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 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?

1 ACCEPTED SOLUTION

Accepted Solutions
jiltao
SAS Super FREQ

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

 

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
kivanvan
Obsidian | Level 7
Thanks for your reply! It is helpful to know how LSMEANS are calculated for the imbalanced data, which it is in my case.
Regarding the LSMEANS without interaction term, I tried it and got an error:" ERROR: Effects used in the LSMEANS statement must have appeared previously in the MODEL statement." So I don't think it is feasible through LSMEANS if I take out the interaction from the model.
jiltao
SAS Super FREQ

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
Obsidian | Level 7
Thank you for your help! The E option works great for me.

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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
  • 1435 views
  • 1 like
  • 3 in conversation