data aaa;
input x1 x2 y @@;
datalines;
1 1 0.02 1 1 0.01 1 1 0.07 1 1 0.04 1 1 0.01 1 1 0.09 1 1 0.05 1 1 0.06
1 2 0.05 1 2 0.01 1 2 0.04 1 2 0.03 1 2 0.02 1 2 0.02 1 2 0.13 1 2 0.06
2 1 0.15 2 1 0.11 2 1 0.22 2 1 0.05 2 1 0.09 2 1 0.05 2 1 0.15 2 1 0.11
2 2 0.14 2 2 0.21 2 2 0.06 2 2 0.12 2 2 0.11 2 2 0.19 2 2 0.12 2 2 0.04
3 1 0.09 3 1 0.03 3 1 0.18 3 1 0.12 3 1 0.18 3 1 0.43 3 1 0.24 3 1 0.4
3 2 0.02 3 2 0.19 3 2 0.15 3 2 0.07 3 2 0.45 3 2 0.2 3 2 0.49 3 2 0.19
;
proc glm data=aaa;
class x1 x2;
model y=x1 x2 x1*x2;
contrast 'linear trend1' x1 -2 0 2 x1*x2 -1 0 1 -1 0 1;
run;
I am trying to get linear trend with interaction, and this contrast coding returned to me with a message that contrast is not estimable. Can somebody clear me out why it's not estimable? I tried bunch of other contrasts, but still the same. Thank you always for your help in advance.
I would also suggest adding the E option to the ESTIMATE which will match the coefficients of the L vector up with their respective parameters.
contrast 'linear trend1' x1 -2 0 2 x1*x2 -1 0 1 -1 0 1/e;
When you do that for this example you will notice that you are applying coefficients in the interaction to parameters where x1=2.
You need to have the interaction coefficients match up with the levels in the main effect. Something like this would be estimable:
contrast 'linear trend1' x1 -2 0 2 x1*x2 -1 -1 0 0 1 1/e;
But you would need to decide if this is actually what you want.
To understand the logic of CONTRAST/ESTIMATE statements, I would (in addition to what Rick suggested) add these examples as well.
http://support.sas.com/kb/24/447.html
The SAS/STAT documentation contains a section that discusses estimability and shows examples. If you change your MODEL statement to
model y=x1 x2 x1*x2 / solution XPX;
then you can see the X`X matrix and the parameter estimates for your model.
I would also suggest adding the E option to the ESTIMATE which will match the coefficients of the L vector up with their respective parameters.
contrast 'linear trend1' x1 -2 0 2 x1*x2 -1 0 1 -1 0 1/e;
When you do that for this example you will notice that you are applying coefficients in the interaction to parameters where x1=2.
You need to have the interaction coefficients match up with the levels in the main effect. Something like this would be estimable:
contrast 'linear trend1' x1 -2 0 2 x1*x2 -1 -1 0 0 1 1/e;
But you would need to decide if this is actually what you want.
To understand the logic of CONTRAST/ESTIMATE statements, I would (in addition to what Rick suggested) add these examples as well.
http://support.sas.com/kb/24/447.html
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.