Choose Language Hide Translation Bar

## Can I use a nominal factor as a random effect (nested within subject) using Mixed Models?

Using the Mixed Model personality when I try to use a nominal factor (nested within participant) it will not allow me specificy the effect as random (e.g., "nest random coefficients").

It gives me the following error: "Effect id cannot be in a Group. Outside of the nesting, no non-continuous terms allowed in a group."

If I do the same analysis in Fir Model, and define subject as random, I am able to interact the nominal factor with the random subject, but I am unable to define the effect of the nominal variable as random slopes within person, in theMixed Model personality.

1 ACCEPTED SOLUTION

Accepted Solutions

## Re: Can I use a nominal factor as a random effect (nested within subject) using Mixed Models?

Thanks for sharing the data.

The two models you fit (saved as Fit Model 1 and Fit Model 2) are so-called random-effect model or variance components model, in which Subject and Cycle-Prop are specified as two sources of variation but no covariance between the two is allowed. They are not random coefficients models.

I fit a random coefficients model using Nest Random Coefficient button (see the attached table). The results are different.

Hope this helps.

6 REPLIES 6

## Re: Can I use a nominal factor as a random effect (nested within subject) using Mixed Models?

Yes, you can.  Use the Nest button to specify a nested random effect.  Nest Random Coefficients button is used for creating random coefficients models

## Re: Can I use a nominal factor as a random effect (nested within subject) using Mixed Models?

Thanks, this is a pretty simple solution.

However, this leads me to another question regarding the difference between "Nest" and "Nest Random Coefficients" options, because if "Nest" gives you the random effect of the nested factor, then what does the "Nest Random Coefficients" do differently?

To understand the difference between "Nest" and "Nest Random Coefficients" I ran a model with data I'm more used to: Observations nested within subject, when both the predictor and outcome are continuous. This is a simple random intercepts and slopes model. I ran this model using the Nest command (including subject as a random factor, then the predictor nested within subject); then I ran the analysis using the "Nest Random Coefficients" (with random intercepts and slopes).

The results are identical. Not surprising, really. However, this makes it seem that the only difference between the "Nest" option and the "Nest Random Coefficients" option is that the former is a bit more flexible because it allows random effects for a nominal variable.

Am I missing something?

Thanks, Jeff

## Re: Can I use a nominal factor as a random effect (nested within subject) using Mixed Models?

Could you post the data with the saved scripts for models you fit for me to take a look at it?

## Re: Can I use a nominal factor as a random effect (nested within subject) using Mixed Models?

Hi,

and thanks for the help.

I didn’t see how to attach a data file on the message board, so I’ll try to attach it to this massage. The file is very simple (3 variables) and the scripts are saved. Note that these are the data and analyses I used to compare the Nested and Nest Random Coefficients analyses, and do not include a nominal nested factor which was part of the original question.

Thanks again, Jeff

## Re: Can I use a nominal factor as a random effect (nested within subject) using Mixed Models?

Thanks for sharing the data.

The two models you fit (saved as Fit Model 1 and Fit Model 2) are so-called random-effect model or variance components model, in which Subject and Cycle-Prop are specified as two sources of variation but no covariance between the two is allowed. They are not random coefficients models.

I fit a random coefficients model using Nest Random Coefficient button (see the attached table). The results are different.

Hope this helps.

## Re: Can I use a nominal factor as a random effect (nested within subject) using Mixed Models?

Great, this helps, I see the mistake I was making while using the Nest Random Coefficients button.

Thanks again for all of your help, Jeff