Skip to content

Commit

Permalink
re-initialize to small values
Browse files Browse the repository at this point in the history
  • Loading branch information
palday committed Dec 10, 2024
1 parent 9c50828 commit c7f80d0
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/generalizedlinearmixedmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,10 @@ function GeneralizedLinearMixedModel(
tbl,
d::Distribution,
l::Link=canonicallink(d);
wts=[],
offset=[],
contrasts=Dict{Symbol,Any}(),
amalgamate=true,
kwargs...,
)
return GeneralizedLinearMixedModel(
f, Tables.columntable(tbl), d, l; wts, offset, contrasts, amalgamate
f, Tables.columntable(tbl), d, l; kwargs...,
)
end

Expand Down Expand Up @@ -469,7 +466,16 @@ function GeneralizedLinearMixedModel(
)

# if the response is constant, there's no point (and this may even fail)
constresponse || deviance!(res, 1)
constresponse || try
deviance!(res, 1)
catch ex
ex isa PosDefException || rethrow()
@warn "Evaluation at default initial parameter vector failed, " *
"initializing to very small variances. This may result in long " *
"model fitting times. You will probably also need to use " *
"`init_from_lmm=[:β, :θ]` in order to fit the model."
res.optsum.initial[res.optsum.initial .!= 0] .= 1e-8
end

return res
end
Expand Down

0 comments on commit c7f80d0

Please sign in to comment.