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

Suppose have 3 Treatment Group, Placebo (1), Group A with Dose 10mg, Group B with Dose 20mg.

Study duration: Baseline (Day 1), Week 4, Week 8, Week 12. 

Goal: 1) compare the change from baseline across visits among treatments separately 2) compare the change from baseline across different visits among (placebo) VS. (combined Group A & B)

 

When using PROC MIXED model, "lsmeans" can provide result of Goal (1), "estimate" can provide (2); however, I am not very sure how to use "estimate" or "lsmestimate" or "contrast" to get Goal (2)

 

proc mixed data= long;
  class treatment visit;
  model CHG =  Treatment*visit;
  repeated visit / subject=id type=UN ;
  estimate 'placebo vs pool' treatment 1 -0.5 -0.5; 
  lsmeans treatment*visit/ slice=visit; /*differences in exertype for each time point*/
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
StatsMan
SAS Super FREQ

In the absence of real data, simulated data can come in handy. The code below simulates data that looks like the situation you have and runs a mixed model similar to yours. 

 

data test;
call streaminit(56340);
do id=1 to 100;
trt=ceil(rand("uniform")*3);
base=rand("uniform");
do time=1 to 3;
y=trt*time*rand("uniform")-base;
output;
end; end;
run;

proc mixed data=test;
class trt time;
model y=trt time trt*time;
repeated time / subject=id type=un;
lsmeans trt*time / slice=time;
lsmestimate trt*time 1 -.5 -.5 / e;
run;

 

The LSMESTIMATE statement above is our first attempt at comparing the result of the placebo (treatment 1) to the pooled result of the two active treatments (treatments 2 and 3) at time point 1. The /e option will help us see if we got the coefficients right:

 

StatsMan_0-1606221810681.png

Looking at the results of the /e option, it appears that we did not set up the coefficients correctly. The comparison here is within the first level of treatment, comparing the result at time 1 to the pooled result at times 2 and 3. That is not what we had in mind. Let's change the coefficients on the LSMESTIMATE statement:

 


proc mixed data=test;
class trt time;
model y=trt time trt*time;
repeated time / subject=id type=un;
lsmeans trt*time / slice=time;
lsmestimate trt*time 1 0 0 -.5 0 0 -.5 0 0 / e;
run;

 

Now the /e option shows which paramters we are combining:

 

StatsMan_1-1606222057330.png

Now we can see that we have a 1 next to the lsmean for trt 1 and time 1, and -.5 next to the lsmeans for trt 2, time 1 and trt 3, time 1. These coefficients line up with the comparison we want, comparing trt 1 to the pooled result of trt 2 and 3 at time point 1.

 

You can verify the result algebraically too. If you look at the output of the LSMEANS table:

StatsMan_2-1606222284694.png

We wish to compare the lsmean for trt 1 at time 1 to the pooled result of trt 2 and trt 3 at time 1. That would be .04008 - (.7140+1.3651)/2 = -.9995, the result we get from the LSMESTIMATE statement. 

 

View solution in original post

5 REPLIES 5
SteveDenham
Jade | Level 19

We'll need some clarification.  It seems you have an ESTIMATE statement that gives you an answer to your Goal(2), so I suspect you want something more.  Is that a comparison of placebo vs. pooled treatments at each time point?  That would require knowing how many timepoints, but otherwise is a perfect case for using an LSMESTIMATE statement.

 

SteveDenham

yw2757
Fluorite | Level 6

" Is that a comparison of placebo vs. pooled treatments at each time point?" is the questions I wish to ask how to use "lsmestimate"

Confused how to set the coefficients  

StatsMan
SAS Super FREQ

In the absence of real data, simulated data can come in handy. The code below simulates data that looks like the situation you have and runs a mixed model similar to yours. 

 

data test;
call streaminit(56340);
do id=1 to 100;
trt=ceil(rand("uniform")*3);
base=rand("uniform");
do time=1 to 3;
y=trt*time*rand("uniform")-base;
output;
end; end;
run;

proc mixed data=test;
class trt time;
model y=trt time trt*time;
repeated time / subject=id type=un;
lsmeans trt*time / slice=time;
lsmestimate trt*time 1 -.5 -.5 / e;
run;

 

The LSMESTIMATE statement above is our first attempt at comparing the result of the placebo (treatment 1) to the pooled result of the two active treatments (treatments 2 and 3) at time point 1. The /e option will help us see if we got the coefficients right:

 

StatsMan_0-1606221810681.png

Looking at the results of the /e option, it appears that we did not set up the coefficients correctly. The comparison here is within the first level of treatment, comparing the result at time 1 to the pooled result at times 2 and 3. That is not what we had in mind. Let's change the coefficients on the LSMESTIMATE statement:

 


proc mixed data=test;
class trt time;
model y=trt time trt*time;
repeated time / subject=id type=un;
lsmeans trt*time / slice=time;
lsmestimate trt*time 1 0 0 -.5 0 0 -.5 0 0 / e;
run;

 

Now the /e option shows which paramters we are combining:

 

StatsMan_1-1606222057330.png

Now we can see that we have a 1 next to the lsmean for trt 1 and time 1, and -.5 next to the lsmeans for trt 2, time 1 and trt 3, time 1. These coefficients line up with the comparison we want, comparing trt 1 to the pooled result of trt 2 and 3 at time point 1.

 

You can verify the result algebraically too. If you look at the output of the LSMEANS table:

StatsMan_2-1606222284694.png

We wish to compare the lsmean for trt 1 at time 1 to the pooled result of trt 2 and trt 3 at time 1. That would be .04008 - (.7140+1.3651)/2 = -.9995, the result we get from the LSMESTIMATE statement. 

 

yw2757
Fluorite | Level 6

This is really helpful and exactly I am looking for.

Really appreciate!

StatsMan
SAS Super FREQ

Adding the /e option to your LSMEANS statement is always a good idea when you are unsure of the hypothesis you are testing with your ESTIMATE (or CONTRAST) statement. The hypothesis tested by LSMEANS is a test of a linear combination of the paramter estimates in the model, achieved by the vector multiplication of two vectors L*B. B is the vector of the paramter estimates (which you can see by adding the /s option to the MODEL statement). L is the vector of coefficients as specified on the ESTIMATE statement (seen by adding that /e option). 

 

This  https://support.sas.com/kb/24/447.html gives lots of examples of writing contrasts and estimates. 

 

Many estimates are more easily constructed if you take a linear combination of the LSMEANS, instead of the model parameters. As @SteveDenham pointed out, that can be achieved through the LSMESTIMATE statement.

 

 

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
  • 5 replies
  • 2314 views
  • 3 likes
  • 3 in conversation