Skip to content

Commit

Permalink
Remove vestigial _zerocorr while code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
dmbates committed Jul 28, 2021
1 parent 3e2827b commit 0afce6c
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions src/linearmixedmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1177,45 +1177,3 @@ function StatsBase.weights(m::LinearMixedModel)
rtwts = m.sqrtwts
return isempty(rtwts) ? ones(eltype(rtwts), nobs(m)) : abs2.(rtwts)
end

"""
_zerocorr!(m::LinearMixedModel[, trmnms::Vector{Symbol}])
Rewrite the random effects specification for the grouping factors in `trmnms` to zero correlation parameter.
The default for `trmnms` is all the names of random-effects terms.
A random effects term is in the zero correlation parameter configuration when the off-diagonal elements of
λ are all zero - hence there are no correlation parameters in that term being estimated.
Note that this is numerically equivalent to specifying a formula with `zerocorr` around each random effects
term, but the `formula` fields in the resulting model will differ. In particular, `zerocorr!` will **not**
change the original `formula`'s terms to be of type of `ZeroCorr` because this would involve changing
immutable types. This may have implications for software that manipulates the formula of a fitted model.
This is an internal function and may disappear in a future release without being considered a breaking change.
"""
function _zerocorr!(m::LinearMixedModel{T}, trmns) where {T}
reterms = m.reterms
for trm in reterms
if fname(trm) in trmns
zerocorr!(trm)
end
end
newparmap = mkparmap(reterms)
copyto!(m.parmap, newparmap)
resize!(m.parmap, length(newparmap))
optsum = m.optsum
optsum.lowerbd = mapfoldl(lowerbd, vcat, reterms)
optsum.initial = mapfoldl(getθ, vcat, reterms)
optsum.final = copy(optsum.initial)
optsum.xtol_abs = fill!(copy(optsum.initial), 1.0e-10)
optsum.initial_step = T[]

# the model is no longer fitted
optsum.feval = -1

return m
end

_zerocorr!(m::LinearMixedModel) = _zerocorr!(m, fnames(m))

0 comments on commit 0afce6c

Please sign in to comment.