## PROC MIXED: is it possible to define an effect as fixed if it is nested within a random effect?

Solved
Community Manager
Posts: 3,115

# PROC MIXED: is it possible to define an effect as fixed if it is nested within a random effect?

A SAS user on reddit asks this question.  No responses there so far, but I'll bet someone here can comment with a clever explanation.  We can close the loop when we have an answer.

Hi there,

as far as I know SAS does not allow for an effect to be fixed if it is nested within an effect set as random. An example model would be

y = A + A∙B + e

with A random and A∙B fixed.

Can anyone confirm this for me or is there a way to work around it? I'm fine with it not being possible, I just wanted to check if I missed something. I'd like to write in my article that it is not possible.

Thanks

Accepted Solutions
Solution
‎08-30-2016 08:28 AM
Valued Guide
Posts: 684

## Re: PROC MIXED: is it possible to define an effect as fixed if it is nested within a random effect?

You are right. If one effect is random, then it's interaction must be random. The opposite is not true: A and B can both be fixed effects, but A*B can be random. The latter happens a lot, and it a common situation with multi-treatment meta-analysis.

You can force MIXED to do what you want by creating other variables in a DATA step (AA=A; BB=B), and then define some of these as random in in MIXED. I don't recommend this: you could get strange or meaningless results.

All Replies
Solution
‎08-30-2016 08:28 AM
Valued Guide
Posts: 684

## Re: PROC MIXED: is it possible to define an effect as fixed if it is nested within a random effect?

You are right. If one effect is random, then it's interaction must be random. The opposite is not true: A and B can both be fixed effects, but A*B can be random. The latter happens a lot, and it a common situation with multi-treatment meta-analysis.

You can force MIXED to do what you want by creating other variables in a DATA step (AA=A; BB=B), and then define some of these as random in in MIXED. I don't recommend this: you could get strange or meaningless results.

SAS Super FREQ
Posts: 3,835

## Re: PROC MIXED: is it possible to define an effect as fixed if it is nested within a random effect?

But @lvm, isn't it misleading to say "SAS does not allow for an effect to be fixed if it is nested within an effect set as random"?

Is it "SAS" that prevents it, or is it the theory of mixed models that prevents it, and SAS merely adheres to the theory?

Valued Guide
Posts: 684

## Re: PROC MIXED: is it possible to define an effect as fixed if it is nested within a random effect?

Rick, I agree that SAS does not allow it for a reason: statistical theory. My latter suggestion was just to see what happens. It is not a limitation of MIXED: one should consider interactions as random when any of the component main effects are random.

☑ This topic is solved.