I have a linear mixed effect model for a repeated measure data with both predictor (3 levels) and time (4 levels) as categorical variables. There was a predictor-time interaction in the model, but I took it out because it is not significant. I want to get the model estimated outcome by predictor. Here is my code:
PROC MIXED DATA = df covtest METHOD=REML PLOTS(MAXPOINTS=NONE)=(ResidualPanel());
CLASS expo time;
MODEL outcome = expo time /solution CHISQ DDFM=KenwardRoger RESIDUAL;
REPEATED time / subject = pid Type = CS R RCorr;
LSMEANS expo/ CL;
RUN;
1) Are the LSMEANS I got from above code the average predicted outcome across all time points by predictor? I am not sure what is the default value LSEMANS using for categorical variables.
2) I know that I can calculate LSMEANS for each combination of predictor and time if I add "expo*time" to the MODEL statement. But since I don't want to keep the interaction term in the model, how can I calculate predicted outcome at each time point by my predictor?
Yes the LSMEANS are computed averaging over other classification effects in the model. You can use the E option in the LSMEANS statement to see exactly how the LSMEANS are computed.
No, without the interaction term, you will not be able to get the lsmeans for EXPO at each value of TIME with the LSMEANS statement. But you can use the ESTIMATE statement. For example, suppose EXPO has 2 levels and TIME has 4 levels, then you can use the following ESTIMATE statement in your PROC MIXED program --
estimate 'average of EXPO for time=1' int 1 expo 0.5 0.5 time 1 0 0 0;
estimate 'average of EXPO for time=2' int 1 expo 0.5 0.5 time 0 1 0 0;
estimate 'average of EXPO for time=3' int 1 expo 0.5 0.5 time 0 0 1 0;
estimate 'average of EXPO for time=4' int 1 expo 0.5 0.5 time 0 0 0 1;
Hope this helps,
Jill
@kivanvan wrote:
1) Are the LSMEANS I got from above code the average predicted outcome across all time points by predictor? I am not sure what is the default value LSEMANS using for categorical variables.
In the case where your data is perfectly balanced, equal number of observations in each cell of the experiment, the LSMEANS are the arithmetic average. If the experiment is not balanced, then the LSMEANS are adjusted for this imbalance, and no longer equal the arithmetic average, but are better representations of the mean for each level of your class variables.
2) I know that I can calculate LSMEANS for each combination of predictor and time if I add "expo*time" to the MODEL statement. But since I don't want to keep the interaction term in the model, how can I calculate predicted outcome at each time point by my predictor?
The LSMEANS statement in PROC MIXED should give predicted values even without the interaction.
Yes the LSMEANS are computed averaging over other classification effects in the model. You can use the E option in the LSMEANS statement to see exactly how the LSMEANS are computed.
No, without the interaction term, you will not be able to get the lsmeans for EXPO at each value of TIME with the LSMEANS statement. But you can use the ESTIMATE statement. For example, suppose EXPO has 2 levels and TIME has 4 levels, then you can use the following ESTIMATE statement in your PROC MIXED program --
estimate 'average of EXPO for time=1' int 1 expo 0.5 0.5 time 1 0 0 0;
estimate 'average of EXPO for time=2' int 1 expo 0.5 0.5 time 0 1 0 0;
estimate 'average of EXPO for time=3' int 1 expo 0.5 0.5 time 0 0 1 0;
estimate 'average of EXPO for time=4' int 1 expo 0.5 0.5 time 0 0 0 1;
Hope this helps,
Jill
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.