BookmarkSubscribeRSS Feed
mthorne
Obsidian | Level 7

I have a 3-way factorial with a 3-way interaction between YEAR, LOCATION, and TREATMENT. If I use SliceDiff to compare simple effect TREATMENT lsmeans at each level of YEAR at each LOCATION, does that preclude me from comparing certain simple effect TREATMENT lsmeans between certain YEARs? In other words, the interaction graphically indicates that treatments differ at each year, but  also between years. I am not trying to look at every simple effect combination and risk a Type I error, just comparisons between the ones that help explain the interaction. The old GLM approach as I recall would have been to only analyze one factor at each level of the other factor, but this limits telling the whole story.  Can I specify LSMEANS YEAR|LOCATION|TREATMENT / SLICEDIFF = LOCATION*YEAR and also do a second run with SLICEDIFF=LOCATION*TREATMENT and not violate any of the rules?

1 REPLY 1
StatDave
SAS Super FREQ

Since you use the SLICEDIFF= option in the LSMEANS statement, I assume that you are using PROC GLIMMIX to fit your model since this option isn't in the LSMEANS statement in other procedures. Regardless, I don't see a problem with you using the statements you propose as long as they are preplanned comparisons of interest. The first LSMEANS statement you show provides comparisons of the treatments in each combination of YEAR and LOCATION. If you are concerned about the multiple comparisons it provides, you could add the ADJUST= option to apply a suitable multiple comparison method. Or you could save the p-values from the multiple tests (using an ODS OUTPUT statement) and use one of the multiple comparison adjustments available in PROC MULTTEST.

 

However, if what you want is a single test of the treatment difference across the YEAR and LOCATION combinations, you could specify:

lsmeans treatment / ilink diff e; 

I don't know what your response distribution is, so the ILINK option gives the individual treatment means for that distribution. The DIFF option compares the treatments averaged over a balanced distribution of YEAR and LOCATION levels as shown by the E option. Since the LSMEANS statement simply estimates linear combinations of the model parameters, it is always advisable to use the E option to see how each estimate is calculated. If you are not comfortable with a balanced distribution given the nature of your data, you can consider using the OM option to change it.

 

But another option is to simply treat all observations as being in one of the treatments and compute their predicted means, and then do the same treating all observations as being in another treatment and comparing the averages of those two sets of predicted values. The YEAR and LOCATION values are not restricted in this as they are using LSMEANS. Those are the predictive margins for treatment. This can be done using the Margins macro. For example, the following fits the 3-way interaction model (using PROC GENMOD), computes the predictive margins for treatment and provides a test comparing them.

%margins(data=your_data, class=year location treatment, response=y,
     model=year|location|treatment, margins=treatment, diff=all)

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 169 views
  • 2 likes
  • 2 in conversation