Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random effects reporting with spaMM and CIs with lme4 #890

Open
KimColyvas opened this issue Aug 5, 2023 · 2 comments
Open

Random effects reporting with spaMM and CIs with lme4 #890

KimColyvas opened this issue Aug 5, 2023 · 2 comments
Labels
3 investigators ❔❓ Need to look further into this issue Enhancement 💥 Implemented features can be improved or revised

Comments

@KimColyvas
Copy link

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)

@strengejacke strengejacke added Enhancement 💥 Implemented features can be improved or revised 3 investigators ❔❓ Need to look further into this issue labels Sep 1, 2023
@strengejacke
Copy link
Member

This is not yet supported from models from package spaMM, but it looks like it should be possible.

@KimColyvas
Copy link
Author

Thanks for getting back to me. If you do find the time to deal with issues I found let me know as these two aspects are still relevant to a (very slow moving) paper we are working on.
Kim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 investigators ❔❓ Need to look further into this issue Enhancement 💥 Implemented features can be improved or revised
Projects
None yet
Development

No branches or pull requests

2 participants