easystats/parameters

Random effects reporting with spaMM and CIs with lme4

KimColyvas opened this issue · 0 comments

I have created my questions as part of the comments in the repex below.
Thanks,
Kim

# Repex for issue with parameters package re support of random effects not supported for spaMM mixed models
#
# I was looking to obtain random effects as part of producing summary tables from fitting mixed models
# I am mainly using lme4's glmer but also using spaMM's fitme
# I am finding 2 things
#
# a) No random effects provided for spaMM
#    however my reading of the documentation for parameters suggest it should be supported
#    This is my main concern
#
# According to the help documentation for
# model_parameters.cpglmm {parameters}
# there is a module for spaMM class HLfit
# 
## S3 method for class 'HLfit'
# model_parameters(
#   model,
#   ci = 0.95,
#   ci_method = NULL,
#   bootstrap = FALSE,
#   iterations = 1000,
#   standardize = NULL,
#   exponentiate = FALSE,
#   p_adjust = NULL,
#   summary = getOption("parameters_summary", FALSE),
#   keep = NULL,
#   drop = NULL,
#   parameters = keep,
#   verbose = TRUE,
#   vcov = NULL,
#   vcov_args = NULL,
#   ...
# )
#
#
# b) However I have noticed Variable results re CI's for glmer model fits
#    I have tried the options that I thought should provide them but
#    looks like they are model specific
#    as when I changed the error distribution to normal from gamma I could obtain a profile CI
#    but no Wald CI in either case
#    Is this the current state of development?
#

# (a) spaMM random effect reporting issue
library(spaMM) # spaMM (Rousset & Ferdy, 2014, version 4.2.1) is loaded.
library(parameters) #parameters’ version 0.21.1

data("wafers")
m1_spaMM = fitme(y ~ 1+(1|batch), family=Gamma(log), data=wafers)
summary(m1_spaMM)
parameters(m1_spaMM)

# Tried this based on the parameters documentation 
model_parameters(m1_spaMM,ci=0.90,ci_method="wald",effects="random",ci_random=T)
# Error: Sorry, `model_parameters()` failed with the following error (possible class `HLfit` not supported):

# (b) lme4 random effect CIs - variable results
library(lme4)

# GLMM
m1_glmer = glmer(y ~ 1+(1|batch), family=Gamma(log), data=wafers)
summary(m1_glmer)

# A message is printed from this call that says
# Uncertainty intervals for random effect variances computed using a Wald z-distribution approximation.
# but no CIs are provided
model_parameters(m1_glmer,ci=0.90,ci_method="wald",effects="random",ci_random=T)

# Profile CIs perhaps don't work with non-normal distributions
model_parameters(m1_glmer,ci=0.90,ci_method="profile",effects="random",ci_random=T)

# Switching to LMM
m2_lmer = lmer(y ~ 1+(1|batch), data=wafers)
summary(m2_lmer)

# Profile CIs now work but still no Wald intervals
model_parameters(m2_lmer,ci=0.90,ci_method="wald",effects="random",ci_random=T)
model_parameters(m2_lmer,ci=0.90,ci_method="profile",effects="random",ci_random=T)