From 8f65ac2aa1ca53001366cf80bd8949dba6c08d65 Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Sat, 6 Dec 2025 15:37:32 -0800 Subject: [PATCH 01/14] started --- Project.toml | 2 +- src/transformations/linear.jl | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Project.toml b/Project.toml index 87147f346..b58860c9e 100644 --- a/Project.toml +++ b/Project.toml @@ -47,7 +47,7 @@ DataAPI = "1" Dictionaries = "0.3, 0.4" DynamicQuantities = "1" FileIO = "1.1" -GLM = "1.7" +GLM = "1.7, 2.0" GeoInterface = "1" GeometryBasics = "0.4.1, 0.5" GridLayoutBase = "0.6, 0.7, 0.8, 0.9, 0.10, 0.11" diff --git a/src/transformations/linear.jl b/src/transformations/linear.jl index ec1932659..ebc268bba 100644 --- a/src/transformations/linear.jl +++ b/src/transformations/linear.jl @@ -3,6 +3,7 @@ Base.@kwdef struct LinearAnalysis{I} dropcollinear::Bool = false interval::I = automatic level::Float64 = 0.95 + weightfunc = GLM.aweights end function add_intercept_column(x::AbstractVector{T}) where {T} @@ -17,19 +18,17 @@ function (l::LinearAnalysis)(input::ProcessedLayer) output = map(input) do p, n x, y = p weights = get(n, :weights, similar(x, 0)) - default_interval = length(weights) > 0 ? nothing : :confidence - interval = l.interval === automatic ? default_interval : l.interval # FIXME: handle collinear case gracefully - lin_model = GLM.lm(add_intercept_column(x), y; wts = weights, l.dropcollinear) - x̂ = range(extrema(x)..., length = l.npoints) - pred = GLM.predict(lin_model, add_intercept_column(x̂); interval, l.level) - return if !isnothing(interval) - ŷ, lower, upper = pred - (x̂, ŷ, x̂, lower, upper), (;) + lin_model = if isempty(weights) + GLM.lm(add_intercept_column(x), y; l.dropcollinear) else - ŷ = pred - (x̂, ŷ, empty(x̂), empty(ŷ), empty(ŷ)), (;) + GLM.glm(add_intercept_column(x), y, GLM.Normal(); wts = l.weightfunc(weights), l.dropcollinear) end + x̂ = range(extrema(x)..., length = l.npoints) + interval = l.interval === automatic ? :confidence : l.interval + pred = GLM.predict(lin_model, add_intercept_column(x̂); interval, l.level) + ŷ, lower, upper = pred + return (x̂, ŷ, x̂, lower, upper), (;) end lineslayer = ProcessedLayer( From 234355b69d8e211fdfd0ff87d2a7d40873e54781 Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Sat, 6 Dec 2025 17:50:25 -0800 Subject: [PATCH 02/14] byo distr --- src/transformations/linear.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/transformations/linear.jl b/src/transformations/linear.jl index ebc268bba..c8f51e79f 100644 --- a/src/transformations/linear.jl +++ b/src/transformations/linear.jl @@ -4,6 +4,7 @@ Base.@kwdef struct LinearAnalysis{I} interval::I = automatic level::Float64 = 0.95 weightfunc = GLM.aweights + distr::GLM.Distribution = GLM.Normal() end function add_intercept_column(x::AbstractVector{T}) where {T} @@ -22,7 +23,7 @@ function (l::LinearAnalysis)(input::ProcessedLayer) lin_model = if isempty(weights) GLM.lm(add_intercept_column(x), y; l.dropcollinear) else - GLM.glm(add_intercept_column(x), y, GLM.Normal(); wts = l.weightfunc(weights), l.dropcollinear) + GLM.glm(add_intercept_column(x), y, l.distr; wts = l.weightfunc(weights), l.dropcollinear) end x̂ = range(extrema(x)..., length = l.npoints) interval = l.interval === automatic ? :confidence : l.interval From 8f7c2d240ca30f19622f17bca41a9475b492f0e0 Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Sat, 6 Dec 2025 17:50:51 -0800 Subject: [PATCH 03/14] temporarily use GLM PR branch --- Project.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Project.toml b/Project.toml index b58860c9e..65550439a 100644 --- a/Project.toml +++ b/Project.toml @@ -40,6 +40,9 @@ AlgebraOfGraphicsUnitfulExt = "Unitful" DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" +[sources] +GLM = {rev = "JuliaStats-master", url = "https://github.com/gragusa/GLM.jl"} + [compat] Accessors = "0.1" Colors = "0.12, 0.13" From 494442e7cd62d5537bc594af67fd3caff60cce54 Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Sun, 7 Dec 2025 10:48:22 -0800 Subject: [PATCH 04/14] weightfunc --> weightkind --- src/transformations/linear.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transformations/linear.jl b/src/transformations/linear.jl index c8f51e79f..98c494751 100644 --- a/src/transformations/linear.jl +++ b/src/transformations/linear.jl @@ -3,7 +3,7 @@ Base.@kwdef struct LinearAnalysis{I} dropcollinear::Bool = false interval::I = automatic level::Float64 = 0.95 - weightfunc = GLM.aweights + weightkind = GLM.aweights distr::GLM.Distribution = GLM.Normal() end @@ -23,7 +23,7 @@ function (l::LinearAnalysis)(input::ProcessedLayer) lin_model = if isempty(weights) GLM.lm(add_intercept_column(x), y; l.dropcollinear) else - GLM.glm(add_intercept_column(x), y, l.distr; wts = l.weightfunc(weights), l.dropcollinear) + GLM.glm(add_intercept_column(x), y, l.distr; wts = l.weightkind(weights), l.dropcollinear) end x̂ = range(extrema(x)..., length = l.npoints) interval = l.interval === automatic ? :confidence : l.interval From 9cbad4532361b7777fcebe3e1647ef67277d0173 Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Sun, 7 Dec 2025 11:31:28 -0800 Subject: [PATCH 05/14] docs started --- docs/src/reference/analyses.md | 25 +++++++++++++++++++++++++ src/transformations/linear.jl | 6 ++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/src/reference/analyses.md b/docs/src/reference/analyses.md index 0a0b30975..31b444896 100644 --- a/docs/src/reference/analyses.md +++ b/docs/src/reference/analyses.md @@ -152,6 +152,31 @@ specs = data(df) * mapping(:x, :y, color=:a => nonnumeric) * ( draw(specs) ``` +Below are a few examples showing the `linear` interface for performing weighted fits: + +```@example analyses +colors = Makie.wong_colors() +df = let + x = 1:5 + y_err = randn(length(x)) + y = x .+ y_err + y_unc = abs.(y_err) + (; x, y, y_unc) +end +specs = data(df) * mapping(:x, :y) * ( + (visual(Scatter) + mapping(:y_unc) * visual(Errorbars)) * visual(; label = "data") + + mapping(; weights = :y_unc) * ( + linear(; weightkind = aweights) * visual(; color = colors[1], label = "aweights") + + linear(; weightkind = fweights) * visual(; color = colors[2], label = "fweights") + + linear(; weightkind = pweights) * visual(; color = colors[3], label = "pweights") + ) + +) +draw(specs) +``` + +Note that the usual caveats still apply for working with different kinds of weights. See the [StatsBase.jl documentation](https://juliastats.org/StatsBase.jl/stable/weights/) for more. + ## Smoothing ```@docs diff --git a/src/transformations/linear.jl b/src/transformations/linear.jl index 98c494751..1f66ee74c 100644 --- a/src/transformations/linear.jl +++ b/src/transformations/linear.jl @@ -50,7 +50,7 @@ function (l::LinearAnalysis)(input::ProcessedLayer) end """ - linear(; interval=automatic, level=0.95, dropcollinear=false, npoints=200) + linear(; interval=automatic, level=0.95, dropcollinear=false, npoints=200, weightkind=GLM.aweights, distr=GLM.Normal()) Compute a linear fit of `y ~ 1 + x`. An optional named mapping `weights` determines the weights. Use `interval` to specify what type of interval the shaded band should represent, @@ -62,7 +62,9 @@ By default, this analysis errors on singular (collinear) data. To avoid that, it is possible to set `dropcollinear=true`. `npoints` is the number of points used by Makie to draw the shaded band. -Weighted data is supported via the keyword `weights` (passed to `mapping`). +Weighted data is supported via the keyword `weights` (passed to `mapping`). Additional +uncertainty support is provided via the `weightkind` and `distr` keywords that are passed to +`GLM.glm`. See the GLM.jl documentation for more on working with these keywords. This transformation creates two `ProcessedLayer`s labelled `:prediction` and `:ci`, which can be styled separately with `[subvisual](@ref)`. """ From a77a0b5a3d29577d52f79dfc91f79f7f0894069e Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Sun, 7 Dec 2025 12:21:23 -0800 Subject: [PATCH 06/14] added weighttransform --- src/transformations/linear.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/transformations/linear.jl b/src/transformations/linear.jl index 1f66ee74c..5aec56e24 100644 --- a/src/transformations/linear.jl +++ b/src/transformations/linear.jl @@ -3,7 +3,8 @@ Base.@kwdef struct LinearAnalysis{I} dropcollinear::Bool = false interval::I = automatic level::Float64 = 0.95 - weightkind = GLM.aweights + weightkind = GLM.fweights + weighttransform = identity distr::GLM.Distribution = GLM.Normal() end @@ -23,7 +24,7 @@ function (l::LinearAnalysis)(input::ProcessedLayer) lin_model = if isempty(weights) GLM.lm(add_intercept_column(x), y; l.dropcollinear) else - GLM.glm(add_intercept_column(x), y, l.distr; wts = l.weightkind(weights), l.dropcollinear) + GLM.glm(add_intercept_column(x), y, l.distr; wts = l.weightkind(l.weighttransform(weights)), l.dropcollinear) end x̂ = range(extrema(x)..., length = l.npoints) interval = l.interval === automatic ? :confidence : l.interval @@ -50,7 +51,7 @@ function (l::LinearAnalysis)(input::ProcessedLayer) end """ - linear(; interval=automatic, level=0.95, dropcollinear=false, npoints=200, weightkind=GLM.aweights, distr=GLM.Normal()) + linear(; interval=automatic, level=0.95, dropcollinear=false, npoints=200, weightkind=GLM.fweights, weighttransform=identity, distr=GLM.Normal()) Compute a linear fit of `y ~ 1 + x`. An optional named mapping `weights` determines the weights. Use `interval` to specify what type of interval the shaded band should represent, @@ -64,7 +65,8 @@ it is possible to set `dropcollinear=true`. Weighted data is supported via the keyword `weights` (passed to `mapping`). Additional uncertainty support is provided via the `weightkind` and `distr` keywords that are passed to -`GLM.glm`. See the GLM.jl documentation for more on working with these keywords. +`GLM.glm`. See the GLM.jl documentation for more on working with these keywords. A `weighttransform` +keyword is also provided to transform the weights before they are passed. This transformation creates two `ProcessedLayer`s labelled `:prediction` and `:ci`, which can be styled separately with `[subvisual](@ref)`. """ From 2cf6b06e8abc4f0be04c91c554be6c0fca8d38c8 Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Sun, 7 Dec 2025 12:27:01 -0800 Subject: [PATCH 07/14] update docs --- docs/src/reference/analyses.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/src/reference/analyses.md b/docs/src/reference/analyses.md index 31b444896..8ad09cc89 100644 --- a/docs/src/reference/analyses.md +++ b/docs/src/reference/analyses.md @@ -152,9 +152,11 @@ specs = data(df) * mapping(:x, :y, color=:a => nonnumeric) * ( draw(specs) ``` -Below are a few examples showing the `linear` interface for performing weighted fits: +Below are a few examples showing the [`linear`](@ref) interface for performing weighted fits: ```@example analyses +using Random +Random.seed!(111) colors = Makie.wong_colors() df = let x = 1:5 @@ -166,12 +168,11 @@ end specs = data(df) * mapping(:x, :y) * ( (visual(Scatter) + mapping(:y_unc) * visual(Errorbars)) * visual(; label = "data") + mapping(; weights = :y_unc) * ( - linear(; weightkind = aweights) * visual(; color = colors[1], label = "aweights") + - linear(; weightkind = fweights) * visual(; color = colors[2], label = "fweights") + - linear(; weightkind = pweights) * visual(; color = colors[3], label = "pweights") + linear(; weightkind = aweights, weighttransform = x -> inv.(x .^ 2)) * visual(; color = :red, label = "aweights") + + linear(; weightkind = fweights) * visual(; color = :blue, label = "fweights") + + linear(; weightkind = pweights) * visual(; color = :green, label = "pweights") ) - -) +) |> draw draw(specs) ``` From ac450f43d33c2f50ae1477787349db37692b234c Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Tue, 23 Dec 2025 11:29:51 -0800 Subject: [PATCH 08/14] weights no longer exported by GLM, use symbols instead --- src/transformations/linear.jl | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/transformations/linear.jl b/src/transformations/linear.jl index 5aec56e24..51e174ef3 100644 --- a/src/transformations/linear.jl +++ b/src/transformations/linear.jl @@ -3,7 +3,7 @@ Base.@kwdef struct LinearAnalysis{I} dropcollinear::Bool = false interval::I = automatic level::Float64 = 0.95 - weightkind = GLM.fweights + weightkind::Symbol = :fweights weighttransform = identity distr::GLM.Distribution = GLM.Normal() end @@ -16,6 +16,22 @@ function add_intercept_column(x::AbstractVector{T}) where {T} end # TODO: add multidimensional version +function get_weightkind(s::Symbol) + weightkind = if s == :aweights + GLM.aweights + elseif s == :pweights + GLM.pweights + elseif s == :uweights + GLM.uweights + elseif s == :eweights + GLM.ewights + else + GLM.fweights + end + + return weightkind +end + function (l::LinearAnalysis)(input::ProcessedLayer) output = map(input) do p, n x, y = p @@ -24,7 +40,8 @@ function (l::LinearAnalysis)(input::ProcessedLayer) lin_model = if isempty(weights) GLM.lm(add_intercept_column(x), y; l.dropcollinear) else - GLM.glm(add_intercept_column(x), y, l.distr; wts = l.weightkind(l.weighttransform(weights)), l.dropcollinear) + weightkind = get_weightkind(l.weightkind) + GLM.glm(add_intercept_column(x), y, l.distr; wts = weightkind(l.weighttransform(weights)), l.dropcollinear) end x̂ = range(extrema(x)..., length = l.npoints) interval = l.interval === automatic ? :confidence : l.interval @@ -51,7 +68,7 @@ function (l::LinearAnalysis)(input::ProcessedLayer) end """ - linear(; interval=automatic, level=0.95, dropcollinear=false, npoints=200, weightkind=GLM.fweights, weighttransform=identity, distr=GLM.Normal()) + linear(; interval=automatic, level=0.95, dropcollinear=false, npoints=200, weightkind=:fweights, weighttransform=identity, distr=GLM.Normal()) Compute a linear fit of `y ~ 1 + x`. An optional named mapping `weights` determines the weights. Use `interval` to specify what type of interval the shaded band should represent, From fe85b63219b967bd04117530308a7f1cbda36bb2 Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Tue, 23 Dec 2025 15:25:27 -0800 Subject: [PATCH 09/14] sync doc examples --- docs/src/reference/analyses.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/src/reference/analyses.md b/docs/src/reference/analyses.md index 8ad09cc89..6714e6d32 100644 --- a/docs/src/reference/analyses.md +++ b/docs/src/reference/analyses.md @@ -168,11 +168,11 @@ end specs = data(df) * mapping(:x, :y) * ( (visual(Scatter) + mapping(:y_unc) * visual(Errorbars)) * visual(; label = "data") + mapping(; weights = :y_unc) * ( - linear(; weightkind = aweights, weighttransform = x -> inv.(x .^ 2)) * visual(; color = :red, label = "aweights") + - linear(; weightkind = fweights) * visual(; color = :blue, label = "fweights") + - linear(; weightkind = pweights) * visual(; color = :green, label = "pweights") + linear(; weightkind = :aweights, weighttransform = x -> inv.(x .^ 2)) * visual(; color = colors[1], label = "aweights") + + linear(; weightkind = :fweights) * visual(; color = colors[2], label = "fweights") + + linear(; weightkind = :pweights) * visual(; color = colors[3], label = "pweights") ) -) |> draw +) draw(specs) ``` From 3118fc98c5575723bca48b2407961cea2ca491e6 Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Thu, 8 Jan 2026 03:36:23 -0800 Subject: [PATCH 10/14] adjust compat --- Project.toml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index 3b2f0383d..114e83e81 100644 --- a/Project.toml +++ b/Project.toml @@ -40,9 +40,6 @@ AlgebraOfGraphicsUnitfulExt = "Unitful" DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" -[sources] -GLM = {rev = "master", url = "https://github.com/JuliaStats/GLM.jl"} - [compat] Accessors = "0.1" Colors = "0.12, 0.13" @@ -50,7 +47,7 @@ DataAPI = "1" Dictionaries = "0.3, 0.4" DynamicQuantities = "1" FileIO = "1.1" -GLM = "2.0" +GLM = "1.9.2" GeoInterface = "1" GeometryBasics = "0.4.1, 0.5" GridLayoutBase = "0.6, 0.7, 0.8, 0.9, 0.10, 0.11" From 88ff001de462516c05423bae604df508efea4207 Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Thu, 8 Jan 2026 04:27:28 -0800 Subject: [PATCH 11/14] update docs [skip ci] --- docs/src/reference/analyses.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/src/reference/analyses.md b/docs/src/reference/analyses.md index 6714e6d32..068d8a807 100644 --- a/docs/src/reference/analyses.md +++ b/docs/src/reference/analyses.md @@ -168,9 +168,11 @@ end specs = data(df) * mapping(:x, :y) * ( (visual(Scatter) + mapping(:y_unc) * visual(Errorbars)) * visual(; label = "data") + mapping(; weights = :y_unc) * ( - linear(; weightkind = :aweights, weighttransform = x -> inv.(x .^ 2)) * visual(; color = colors[1], label = "aweights") + - linear(; weightkind = :fweights) * visual(; color = colors[2], label = "fweights") + - linear(; weightkind = :pweights) * visual(; color = colors[3], label = "pweights") + linear(; weighttype = :fweights, weighttransform = x -> inv.(x .^ 2)) * visual(; color = colors[1], label = "fweights") + + # Other weights available once GLM v2 is released + #linear(; weighttype = :aweights) * visual(; color = colors[2], label = "aweights") + #linear(; weighttype = :pweights) * visual(; color = colors[3], label = "pweights") ) ) draw(specs) From 3bb3f5ed7a7bb8a5153aeab8118421f074bab8dd Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Thu, 8 Jan 2026 13:58:06 -0800 Subject: [PATCH 12/14] docstring cleanup [skip ci] --- src/transformations/linear.jl | 6 +++--- test/runtests.jl | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/transformations/linear.jl b/src/transformations/linear.jl index d3013bfa6..275556da8 100644 --- a/src/transformations/linear.jl +++ b/src/transformations/linear.jl @@ -19,7 +19,7 @@ function get_weighttype(s::Symbol) weighttype = if s == :fweights StatsBase.fweights else - throw(ArgumentError("Currently, StatsBase.jl only supports `fweights`.")) + throw(ArgumentError("Currently, GLM.jl only supports `StatsBase.fweights`.")) end # TODO: Uncomment when GLM v2.0 is released @@ -48,7 +48,7 @@ function (l::LinearAnalysis)(input::ProcessedLayer) lin_model = if isempty(weights) GLM.lm(add_intercept_column(x), y; l.dropcollinear) else - GLM.glm(add_intercept_column(x), y, l.distr; weights, l.dropcollinear) + GLM.glm(add_intercept_column(x), y, l.distr; wts = weights, l.dropcollinear) end x̂ = range(extrema(x)..., length = l.npoints) pred = GLM.predict(lin_model, add_intercept_column(x̂); interval, l.level) @@ -91,7 +91,7 @@ By default, this analysis errors on singular (collinear) data. To avoid that, it is possible to set `dropcollinear=true`. `npoints` is the number of points used by Makie to draw the shaded band. -Weighted data is supported via the `weights` keyword passed to `mapping`. +Weighted data is supported via the keyword `weights` (passed to `mapping`). Additional weight support is provided via the `weighttype`, `weighttransform`, and `distr` keywords. `weightype` specifies the `StatsBase.AbstractWeights` type to use. `weighttransform` accepts an optional function to transform the weights before they are passed to `GLM.glm`. diff --git a/test/runtests.jl b/test/runtests.jl index b6b34db32..381f4f7ba 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -53,16 +53,16 @@ end include("reference_tests_utils.jl") -include("utils.jl") -include("visual.jl") -include("algebra.jl") +#include("utils.jl") +#include("visual.jl") +#include("algebra.jl") include("analyses.jl") -include("scales.jl") -include("helpers.jl") -include("facet.jl") -include("legend.jl") -include("geometry.jl") -include("paginate.jl") +#include("scales.jl") +#include("helpers.jl") +#include("facet.jl") +#include("legend.jl") +#include("geometry.jl") +#include("paginate.jl") @testset "Reference tests" begin include("reference_tests.jl") From 13f9dff42febff8acbf9c734cfce06c5a86a9f53 Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Thu, 8 Jan 2026 14:01:16 -0800 Subject: [PATCH 13/14] cleanup --- src/transformations/linear.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/transformations/linear.jl b/src/transformations/linear.jl index 275556da8..563dc992b 100644 --- a/src/transformations/linear.jl +++ b/src/transformations/linear.jl @@ -40,8 +40,7 @@ end function (l::LinearAnalysis)(input::ProcessedLayer) output = map(input) do p, n x, y = p - weighttype = get_weighttype(l.weighttype) - weights = (weighttype ∘ l.weighttransform)(get(n, :weights, similar(x, 0))) + weights = (get_weighttype(l.weighttype) ∘ l.weighttransform)(get(n, :weights, similar(x, 0))) default_interval = length(weights) > 0 ? :confidence : nothing interval = l.interval === automatic ? default_interval : l.interval # FIXME: handle collinear case gracefully From c3bbc262f5adb559cff42fd883e6f4fdc53eec84 Mon Sep 17 00:00:00 2001 From: Ian Weaver Date: Thu, 8 Jan 2026 22:41:06 -0800 Subject: [PATCH 14/14] cleanup --- src/transformations/linear.jl | 11 +++++++---- test/runtests.jl | 18 +++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/transformations/linear.jl b/src/transformations/linear.jl index 563dc992b..0e4325afb 100644 --- a/src/transformations/linear.jl +++ b/src/transformations/linear.jl @@ -22,7 +22,8 @@ function get_weighttype(s::Symbol) throw(ArgumentError("Currently, GLM.jl only supports `StatsBase.fweights`.")) end - # TODO: Uncomment when GLM v2.0 is released + # TODO: Can support these weights as well after GLM v2 is released + # https://github.com/JuliaStats/GLM.jl/pull/619 #weighttype = if s == :aweights # StatsBase.aweights #elseif s == :pweights @@ -41,13 +42,15 @@ function (l::LinearAnalysis)(input::ProcessedLayer) output = map(input) do p, n x, y = p weights = (get_weighttype(l.weighttype) ∘ l.weighttransform)(get(n, :weights, similar(x, 0))) - default_interval = length(weights) > 0 ? :confidence : nothing - interval = l.interval === automatic ? default_interval : l.interval + interval = l.interval === automatic ? :confidence : l.interval # FIXME: handle collinear case gracefully + # TODO: `wts` --> `weights` after GLM v2 is released + # https://github.com/JuliaStats/GLM.jl/pull/631 lin_model = if isempty(weights) GLM.lm(add_intercept_column(x), y; l.dropcollinear) else - GLM.glm(add_intercept_column(x), y, l.distr; wts = weights, l.dropcollinear) + # Supports confidence intervals, while `GLM.lm` currently does not + GLM.glm(add_intercept_column(x), y, l.distr; weights, l.dropcollinear) end x̂ = range(extrema(x)..., length = l.npoints) pred = GLM.predict(lin_model, add_intercept_column(x̂); interval, l.level) diff --git a/test/runtests.jl b/test/runtests.jl index 381f4f7ba..b6b34db32 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -53,16 +53,16 @@ end include("reference_tests_utils.jl") -#include("utils.jl") -#include("visual.jl") -#include("algebra.jl") +include("utils.jl") +include("visual.jl") +include("algebra.jl") include("analyses.jl") -#include("scales.jl") -#include("helpers.jl") -#include("facet.jl") -#include("legend.jl") -#include("geometry.jl") -#include("paginate.jl") +include("scales.jl") +include("helpers.jl") +include("facet.jl") +include("legend.jl") +include("geometry.jl") +include("paginate.jl") @testset "Reference tests" begin include("reference_tests.jl")