Dear community,
I would really like to know if the way I wrote my lsmestimates is correct. I'm combining the data of 2 experiments in a weighted analysis. I have 6 treatments applied at rate 1, 2, 3 and 4. So I want to compare trt 2 vs trt 3 at rate 1, and so on. In this case my dependent variable is the fresh shoot weight of watermelons.
Proc glimmix data=one;
class Exp Blk Trt Rate;
model Fshoot_weight= Trt|Rate/dist=lognormal ddfm=kr;
random intercept/subject=Blk;
weight Fshoot_weight_wt;
lsmestimate Trt*Rate 'Trt 2 vs 3 @ rate=1' 1 11 -11 1 1 1,
'Trt 2 vs 4 @ rate=1' 1 11 1 -11 1 1,
'Trt 2 vs 5 @ rate=1' 1 11 1 1 -11 1/adjust=t elsm ;
run;
I would greatly appreciate if you could check if these estimates statements make sense.
Thanks a lot!
Caroline
Look at the output table from the ELSM option (should be labelled "Least Squared Means Estimate Coefficients"). That table shows which lsmeans you are comparing in each contrast. The 1 and -1 in your contrast should line up with the lsmeans you want to compare.
Further help with CONTRAST and ESTIMATE statements can be found here
The test formed by the LSMESTIMATE statement is in the form KLB, where K is the matrix formed by the rows of your LSMESTIMATE coefficients. B is the parameter estimate vector that you can see by adding the SOLUTION option to the MODEL statement. Looking at the results of the ELSM option and the SOLUTION option shows you how your LSMESTIMATE coefficients line up with the elements of the parameter estimates vector and will tell you if you have the correct set of coefficients for your test.
It would be unusual to have 1's on the levels of the coefficients that you are not interested in. We usually see 0's there. Also unusual to see 11 and -11 on the levels you want to compare. We usually see 1 and -1 there. But that might have to do with the weighting you have for this data.
Thank you very much for your answer!
Since I have 2 factors (trt and rate) how do I write the estimates to compare trt 2 vs trt 3 at rate 1?
If I write them like this then I'm comparing trt 2 with 3, but what about the rate (I have 6 treatments in total and 4 rates)?
lsmestimate Trt*Rate 'Trt 2 vs 3 @ rate=1' 0 1 -1 0 0 0,
Thank you!
Look at the output table from the ELSM option (should be labelled "Least Squared Means Estimate Coefficients"). That table shows which lsmeans you are comparing in each contrast. The 1 and -1 in your contrast should line up with the lsmeans you want to compare.
Further help with CONTRAST and ESTIMATE statements can be found here
Hi StatsMan,
Thank you so much for your help, now I got it. I think it should look like this:
Proc glimmix data=one;
class Exp Blk Trt Rate;
model Fshoot_weight= Trt|Rate/dist=lognormal ddfm=kr solution;
random intercept/subject=Blk;
weight Fshoot_weight_wt;
lsmestimate Trt*Rate 'Trt 2 vs 3 @ rate=1' 0 0 0 0 1 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,
'Trt 2 vs 4 @ rate=1' 0 0 0 0 1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0,
'Trt 2 vs 5 @ rate=1'0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0/adjust=t elsm
Least Squares Means Estimate Coefficients | |||||
---|---|---|---|---|---|
Effect | Trt | RateA | Row1 | Row2 | Row3 |
Trt*RateA | 1 | 1 | |||
Trt*RateA | 1 | 2 | |||
Trt*RateA | 1 | 3 | |||
Trt*RateA | 1 | 4 | |||
Trt*RateA | 2 | 1 | 1 | 1 | 1 |
Trt*RateA | 2 | 2 | |||
Trt*RateA | 2 | 3 | |||
Trt*RateA | 2 | 4 | |||
Trt*RateA | 3 | 1 | -1 | ||
Trt*RateA | 3 | 2 | |||
Trt*RateA | 3 | 3 | |||
Trt*RateA | 3 | 4 | |||
Trt*RateA | 4 | 1 | -1 | ||
Trt*RateA | 4 | 2 | |||
Trt*RateA | 4 | 3 | |||
Trt*RateA | 4 | 4 | |||
Trt*RateA | 5 | 1 | -1 | ||
Trt*RateA | 5 | 2 | |||
Trt*RateA | 5 | 3 | |||
Trt*RateA | 5 | 4 | |||
Trt*RateA | 6 | 1 | |||
Trt*RateA | 6 | 2 | |||
Trt*RateA | 6 | 3 | |||
Trt*RateA | 6 | 4 |
One thing that would have made this clearer to me would have been to use some spaces in your various LSMESTIMATE statements. For instance:
lsmestimate Trt*Rate 'Trt 2 vs 3 @ rate=1' 0 0 0 0 1 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,
'Trt 2 vs 4 @ rate=1' 0 0 0 0 1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0,
'Trt 2 vs 5 @ rate=1' 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0/adjust=t elsm
This method is my preference - at least two spaces before the first coefficient, at least two spaces between levels, and some effort at aligning things vertically.
Or use the non-positional format.
SteveDenham
Very good idea Steve, thank you so much!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.