One of the things I love about MIXED in SPSS is that the syntax is very similar to GLM. So anyone who is used to the GLM syntax has just a short jump to learn writing MIXED.

Which is a good thing, because many of the concepts are a big jump.

And because the MIXED dialogue menus are seriously unintuitive, I’ve concluded you’re much better off using syntax.

I was very happy a few years ago when, with version 19, SPSS finally introduced generalized linear mixed models so SPSS users could finally run logistic regression or count models on clustered data.

But then I tried it, and the menus are even less intuitive than in MIXED.

And the syntax isn’t much better. In this case, the syntax structure is quite different than for MIXED.

And I find the model viewer output quite cumbersome to navigate. (Edit: There is now a way to turn off the model viewer. Woo hoo!)

But if you really need to use GENLINMIXED, I thought I’d show you how to write some of the syntax. Seriously, just skip the menus altogether. They’re confusing.

Below is the exact same model written in both MIXED and GENLINMIXED. Because the DV, JobsK, is quantitative, and I’m assuming normal residuals, I can get the same results in both.

If you are running something like a logistic regression model, you can’t use MIXED and will have to change the LINK and DISTRIBUTION options.

### The Random Intercept Model in both procedures:

MIXED JobsK BY Rural WITH Time

/FIXED=Rural Time Rural*Time| SSTYPE(3)

/METHOD=REML

/RANDOM Intercept|Subject(County) COVTYPE(VC).

*Generalized Linear Mixed Models.

GENLINMIXED

/DATA_STRUCTURE SUBJECTS=County

/FIELDS TARGET=JobsK

/TARGET_OPTIONS DISTRIBUTION=NORMAL LINK=IDENTITY

/FIXED EFFECTS=Rural Time Rural*Time USE_INTERCEPT=TRUE

/RANDOM USE_INTERCEPT=TRUE SUBJECTS=County

COVARIANCE_TYPE=VARIANCE_COMPONENTS

/BUILD_OPTIONS TARGET_CATEGORY_ORDER=ASCENDING

INPUTS_CATEGORY_ORDER=ASCENDING MAX_ITERATIONS=100

CONFIDENCE_LEVEL=95 DF_METHOD=RESIDUAL COVB=MODEL.

You will notice that, for example, both procedures have a FIXED and a RANDOM subcommand. The FIXED subcommand lists the fixed effects. The only really differences are that in GENLINMIXED you have to put EFFECTS= and you have to specify that you do want an intercept.

Likewise, the RANDOM subcommand tell SPSS the same thing in both models, but just has slightly different sytnax to do so. In both cases, you need to list the random effects, indicate the subject and specify the covariance structure.

All the other subcommands in GENLINMIXED are explicity defining different parts of the model. Not all of these are relevant to a linear model, but the options are there to change them for another type of Generalized Linear Mixed Model.

And just to be thorough, here again is the syntax for a random slope model in both procedures. I’ve bolded the parts in both that specify the random slope for Time.

### The Random Slope for Time Model in Both Procedures:

MIXED JobsK BY Rural WITH Time

/FIXED=Rural Time Rural*Time| SSTYPE(3)

/METHOD=REML

/RANDOM Intercept **Time**|Subject(County) COVTYPE(VC).

GENLINMIXED

/DATA_STRUCTURE SUBJECTS=County

/FIELDS TARGET=JobsK

/TARGET_OPTIONS DISTRIBUTION=NORMAL LINK=IDENTITY

/FIXED EFFECTS=Rural Time Rural*Time USE_INTERCEPT=TRUE

/RANDOM **EFFECTS =Time** USE_INTERCEPT=TRUE SUBJECTS=County

COVARIANCE_TYPE=VARIANCE_COMPONENTS

/BUILD_OPTIONS TARGET_CATEGORY_ORDER=ASCENDING

INPUTS_CATEGORY_ORDER=ASCENDING MAX_ITERATIONS=100

CONFIDENCE_LEVEL=95 DF_METHOD=RESIDUAL COVB=MODEL.

This was the example used in our free webinar: Random Intercept and Random Slope Models. The recording of the webinar is freely available for download.

{ 7 comments… read them below or add one }

Hi Karen,

Thank you for your webinars and blogs on LMM, they have been a real help to me. i do have a quick question though. I am wanting to know if I can look at two random effects of intercepts within the same model. For example, I want to control for the random effects of intercepts for Participants and Items/Trials. How would I go about writing this in my syntax please? I am working with SPSS.

Kind regards,

Gabbie

Would it be possible for you to post the syntax above that produced the final output in SPSS in the webinar on random intercepts and slopes? I think I mostly get how the syntax above produce random intercept model for that example, and then random slope for that model, but I cannot figure out how to get out of GLMM the output you have that has the correlation between the random slope and intercept. I cannot figure anyway to build it in the menus (SPSS 25) nor can I imagine what it looks like in syntax. In other words, I don’t see how to get the output for the “estimates of covariance parameters” that you show on slide page 12 in the webinar.

One other question. I do not understand why you do not specify the repeated measure of Time in the data structure. It seems like that would be what one would do, but the output gets further away from anything you have when I do that, but I just cannot imagine why that’s not a thing to do.

Thanks for the great webinars, btw. Really helpful stuff to me.

Hi Scott,

It’s the covariance structure of the random effects. In the models above, both mixed and genlinmixed, I’m using variance components, which is telling spss to NOT estimate a covariance parameter between the intercept and slope. Just to include variance estimates.

If you want that parameter estimate, you need to use unstructured instead.

Can you do deviance statistics with GenLinMixed? that’s usually what I do with Mixed but the output of GenLinMixed is a little confusing and I don’t know what to do with (how to interpret) a Wald Z for each trial number.

Hi Karen,

Thanks for the quick response! SPSS 22 can provide Sattherwaite df’s so I’ll try that and see how my models look.

Richard

Dear Karen,

I am running a series of generalized linear mixed models with SPSS version 22 using the GENLINMIXED procedure and I have read your post with great interest. I am examining the factors associated with how children travel to and from school (e.g. dichotomous outcome : active vs. motorized transport), so I am using a binomial distribution with a logit link. This is a 3-level model (e.g., children nested within schools nested within countries) which makes calculation of the degrees of freedom messy. I would like to know if there is any way to obtain Kenward-Roger degrees of freedom for my models.

Thanks in advance!

Richard

Hi Richard,

Not in SPSS. As far as I know, only SAS has options for changing the type of df and I’d have to check whether that’s just in mixed or also glimmix.

Karen