Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions issues/794/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
BSplineKit = "093aae92-e908-43d7-9660-e50ee39d5a0a"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
MixedModels = "ff71e718-51f3-5ec2-a782-8ffcbfa3c316"
MixedModelsDatasets = "7e9fb7ac-9f67-43bf-b2c8-96ba0796cbb6"
13 changes: 13 additions & 0 deletions issues/794/main.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using CSV
using MixedModels
using MixedModelsDatasets: dataset
x = CSV.read(download("https://gist.githubusercontent.com/yjunechoe/af4a8dd3e2b0343fe3818e93dba8c81d/raw/x.csv"), Table);
m = fit(MixedModel, @formula(y ~ x1 * x2 + (1 | g)), x)

profile(m; threshold=4) # works

profile(m; threshold=3)

s = lmm(@formula(reaction ~ 1 + days + (1 + days| subj)), dataset(:sleepstudy))

profile(s; threshold=3)
11 changes: 9 additions & 2 deletions src/profile/sigmapr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ end
profileσ(m::LinearMixedModel, tc::TableColumns; threshold=4)

Return a Table of the profile of `σ` for model `m`. The profile extends to where the magnitude of ζ exceeds `threshold`.

!!! note
This method is called by `profile` and currently considered internal.
As such, it may change or disappear in a future release without being considered breaking.
Expand Down Expand Up @@ -69,7 +70,13 @@ function profileσ(m::LinearMixedModel{T}, tc::TableColumns{T}; threshold=4) whe
updateL!(setθ!(m, θ))
σv = [r.σ for r in tbl]
ζv = [r.ζ for r in tbl]
fwd = Dict(:σ => interpolate(σv, ζv, BSplineOrder(4), Natural()))
rev = Dict(:σ => interpolate(ζv, σv, BSplineOrder(4), Natural()))
local fwd, rev
try
fwd = Dict(:σ => interpolate(σv, ζv, BSplineOrder(4), Natural()))
rev = Dict(:σ => interpolate(ζv, σv, BSplineOrder(4), Natural()))
catch
@error "An error occurred while fitting the profile splines for σ. Try adjusting the threshold."
rethrow()
end
return (; m, tbl, fwd, rev)
end
11 changes: 8 additions & 3 deletions src/profile/vcpr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,14 @@ function profileσs!(val::NamedTuple, tc::TableColumns{T}; nzlb=1.0e-8) where {T
append!(val.tbl, tbl)
ζcol = getproperty(:ζ).(tbl)
symcol = gpsym.(tbl)
val.fwd[sym] = interpolate(symcol, ζcol, BSplineOrder(4), Natural())
issorted(ζcol) &&
(val.rev[sym] = interpolate(ζcol, symcol, BSplineOrder(4), Natural()))
try
val.fwd[sym] = interpolate(symcol, ζcol, BSplineOrder(4), Natural())
issorted(ζcol) &&
(val.rev[sym] = interpolate(ζcol, symcol, BSplineOrder(4), Natural()))
catch
@error "An error occurred while fitting the profile splines for the variance components. Try adjusting the threshold."
rethrow()
end
end
end
copyto!(final, initial)
Expand Down
Loading