Skip to content

Extract posterior variance for single random intercept (Poisson GLMM) #868

@jan-engelmann

Description

@jan-engelmann

Hi,
thanks for putting this out!
my model is

frm = @formula(counts ~ 1 +C1 + C2 + ... + C37 + (1 | genotype_id))
modelp = fit(MixedModel,frm, df, Poisson(), fast = true) 

in lme4 I can get the random mode and conditional variance like:
lme4::ranef(model, condVar = TRUE)

In MixedModels I can get the means with only(raneftables(model))

For a LMM is it correct to extract the variance as below?

  ranefs = DataFrame(only(raneftables(model)))
  rename!(ranefs, Dict("(Intercept)" => "mean"))
  ranefs.var = vec(condVar(model)[1][1, 1, :])

For a Poisson GLMM, I get the following error:

MethodError: no method matching condVar(::GeneralizedLinearMixedModel{Float64, Poisson{Float64}})

Closest candidates are:
  condVar(::LinearMixedModel{T}, ::Any) where T
   @ MixedModels ~/.julia/packages/MixedModels/L0NHA/src/linearmixedmodel.jl:324
  condVar(::LinearMixedModel{T}) where T
   @ MixedModels ~/.julia/packages/MixedModels/L0NHA/src/linearmixedmodel.jl:320


Stacktrace:
 [1] top-level scope
   @ In[74]:1

What would be the right way to calculate the posterior variance of the random intercept per group?

Thanks a lot for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions