BookmarkSubscribeRSS Feed
Xi1
Calcite | Level 5 Xi1
Calcite | Level 5

Hi all,

I am working on a project where I want to random my subject (ID in my case). I wonder which of the following code is doing a random effect for me? or are they both giving the ID a random effect?

1 proc mixed data=WORK.IMPORT method=reml plots=(residualPanel studentPanel

influenceStatPanel)alpha=0.05;

class ID Treatment Time;

model R=Time Treatment Time*Treatment/noint;

repeated Time/ Subject=ID TYPE=unstructured;

lsmeans Time*Treatment/adjust=tukey pdiff=all alpha=0.05 cl;

run;

proc mixed data=WORK.IMPORT method=reml plots=(residualPanel studentPanel

influenceStatPanel)alpha=0.05;

class ID Treatment Time;

model R=Time Treatment Time*Treatment/noint;

repeated Time/ type= cs Subject=ID TYPE=unstructured;

lsmeans Time*Treatment/adjust=tukey pdiff=all alpha=0.05 cl;

run;

Thank you so much 

4 REPLIES 4
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

The first model looks OK.

The second model specifies type twice in the REPEATED statement, and you can only have one.

 

As a general rule, you should always (with few exceptions) include an intercept in a MODEL statement such as the one you are using.

 

Xi1
Calcite | Level 5 Xi1
Calcite | Level 5

Hello,

Thank you so much for your invaluable common. I fixed my code into this one.

proc mixed data=WORK.IMPORT covtest noclprint method=reml plots=(residualPanel studentPanel
influenceStatPanel)alpha=0.05;
class ID Treatment Time;
model R=Time Treatment Time*Treatment Pre/noint;
random intercept/ Subject=ID TYPE=vc;
lsmeans Time*Treatment/adjust=tukey pdiff=all alpha=0.05 cl;
run;

Does this one seems correct to you? is there a random effect on ID?

Deeply appreciated. 

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

This line

random intercept/ Subject=ID TYPE=vc;

incorporates ID as a random effects factor and produces an estimate of the variance among IDs (random intercepts) assuming that IDs are independent.

 

The general convention is to exclude "noint" from your MODEL statement, so that you have

model R=Time Treatment Time*Treatment Pre;

I do not know why you have included "noint" here. If you are using it to get means for each treatment, it would be better to use the LSMEANS statement.

 

I do not recommend the use of Tukey adjusted p-values for pairwise comparisons among interaction means for (at least) two reasons. One, the comparisons are adjusted for all possible pairwise comparisons. You are not usually interested in all of them, so the results are too conservative (the adjusted p-values are too small). Two, pairwise comparisons among interaction means do not do a good job of assessing the nature of interaction: interaction is comparisons of pairwise comparisons. I think it is preferable to develop hypotheses that make sense in the context of the study and to test those hypotheses with contrasts.

 

I'm guessing that Time is a repeated measure on each ID. Your current model assumes equal correlation among residuals regardless of how far apart in time they are (i.e., compound symmetry). You may be interested in exploring other covariance structures, such as AR(1), by using the REPEATED statement. Modelling covariance structure in the analysis of repeated measures data by Littell et al. provides a nice discussion of different covariance structures and how to implement them in Proc MIXED. SAS for Mixed Models: Introduction and Basic Applications by Stroup et al. is an invaluable resource for mixed models and their implementation in SAS software.

 

I hope this helps move you forward.

 

Xi1
Calcite | Level 5 Xi1
Calcite | Level 5
Thank you so much for your help.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1497 views
  • 1 like
  • 2 in conversation