BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kivanvan
Obsidian | Level 7

I have a data set from a repeated measure design (4 repeated measures). I used PROC MIXED with the REPEATED statement for the effect of my main predictor (categorical) on the outcome (continuous). The time variable is set as a categorical variable. Now I want to assess the model assumption by plotting the residual vs. fitted value at both level-1 and level-2, but I am not sure how to get the level-2 residuals and fitted values. 

I used outp= in the model statement to get residuals and predicted values, but I think they're on level 1. Is level-2 residuals and predicted values the average of all time points for each subject?

Here is my code for the model:

PROC MIXED DATA = df covtest METHOD=REML PLOTS(MAXPOINTS=NONE)=(ResidualPanel());
 CLASS pid FOLLOWUP2(REF="0") PREDICTOR(REF = FIRST);
 MODEL OUTCOME= PREDICTOR FOLLOWUP2 PREDICTOR*FOLLOWUP2 /solution CHISQ  DDFM=KenwardRoger RESIDUAL outp=temp;
 REPEATED FOLLOWUP2 / subject = pid Type = CS R RCorr;
RUN;

pid is the participant ID. Follwoup2 is my time variable.

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
StatsMan
SAS Super FREQ

I think you will need to fit PID as a random effect to get your level-1 and level-2 residuals. Use a RANDOM statement like

 

random int / subject=pid solution;

 

and remove your REPEATED statement. The OUTP= data set will contain the level-2 residuals if you keep the RESIDUAL option on the MODEL statement. The ODS output table SOLUTIONR will contain the level-1 residuals. 

View solution in original post

4 REPLIES 4
StatsMan
SAS Super FREQ

I think you will need to fit PID as a random effect to get your level-1 and level-2 residuals. Use a RANDOM statement like

 

random int / subject=pid solution;

 

and remove your REPEATED statement. The OUTP= data set will contain the level-2 residuals if you keep the RESIDUAL option on the MODEL statement. The ODS output table SOLUTIONR will contain the level-1 residuals. 

kivanvan
Obsidian | Level 7

Thanks for your reply. I tried your suggestion, and got fewer data in the output data set of SOLUTIONR, which equals to the number of subjects in my data. So I think this is for level 2 and the output from OUTP is for level 1?

I also looked at the variables in the output of SOLUTIONR. It looks like that the variable Estimate is the predicted level-2 intercept. Do I need to do some calculations to get the residual?

StatsMan
SAS Super FREQ

The values in the ESTIMATE variable are the random adjustment to the intercept of the model for each subject. Most consider those values to be the residuals you are looking for. If you look at OUTP= and OUTPM=, the difference in the predicted values of the two data sets is the inclusion of these residuals in the calculated prediction in OUTP=. The predicted means in OUTPM= do not contain these residual values. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 784 views
  • 2 likes
  • 2 in conversation