New Contributor
Posts: 2

# Longitudinal mixed models - lsmeans for a fixed effect with continuous time

I am running a mixed effects longitudinal model with linear and quadratic time effects and a continuous outcome. I have a covariate that has a significant interaction with time-squared, so obviously the linear interaction and its main effect are left in the model. When interactions are in the model you cannot directly interpret lower order terms. I have centered time at the study mid point and would like to know if there are significant differences between the two levels of this covariate either on average or at the mid-point. When I include the code: lsmeans sex/ diff = control ('0'') ; does this give me the difference between males and females on average or at the time intercept, or neither? (time is continuous so I cannot include the interaction).

Any help would be greatly appreciated!

Megan

Posts: 2,655

## Longitudinal mixed models - lsmeans for a fixed effect with continuous time

I'm a bit confused here, because I come from a tradition that would consider sex as a fixed effect, and time and time-squared as covariates.  The LSMEANS statement that you present would compare males to females at the average time AND at the average time-squared, and it may be the case that average time-squared does not equal (average time)*(average time), due to imbalance in data.  Check the use of the AT= option in the LSMEANS statement.  This may help clarify your thoughts.

And don't think for a moment that you cannot include the interaction--it would simply mean differing slopes for the sexes.

Steve Denham

SAS Employee
Posts: 31

## Longitudinal mixed models - lsmeans for a fixed effect with continuous time

I agree with Steve’s points. Here is another SAS statement that you may find helpful to visualize the interaction effect of continuous variable and a class variable in your model. If your response variable is continuous, the EFFECTPLOT statement with the SLICEFIT option will give you a curve of predicted values versus a continuous variable (x=), grouped by the levels of a CLASS effec (sliceby=).

The EFFECTPOT statement is not supported with the MIXED procedure; however you can obtain the display by using the PLM procedure. Here is a simple example that shows how the PLM procedure works:

proc mixed data=bp;

class trt person;

model sbp = trt visit trt*visit trt*visit2;

random int /sub=person;

store sasuser.StudyResults;

run;

The STORE statement in the MIXED procedure saves the model information as a SAS item store.

proc plm restore=sasuser.StudyResults;

effectplot slicefit (x=visit sliceby=trt);

run;

The PLM procedure takes the item store and performs post fitting analysis with the EFFECTPLOT statement.

Funda

New Contributor
Posts: 2

## Longitudinal mixed models - lsmeans for a fixed effect with continuous time

Thanks to you both. Just to clarify, I have tested and included interactions with time and time2 where appropriate. The lsmeans does not let me test an interaction between time (continuous) and sex for example. I will explore the AT = option in lsmeans. This procedure that Funda has indicated is intriguing. Currently, my version of SAS (9.2) does not recognize the command 'store' or the plm procedure. Where can I download a patch or is there something I need to set in SAS to allow these statements to run?

Thanks again~

Megan

SAS Employee
Posts: 31

## Longitudinal mixed models - lsmeans for a fixed effect with continuous time

The PLM procedure (and the STORE statement in many procedures that fit linear models) is included in SAS/STAT 9.22. This release was coupled with the third maintenance release of SAS 9.2, SAS 9.2 (TS2M3).

Discussion stats
• 4 replies
• 418 views
• 0 likes
• 3 in conversation