BookmarkSubscribeRSS Feed
vitaaquaticus
Fluorite | Level 6

I want to run a statistical model assessing the effects of light and herbivory on the length of plants (n = 53 observations). I developed one model with Site|Treatment as fixed effects (with Treatment containing both light and herbivory factors into one (-He = herbivores absent, +He = herbivores present, -Sh = unshaded, +Sh = shaded). Then, I tried a different model with Site|Light|Herbivory as fixed effects (splitting Treatment into two separate factors: light and herbivory). See the screenshot below.

 

Screen Shot 2022-02-13 at 12.24.08.png

Even though the models are coded a bit differently, I would imagine that LSMESTIMATE should arrive at the same least squares mean values for both models considering they will calculate the mean of the response variable based on the same contrasts. However, I keep getting drastically different results for these two with respect to magnitude and direction of the means, and p-value?

 

Treatment Model:

DATA WORK.MONTH89;

SET WORK.OR_LH_Under10_Index;

IF Month >= 8 THEN OUTPUT;

RUN;

 

ods graphics on;

PROC MIXED DATA = WORK.MONTH89 plots=all;;

CLASS Treatment Site Month Block;

MODEL'Change_Length'n = Site|Treatment /SOLUTION ddfm = KR CL ALPHA=0.05 INTERCEPT;

    RANDOM Block Month /CL ALPHA=0.05 TYPE=VC; 

LSMESTIMATE Site*Treatment

  'SH +He/-Sh x SH -He/-Sh'[1,2 2][-1,4 2],

  'SH +He/+Sh x SH -He/+Sh'[1,1 2][-1,3 2],

  'SH +He/-Sh x SH +He/+Sh'[1,2 2][-1,1 2],

  'SH -He/-Sh x SH -He/+Sh'[1,4 2][-1,3 2],

  'SH +He/-Sh x SH -He/+Sh'[1,2 2][-1,3 2],

 

  'CB +He/-Sh x CB -He/-Sh'[1,2 1][-1,4 1],

  'CB +He/+Sh x CB -He/+Sh'[1,1 1][-1,3 1],

  'CB +He/-Sh x CB +He/+Sh'[1,2 1][-1,1 1],

  'CB -He/-Sh x CB -He/+Sh'[1,4 1][-1,3 1],

  'CB +He/-Sh x CB -He/+Sh'[1,2 1][-1,3 1]

  / CL Alpha=0.05;

LSMESTIMATE Site

  'SH x CB'[1,2][-1,1]

  / CL Alpha=0.05;

RUN;

ods graphics off;

Light/Herbivory Model:

DATA WORK.MONTH89;

SET WORK.OR_LH_Under10_Index;

IF Month >= 8 THEN OUTPUT;

RUN;

 

ods graphics on;

PROC MIXED DATA = WORK.MONTH89 plots=all;

CLASS Light Herbivory Month Block Site;

MODEL 'Change_Length'n = Site|Light|Herbivory /SOLUTION ddfm = KR CL ALPHA=0.05 INTERCEPT;

    RANDOM Block Month /CL ALPHA=0.05 TYPE=VC; 

LSMESTIMATE Site*Light*Herbivory

  'Herbivory: SH Unshaded Present x Unshaded Absent'[1,2 2 2][-1,2 2 1],

  'Herbivory: SH Shaded Present x Shaded Absent'[1,2 1 2][-1,2 1 1],

  'Light: SH Unshaded Present x Shaded Present'[1,2 2 2][-1,2 1 2],

  'Light: SH Unshaded Absent x Shaded Absent'[1,2 2 1][-1,2 1 1],

  'H x L: SH Shaded Present x Unshaded Absent'[1,2 1 2][-1,2 2 1],

  'Herbivory: CB Unshaded Present x Unshaded Absent'[1,1 2 2][-1,1 2 1],

  'Herbivory: CB Shaded Present x Shaded Absent'[1,1 1 2][-1,1 1 1],

  'Light: CB Unshaded Present x Shaded Present'[1,1 2 2][-1,1 1 2],

  'Light: CB Unshaded Absent x Shaded Absent'[1,1 2 1][-1,1 1 1],

  'H x L: CB Unshaded Present x Shaded Absent'[1,1 2 2][-1,1 1 1]

  / CL Alpha=0.05;

RUN;

ods graphics off;

I am not sure if this is a content question or a programming question. I am hoping someone can help me understand what is happening behind the scenes.

5 REPLIES 5
PaigeMiller
Diamond | Level 26

I don't think the you should get the exact same LSMEANSESTIMATES from different models.

 

You should use the E option of the LSMESTIMATES statement to print out the L Matrix and take a look at that.

 

But since I don't have your data, I can't dig into this.

--
Paige Miller
vitaaquaticus
Fluorite | Level 6

I am not sure how to read the E option results, especially with the row numbers. I have included data in the original post if you want to sleuth a bit more and help me figure this out.

Screen Shot 2022-02-13 at 16.28.38.png

PaigeMiller
Diamond | Level 26

The proper way to provide data is via SAS data step code (instructions)


I think we would need to see the table of E options for both models.

--
Paige Miller
vitaaquaticus
Fluorite | Level 6

I am a new-ish SAS user and I tried following the instructions you linked. I ran the first three sections and I got several error messages such as "SELECT" statement is not valid. The instructions are a bit overwhelming for me and I am unclear on how to properly provide data. I am sorry for my ineptitude.

 

Option E for Treatment Model:

Screen Shot 2022-02-13 at 17.16.41.png

Option E for Light/Herbivory Model:

Screen Shot 2022-02-13 at 17.15.50.png

PaigeMiller
Diamond | Level 26

Here's an alternative plan:

 

Compute the LSMEANS for these two models. Compare them for terms in both models. If they are not the same, then you would not expect the LSMESTIMATE to be the same either.

 

Also, when you can't get something to work, be specific. Show us what you tried. Provide details. Ask questions. Don't say "I couldn't get it to work" and then stop there.

--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 737 views
  • 0 likes
  • 2 in conversation