BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
jesseh
Calcite | Level 5

I am doing an analysis using a mixed model (PROC MIXED) on longitudinal data, wherein I'm running the model for different bootstraps/imputation combinations using a BY statement. Getting the LSMEANS from each is easy, and I can estimate the model mean AT any visit for all different values of my BY variables (bootstrap/imputation combo). SAS automatically plugs in the means of the other covariates BY the variables I have given to create different LSMEANS each time. 

 

However, one estimate of interest is the mean OVER the first six visits. For a single analysis, I have previously used an ESTIMATE statement as shown in the code below, giving equal weight over the first six visits. To produce the mean, this ESTIMATE statement needs average values of my two continuous covariates (var1 and var2) explicitly plugged in, which here are assumed to be calculated previously and stored as macro variables &mvar1 and &mvar2; it is not automatically done like in LSMEANS.

 

How can I most efficiently run the model over my BY variables (bootstrap sample/imputation combinations) using the mean of var1 and var2 for the specific bootstrap sample/imputation each time, the same way LSMEANS does automatically with the BY statement?

 

proc mixed data=mydata method = reml;   
   by bootn imputen;                                                
   class subj trt visit;   
   model chg = trt|visit var1 var2   / ddfm=bw solution;
   repeated visit / type=un subject=subj;
   lsmeans trt|visit/ pdiff=all cl;
	          
  estimate 'TRT 1 Over First 6 visits'
       intercept 1   
       var1 &mvar1
       covar3 &mvar2
       visit 0.166666 0.166666 0.1666666 0.166666 0.166666 0.166666 0 0 0 0
       trt 1 0 0 0
       trt*visit 0.1666666 0.166666 0.166666 0.166666 0.166666 0.166666 0 0 0 0           0 0 0 0 0 0 0 0 0 0          0 0 0 0 0 0 0 0 0 0          0 0 0 0 0 0 0 0 0 0    /CL;  

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SteveDenham
Jade | Level 19

That is close, @Ksharp . All that needs done is to add in the continuous covariates using the AT option.

 

lsmestimate trt*visit 'Trt 1 mean OVER the first six visits' 1 1 1 1 1 1 0 0 0 0   0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0/ divisor=6 cl AT MEANS ;

I added in the zeroes for the coefficients of the other lsmeans used in the LSMESTIMATE. That should make it easier if you have other treatment means or differences to estimate. The key here is the AT MEANS which applies the covariate adjustment using the mean of each continuous covariate in the model. Since this is being processed by bootstrap - imputation combination, each will be fit with different mean values. If you want the means over all bootstrap-imputation combinations, create the macro variable for each and change the AT MEANS to AT var1=&meanoverallvar1 covar3=&meanoverallvar2.

 

SteveDenham

 

View solution in original post

3 REPLIES 3
Ksharp
Super User
I am not sure . You could try LSMESTIMATE statement which like LSMEANS and no need to consider other two continuous covariates (var1 and var2) . would handle by LSMESTIMATE itself .
LIke:

lsmestimate trt*visit ' mean OVER the first six visits' 1 1 1 1 1 1 / divisor=6 cl ;

But @StatDave @SteveDenham @lvm could give you right code.
SteveDenham
Jade | Level 19

That is close, @Ksharp . All that needs done is to add in the continuous covariates using the AT option.

 

lsmestimate trt*visit 'Trt 1 mean OVER the first six visits' 1 1 1 1 1 1 0 0 0 0   0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0/ divisor=6 cl AT MEANS ;

I added in the zeroes for the coefficients of the other lsmeans used in the LSMESTIMATE. That should make it easier if you have other treatment means or differences to estimate. The key here is the AT MEANS which applies the covariate adjustment using the mean of each continuous covariate in the model. Since this is being processed by bootstrap - imputation combination, each will be fit with different mean values. If you want the means over all bootstrap-imputation combinations, create the macro variable for each and change the AT MEANS to AT var1=&meanoverallvar1 covar3=&meanoverallvar2.

 

SteveDenham

 

jesseh
Calcite | Level 5

This is perfect, thank you. I have used lsmestimate before, but it slipped my mind to use it in this way.

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
  • 3 replies
  • 559 views
  • 2 likes
  • 3 in conversation