BookmarkSubscribeRSS Feed
57078
Calcite | Level 5

Hi,

I have a 6 level categorical variable and want a linear trend for the hazard ratios.

Should the contrast statement have 5 levels ignoring the reference group?

Code:

proc phreg data=trcs ;

class rumol5A  /order=internal ;

model age*censor1(1) =rumol5A /rl;

contrast ' LINEAR EFFECT'   rumol5A -2 -1 0 1 2  /e;

run;

I've found online that these are the numbers to use for a linear effect for 5 coefficients but I can't find an easy explanation of why. Can someone confirm the above and provide an explanation?

Thanks in advance.

2 REPLIES 2
SteveDenham
Jade | Level 19

I think under the default parameterization (REF, with the reference level being the last level), your code looks right.  It excludes the last level.  However, that may not be what you want or need.  What values does rumol5A take on?  You may need to change the parameterization to get what you want.  I know if you used:

class rumol5A/order=internal param=GLM;

then the correct contrast would be:

contrast 'Linear effect' rumol5A -5 -3 -1 1 3 5 /e;

as the GLM parameterization requires all levels to be included.

As far as the coefficients, they provide a linear only contrast that has coefficients that sum to zero.  To derive them, take the ordinal values of the levels, find their mean, subtract the mean from the ordinal value, and convert all to integers by multiplying each by an appropriate constant.

Steve Denham

SeaMoon_168
Obsidian | Level 7

I am new to this contrast statement. Can you help me explain why the number should be  -5 -3 -1 1 3 5 not -4 -2 0 2 4? 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 3043 views
  • 0 likes
  • 3 in conversation