I need to estimate a generalized linear mixed model (GLMM). When using R, I need to choose a specific fixed effect (one of the independent variables in the model) to have a random slope according to a random variable such as subject ID. But when using SPSS, I can't choose a specific fixed effect to have a random slope.
I asked chatGPT about it and it responded as follows:
The difference you're observing in the specification of random slopes for specific fixed effects between SPSS and R might be related to how the two software packages handle mixed-effects modeling. This difference is not necessarily due to the capabilities of the software but rather the way they present the options to the user. Here's why this might be the case: SPSS: In SPSS, the interface for specifying mixed-effects models is designed to be user-friendly and may abstract away some of the technical details. It allows users to specify random slopes and intercepts for subjects using the Repeated option or Mixed Linear Models (MIXED) procedure. SPSS may automatically set up random slopes for all fixed effects by default, which is a more automated approach, but it doesn't give you explicit control over which fixed effects have random slopes. R (lme4 package): R, specifically with the lme4 package, provides more flexibility and control in specifying mixed-effects models. This can be both an advantage and a challenge for users. In R, you have to explicitly specify which fixed effect(s) should have random slopes by including them in the model formula. This explicit control allows for more customized modeling but can be more complex and requires users to have a good understanding of their data and the modeling process.
1. Can someone please confirm this answer? 2. Is there a way to estimate a mixed-effect logistic regression model in R that would be the same as the estimated model in SPSS?
I would appreciate any clues about this issue! Thanks!
In R I tried:
model <- glmer(y ~ x1 + x2 + x3 + x4 + x5 + x6 + (-1 + x1 + x2 + x3 + x4 + x5 + x6 | workerId), data = exp_data, family = binomial)
and got this error message:
Error: number of observations (=2193) < number of random effects (=7310) for term (-1 + x1 + x2 + x3 + x4 + x5 + x6 | workerId); the random-effects parameters are probably unidentifiable