Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force non-zero step size for general optimization after boundary fit in fast=true #201

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 2 additions & 0 deletions src/MixedModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export @formula,
Gamma,
GeneralizedLinearMixedModel,
HelmertCoding,
IdentityLink,
InverseGaussian,
InverseLink,
LinearMixedModel,
Expand All @@ -52,6 +53,7 @@ export @formula,
RaggedArray,
RandomEffectsTerm,
ReMat,
SqrtLink,
UniformBlockDiagonal,
VarCorr,
aic,
Expand Down
3 changes: 3 additions & 0 deletions src/generalizedlinearmixedmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ function fit!(m::GeneralizedLinearMixedModel{T};
optsum.initial = vcat(β, m.θ)
optsum.final = copy(optsum.initial)
optsum.initial_step = vcat(stderror(m) ./ 3, min.(T(0.05), m.θ ./ 4))
# force a non-zero step
ss = optsum.initial_step
optsum.initial_step[ss .== 0] .= min(ss[ss .≠ 0]...)
end
setpar! = fast ? setθ! : setβθ!
feval = 0
Expand Down
Binary file added test/lexdec.rds
Binary file not shown.
15 changes: 15 additions & 0 deletions test/pirls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,18 @@ end
#@test isapprox(sum(x -> sum(abs2, x), gm4.u), 196.8695297987013, atol=0.1)
#@test isapprox(sum(gm4.resp.devresid), 220.92685781326136, atol=0.1)
end

@testset "lexdec" begin
lexdec = load(joinpath(dirname(pathof(MixedModels)), "..", "test", "lexdec.rds"))
gmldγ = fit(MixedModel, @formula(RT_raw ~ 1 + Class * NativeLanguage + (1|Subject) + (1|Word)),
lexdec, Gamma(), IdentityLink(), fast=false)
@test all(gmldγ.optsum.initial_step .> 0)
@test first(gmldγ.θ) ≈ 0 atol=0.001

# don't know how much sense this model makes, but it's a boundary fit on two
# boundaries and it uses InverseGaussian()
gmldig = fit(MixedModel, @formula(RT_raw ~ 1 + Class * NativeLanguage + (1|Subject) + (1|Word)),
lexdec, InverseGaussian(), IdentityLink(), fast=false)
@test all(gmldγ.optsum.initial_step .> 0)
@test all(isapprox.(gmldig.θ, 0, atol=0.001))
end