BookmarkSubscribeRSS Feed
wateas
Obsidian | Level 7

I'm attempting to code CONTRAST statements in GLIMMIX for a RCBD, factorial, repeated measures design.  There are two experimental treatments ("Treatment_1" and "Treatment_2"), two locations, and three time points (years).  Location and year need to be included as interactive.

proc glimmix data=df plots=studentpanel method=rspl;
    class Year_CAT Location Treatment_1 Treatment_2 Block ID_S_P;
    model Response_Var = Treatment_1 | Treatment_2 | Location | Year_CAT / ddfm=kr2;
	random Block(Location);
    random Year_CAT / residual type=un subject=ID_S_P;

/* This works. */ contrast "Overall impact: Treatment 1 (vs. Control)" /* Treatment 1 */ Treatment_1 0 0 0 0 1 1 -2 0; /* (10/14/25 Doesn't work. */ contrast "Site Impact (Location 1): Treatment 1 (vs. Control)" Location 1 0 Treatment_1 0 0 0 0 1 1 -2 0 Location * Treatment_1 0 0 0 0 1 1 -2 0 0 0 0 0 0 0 0 0 / e; run;

The second contrast (indicated to not work by the comment above it) appears to be inestimable.  I don't get a warning or error in the log, but no values are produced in the contrast table output (just periods in place of where F/p-values should be).  The coefficients as they appear in the table (procured from passing option "e" to the contrast statement) look as they should. 


Edit:  The reason I want an F-value from a contrast statement is because I want a single figure that represents treatment effect magnitude which I can use to compare across different response variables.  The response variables here are various measurement of soil properties, and having a sense of the degree to which different levels of "treatment 1" (e.g., compost or biochar) affects the different measurements of soil properties would be useful to me.    I can't use LSMESTIMATE for this purpose, because the response variables are all on different scales, and so effect magnitudes expressed in absolute terms don't work.

Based on the code above, is anything apparent that may be preventing the contrast from working?   Thank you for your time.

11 REPLIES 11
JackieJ_SAS
SAS Employee

Hi, Please post screen shots of your log and output to help us better understand your issue. Thanks.

wateas
Obsidian | Level 7

Here is the portion of the output showing the contrast table, with the results of the faulty contrast below the working one.  I can send other portions of the output if you want to see them for some reason.  To reiterate, there are no errors or warnings in the log upon executing the procedure.

20251014 - SAS Community Post - Contrast issue in GLIMMIX.png 

 

jiltao
SAS Super FREQ

I do not see Location and Treatment_1 in your CLASS statement. Is that what you intended?

If after making appropriate changes, you are still experiencing issues, send us the Class Level Information table and the E option output.

Thanks,

Jill

 

wateas
Obsidian | Level 7
Sorry - that was just a typo. Its corrected now. I have received no errors regarding variables not being in the class statement. Thanks.
jiltao
SAS Super FREQ

Then please provide the E option output. -- Jill

wateas
Obsidian | Level 7

Please see the attached PDF.  The coefficient table spans multiple pages.  Also, note that I've temporarily removed the random statement for the repeated measures so that the procedure executes faster.   Thanks for looking!

jiltao
SAS Super FREQ

Thank you for the information.

Does the following statement work for you --

contrast "Site Impact (Location 1): Treatment 1 (vs. Control)"
	    Location 2 0  Treatment_1 0 0 0 0 1 1 -2 0  Location * Treatment_1 0 0 0 0 1 1 -2 0   0 0 0 0 0 0 0 0 / e;

Thanks,

Jill

wateas
Obsidian | Level 7
I tried this, and unfortunately it does not fix the issue (I get the same output). I do appreciate the suggestion though.
StatDave
SAS Super FREQ

It's always best to avoid CONTRAST or ESTIMATE statements when the LSMEANS, SLICE, or LSMESTIMATE statement can be used. This avoids having to come up with appropriate and estimable coefficients needed in the former statements. The following statement will estimate and compare the means among the Location*Treatment1 combinations:

lsmeans location*treatment_1 / diff e;

As with your CONTRAST statements, the E option shows the coefficients that LSMEANS uses to compute each mean. While it's possible that some will be nonestimable, depending on your data structure, you could try options like OM and BYLEVEL to make changes to the coefficients. With the list of LS-means that are produced, if you want to make some comparison among sets of them, you could either use a SLICE statement or the LSMESTIMATE statement. For example, if you want the effect of treatment1 in each location:

slice location*treatment1 / sliceby=location;

For comparisons other than pairwise comparisons as done by the DIFF option in LSMEANS, you can use the LSMESTIMATE statement to much more simply compare, say, groups of LS-means than can be done with a CONSTRAST or ESTIMATE statement.

 

wateas
Obsidian | Level 7

[added to my original post] The reason I want an F-value from a contrast statement is because I want a single figure that represents treatment effect magnitude which I can use to compare across different response variables.  The response variables here are various measurement of soil properties, and having a sense of the degree to which different levels of "treatment 1" (e.g., compost or biochar) affects the different measurements of soil properties would be useful to me.    I can't use LSMESTIMATE for this purpose, because the response variables are all on different scales, and so effect magnitudes expressed in absolute terms don't work.

PaigeMiller
Diamond | Level 26

@wateas wrote:

[added to my original post] The reason I want an F-value from a contrast statement is because I want a single figure that represents treatment effect magnitude which I can use to compare across different response variables.  The response variables here are various measurement of soil properties, and having a sense of the degree to which different levels of "treatment 1" (e.g., compost or biochar) affects the different measurements of soil properties would be useful to me.    I can't use LSMESTIMATE for this purpose, because the response variables are all on different scales, and so effect magnitudes expressed in absolute terms don't work.


You run PROC GLIMMIX with the appropriate LSMEANS or LSMESTIMATE statement once for each response variable. LSMEANS or LSMESTIMATE replace the need to determine a working CONTRAST statement.

--
Paige Miller

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
  • 11 replies
  • 130 views
  • 2 likes
  • 5 in conversation