I have a categorical predictor that has 5 groups in it. I want to create contrasts necessary to test for significance of differences between each pair of slopes and then use the Bonferroni adjustment to preserve the overall alpha for the simultaneous tests of slopes and draw a conclusion about the regression slopes.
In case of a predictor with 3 groups, the SAS code would look like:
ods select SolutionF Contrasts;
contrast 'A vs B' pos*pts 1 -1 0;
contrast 'A vs C' pos*pts 1 0 -1;
contrast 'B vs C' pos*pts 0 1 -1;
.. How to work in case of 5 groups ?
Thank you for the additional information. You've made an excellent start.
The INPUT statement in your DATA step is probably wrong: it specifies a as a categorical variable ("a $"), and it is missing x. Perhaps you mean it to be
input x $ a b c d e;
The ESTIMATE statement in the GLIMMIX (but not the MIXED) procedure has an ADJUST option that will work for what you want:
Try something like
proc glimmix data=hye;
class x;
model = x a*x b c d e / noint solution;
estimate 'x1 vs x2' a*x 1 -1 0 0 0,
'x1 vs x3' a*x 1 0 -1 0 0,
/* add the other 7 comparisons */
'x4 vs x5' a*x 0 0 0 1 -1
/ adjust=bon stepdown adjdfe=row;
run;
Note the change I've made in the MODEL statement: I added e, and replaced a with x; if the effect of the change is not obvious to you, run the model without b, c, d, and e to see how the model is parameterized with respect to a and x.
Note, too, that for your equation to match the code above, there will be no intercept (const), there will be no "a*beta1", and "beta6" (and "beta7") will actually be 5 parameters, one for each level of x.
By default, the estimates will be computed at b=c=d=e=0. Because there are no interactions involving these factors in the model, the estimates that you want will not be affected by the values of b, c, d, and e.
I have not run this code, and so I don't guarantee it will work, it might need tweaking (and I'm not sure about your data input).
Please provide more detail. See the posting guidelines here:
and here
http://support.sas.com/resources/papers/proceedings12/189-2012.pdf
In particular, post the full code for the statistical model, and show what you've tried so far.
Thank you for correcting my rookie mistake, I'll be elaborate henceforth. My dataset consists of response(R) and predictors(a,b,c,d,e) + a categorical predictor(x, which has five groups x1,x2,x3,x4,x5).
My regression model is R = const+a(beta1)+b(beta2)+c(beta3)+d(beta4)+e(beta5)+x(beta6)+a*x*(beta7)
I want to test for significance of differences between each pair of slopes corresponding to a*x1, a*x2,a*x3, a*x4,a*x5. We will have 10 such pairs ( 5C2).
Here's the SAS code that produces a reparametrized model and gives the solutions table for the intercepts and slopes
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
data hye;
input a $ b c d e;
datalines;
/*data goes here*/
;
proc mixed data=hye method=type3;
class x;
model = b c d a a*x / noint solution;
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Further, I would like to construct the ten contrasts necessary to test for significance of differences between each pair of slopes. I'm completely at loss how to go about it.
In case of three contrasts(3C2) originating from 3 groups for a categorical predictor, the code would be like this:
ods select SolutionF Contrasts;
contrast 'x1 vs x2' a*x 1 -1 0;
contrast 'x1 vs x3' a*x 1 0 -1;
contrast 'x2 vs x3' a*x 0 1 -1;
Thank you for the additional information. You've made an excellent start.
The INPUT statement in your DATA step is probably wrong: it specifies a as a categorical variable ("a $"), and it is missing x. Perhaps you mean it to be
input x $ a b c d e;
The ESTIMATE statement in the GLIMMIX (but not the MIXED) procedure has an ADJUST option that will work for what you want:
Try something like
proc glimmix data=hye;
class x;
model = x a*x b c d e / noint solution;
estimate 'x1 vs x2' a*x 1 -1 0 0 0,
'x1 vs x3' a*x 1 0 -1 0 0,
/* add the other 7 comparisons */
'x4 vs x5' a*x 0 0 0 1 -1
/ adjust=bon stepdown adjdfe=row;
run;
Note the change I've made in the MODEL statement: I added e, and replaced a with x; if the effect of the change is not obvious to you, run the model without b, c, d, and e to see how the model is parameterized with respect to a and x.
Note, too, that for your equation to match the code above, there will be no intercept (const), there will be no "a*beta1", and "beta6" (and "beta7") will actually be 5 parameters, one for each level of x.
By default, the estimates will be computed at b=c=d=e=0. Because there are no interactions involving these factors in the model, the estimates that you want will not be affected by the values of b, c, d, and e.
I have not run this code, and so I don't guarantee it will work, it might need tweaking (and I'm not sure about your data input).
Thank you for such a detailed response and a working solution. It indeed worked!
Excellent! Thanks for letting me know.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.