Quartz | Level 8

## Setting up a mixed model

Hello all,

I have a sample containing data on 400 school students.

For each student I have 3 dependent variables: Y1, Y2, Y3

In addition, for each student I have several independent variables: Age, Gender, ....

The students come from classes. Some students share the same class, so for each student I have the class as another independent variable.

In a different file, I have teacher data, such as teacher age, teacher gender,...

I need to try and find out which variables relate, or affect Y1, Y2 and Y3.

Since I have students from the same class, I thought that class should be a random effect and I will need PROC Mixed for the analysis (Y1 Y2 and Y3 are all continuous).

I am not sure what to do with the teacher data. Teacher's age might affect the dependent variables, same is gender. Can I simply add these variables to the model as fixed effects, while class is random effect ? Obviously, same class means same teacher...

Is this code reasonable ?

```proc mixed data=school;
class Gender_S Gender_T;
model Y1 = Gender_S Gender_T Age_S Age_T;      random class;
run;```

And one more thing if I may. Is there a way to analyze all dependent variables together, like in MANOVA or MANCOVA, but only with mixed models ?

2 REPLIES 2
Obsidian | Level 7

## Betreff: Setting up a mixed model

Hey,

for a random intercept model you code will look like

``````proc mixed data=school;
class Gender_S Gender_T ;
model Y1 = Gender_S Gender_T Age_S Age_T;
random int / sub=class;
run;``````

However, usually class should also be a class variable, so you should add this to the class statement. In addition, you should look at the type option for the random statement.

Bye,

Daniel

Rhodochrosite | Level 12

## Re: Setting up a mixed model

Your code might work correctly, or it might not. Among other things, whether your code is correct depends upon the data structure (what observations exist for what levels of what factors) in addition to how the data set is sorted (because the class variable is not in the CLASS statement) plus how you have coded the levels for your random effects factors.

How many classes do you have? What does the tabulation of age x gender look like for classes: in other words, how many classes do you have for each combination of age (how many levels?) and gender (2 levels presumably) and for the marginal totals for age and gender?

At the class level, notice that you have a two-way factorial (either without or with interaction) of age and gender. There is intuitive value in recognizing this ANOVA for class-level data as you set up a mixed model with students nested within classes (which is likely a form of split-plot design). If you do not have adequate replication (i.e., multiple classes) of teacher age and gender, then your ability to model the effects of teacher age and gender on student outcomes is limited or even not possible.

The MIXED procedure is able to do multivariate analysis using Kronecker products as discussed here. However, I recommend starting simply, with univariate analyses and make sure those work correctly before attempting multivariate analysis.

SAS® for Mixed Models, Second Edition is an excellent resource that addresses many aspects of your modeling challenge.

Discussion stats
• 2 replies
• 1859 views
• 0 likes
• 3 in conversation