BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Haris
Lapis Lazuli | Level 10

Is there a way to switch the default dummy-coding of CLASS variables to effect-coding in PROC GLIMMIX?

 

My goal is to obtain tests for each level of a fixed class variable against sample average in PROC GLIMMIX.  In PROC LOGISTIC the CLASS statement has an option ‘PARAM=EFFECT’ to accomplish this.  There does not seem to be an equivalent for that in PROC GLIMMIX.  Am I missing something?

 

If I can't change the way a CLASS variable is parameterized by GLIMMIX, what would you recommend for me to achieve my goal? I know I could manually effect-code each level of my class variable in the source dataset and enter all of those effect-coded variables into the model.  I can also use a series of ESTIMATE statements to compute the desired targets by using dummy-code default.  Trouble is that my class variable has over 400 levels and both of the options above require a whole lot of coding. I have hard time believing that SAS took away PARAM=EFFECT option without an easy alternative.

 

Do you have any other suggestions?

 

Thanks,

Haris

1 ACCEPTED SOLUTION

Accepted Solutions
Haris
Lapis Lazuli | Level 10
SAS Tech Support came through rapidly: DIFF=ANOM option in the LSMEANS statement in PROC GLIMMIX is exactly what I was looking for.

View solution in original post

4 REPLIES 4
Haris
Lapis Lazuli | Level 10
SAS Tech Support came through rapidly: DIFF=ANOM option in the LSMEANS statement in PROC GLIMMIX is exactly what I was looking for.
maleien
Calcite | Level 5

Haris, Since you figured it out, maybe you can help me? I added a "lsmeans var / diff=anom" line to my proc glimmix code and all that did was lines to my output populated with . (missing values) for the main effects. Interestingly, they are the inverse in direction, but the same in magnitude as the original output without the lsmeans var / diff=anom line. 

 

I have to conduct these follow up tests for two separate analyses. In one the two model variables are categorical with two levels each and their interaction. In a second, I have a two categorical variables with 2 levels each, a linear variable, the quadratic of that linear variable, and all the higher-order interactions. 

 

Any help would be much appreciated.

RobertF
Obsidian | Level 7

I would recommend manually coding your categorical variables if you want to use effect coding.

 

For example, if you have a categorical variable called hospital with values of "Hospital A", "Hospital B", and "Hospital C", rather than entering hospital into proc glimmix in the class statement, instead create two new variables, "Hospital_A" and "Hospital_B" (Hospital C is arbitrarily designated the reference group).

 

If hospital = "Hospital A",  then Hospital_A = 1, hospital = "Hospital B",  then Hospital_A = 0, and if hospital = "Hospital C", then Hospital_A = -1. Use the same logic for the Hospital_B variable.

 

Manual coding allows you to choose which category to use as a reference and directly find the effect code coefficients in the Solutions for Fixed Effects output (use the "solution" option in the model statement). I would also use manual coding when using weighted effect coding, when there are an unequal number of observations across categories.

Haris
Lapis Lazuli | Level 10

RobertF,

 

Manual coding is nice if you have a reasonable number of categories.  My categorical variable is approaching 500 levels.

 

Another nice thing about DIFF=ANOM is that it gives you effects for each level of the predictor without the need to re-run the model with a different reference category to obtain the delta for that level.

sas-innovate-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

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
  • 4 replies
  • 2583 views
  • 2 likes
  • 3 in conversation