Programming the statistical procedures from SAS

Contrasts Statement

Reply
Super Contributor
Posts: 256

Contrasts Statement

[ Edited ]

I'm trying to figure out how the Contrasts statement works

 

I'm running a simple glm on a single factor (glm31_cover_type)

 

I want to test whether each of the parameter estimates is independent from the other levels of the factor cover type. I've read a few articles on this but it seems quite complicated. I thought there would just be a statement that would produce something like the attachment.

 

How would I adjust my code below so that I get something like the attached? So, for each level of the factor I want to get the standard error of the parameter differences. There are 5 levels so 5+4+3+2+1 = 15 standard errors.

 

 Specifically I'm confused by the "contrast label factor 1 -1" code. How do I change this to incororate a test of all parameter differences in the factor.  

 

 

proc genmod data=insurancedata;

class glm31_cover_type(ref="COMP");

Weight NbClaims;

model AvgClaim = glm31_cover_type/ dist=gamma link=log obstats SCALE=DEVIANCE CORRB;

contrast 'Label1' glm31_cover_type 1 -1 ;

ods output ParameterEstimates =myObStats CORRB = CorrMatrix Contrasts = TestOfContrasts;

run;

Attachment
Respected Advisor
Posts: 3,773

Re: Contrasts Statement

I think you will find the LSMEANS effect(s) / diff; statement is more suited to the task of all differences.

Super Contributor
Posts: 256

Re: Contrasts Statement

Will that give you an estimate of the significance of the difference for each of the 15 combinations above? I'm interested in the individual differences rather than an overall. If you open the attachment in my last post you will see what I'm after. It just allows me to group levels that are similar. For example looking at the effect of cover type on claim frequency I might group "adft" and "comp" together as there is no statistically significant difference in their parameter estimates.
Respected Advisor
Posts: 3,773

Re: Contrasts Statement

LSMEANS will give you pair-wise differences.  Use the LSMESTIMATE to do what you are asking about where you take the mean of 1 or more levels and compare to mean 1 or more other levels.

 

It might look something like 

 

LSMESTIMATE effect -.5 -.5 .33333 .33333 .33333;

 

To compare the mean of levels 1+2 with mean of levels 3+4+5;  You may want more decimal places or use divisor option.

 

lsmestimate effect -3 -3 2 2 2 / divisor=6;

 

Ask a Question
Discussion stats
  • 3 replies
  • 246 views
  • 1 like
  • 2 in conversation