How can we extract the individual random slopes from a MixedModel.jl fit?


#1

In R package lme4, the function coef seems to return slopes for each level of the factor, but in Julia coef returns only fixed effects. (see https://stats.stackexchange.com/questions/122009/extracting-slopes-for-cases-from-a-mixed-effects-model-lme4).

Is there a way to get the individual slopes like in R?

using RData, MixedModels
const dat = Dict(Symbol(k)=>v for (k,v) in
    load(joinpath(dirname(pathof(MixedModels)), "..", "test", "dat.rda")));
sleepstudy = deepcopy(dat[:sleepstudy])
names!(sleepstudy, [:Reaction, :Days, :Subject])
fm1 = fit(LinearMixedModel, @formula(Reaction ~ Days + (Days|Subject)), sleepstudy)

coef(fm1)
# 2-element Array{Float64,1}:
#  251.40510484848375
#   10.467285959596053

#2

From http://dmbates.github.io/MixedModels.jl/stable/constructors/#Conditional-modes-of-the-random-effects-1, looks like the ranef function gives you conditional modes of the random effects.


#3

awesome, just what I needed - thanks!