4
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ I'd just like to point out that 1) SPSS most certainly does NOT automatically set up random slopes for all fixed effects by default! and 2) Yes you can choose a particular fixed effect to have a random slope in SPSS, why do you think you can't? 3) the model you present is most likely too complex for almost any actual data, but definitely for your data, as R tells you. $\endgroup$
    – Sointu
    Commented Oct 13, 2023 at 7:07
  • $\begingroup$ Almost certainly, you do not want to include all covariates as random effect terms. Moreover, unless things have changed in the newer version of SPSS, it uses the PQL method to fit GLMMs, which is suboptimal. I would suggest using the lme4 or GLMMadaptive (drizopoulos.github.io/GLMMadaptive) packages in R. $\endgroup$ Commented Oct 13, 2023 at 8:51

1 Answer 1

8
$\begingroup$

I don't know SPSS, but I would recommend checking their documentation or manuals rather than ChatGPT - the latter will literally just make stuff up.

From what I can see in the SPSS documentation a random intercept is not included by default, so you'll have to tick the 'Include Intercept' box if you want one. All other parameters will have to come from effects that may or may not already be in the fixed part of the model, so if you add a continuous ('scale' in SPSS parlance?) effect as a random one you'll have produced a random slope. Adding a categorical effect will create additional random intercepts for observations in those categories. There's nothing that would suggest to me that you can't have the same model as you're trying to fit in R.

The reason for your error is explained within the error message itself: you're trying to fit too many random effect parameters for the number of observations you have within the workerId clusters. You'll need at least as many observations per cluster as you're fitting random effects (6 assuming they require a single degree of freedom each).

$\endgroup$
1
  • 5
    $\begingroup$ In hindsight I was giving ChatGPT too much credit here, it cannot make stuff up. It rather combines word tokens stochastically using statistical patterns it learned from reading who knows what, but has no semantic understanding whatsoever. $\endgroup$
    – PBulls
    Commented Oct 14, 2023 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.