easystats / easystats/parameters

Random effects reporting with spaMM and CIs with lme4

Open
#890 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3 investigators :grey_question::question: Enhancement :boom:
Dominant language
R
Stars
499
Forks
45
Avg merge
3d 1h
Merged PRs (30d)
3

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the spaMM and lme4 examples in the issue, including the model_parameters() calls with random effects and Wald or profile confidence intervals. Compare the observed output with the documented HLfit support and determine whether spaMM random effects and the requested confidence intervals should be reported consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.