[R] question about contrast in R for multi-factor linear regression models?
Michael
comtech.usa at gmail.com
Tue Nov 11 03:03:36 CET 2008
> Yes, it is possible to lose your mind on this (so perhaps get a real name).
> A good friend here is
>
> ?dummy.coef
When I use it, it complained:
> dummy.coef(yy)
Error in dd$A1 : $ operator is invalid for atomic vectors
What's wrong?
>
> In your case (i.e. treatment contrasts), your reference level for the
> interaction terms are the reference levels of the factors themselves. In
> your example, these seem to be A1 and b1. Assuming they are, the coefficient
> for, say, dd$AA3:dd$Bb2 is worked out relative to them.
>
dd$AA3:dd$Bb2 is relative to
dd$AA1 only, or
dd$Bb1 only , or
dd$AA1 + dd$Bb1, or
dd$AA1 : dd$Bb1, or
dd$AA1 * dd$Bb1
That's exactly where I was not sure about!
>> Call:
>> lm(formula = dd$Y~ dd$A * dd$B)
>>
>> Residuals:
>> Min 1Q Median 3Q Max
>> -1.68582 -0.42469 -0.02536 0.20012 3.50798
>>
>> Coefficients:
>> Estimate Std. Error t value Pr(>|t|)
>> (Intercept) 4.40842 0.40295 10.940 5.34e-13 ***
>> dd$AA2 0.11575 0.56986 0.203 0.8402
>> dd$AA3 0.01312 0.56986 0.023 0.9818
>> dd$AA4 -0.06675 0.56986 -0.117 0.9074
>> dd$AA5 0.10635 0.56986 0.187 0.8530
>> dd$AA6 0.11507 0.56986 0.202 0.8411
>> dd$Bb2 -0.58881 0.56986 -1.033 0.3084
>> c 0.26465 0.80590 0.328 0.7445
>> dd$AA3:dd$Bb2 0.40984 0.80590 0.509 0.6142
>> dd$AA4:dd$Bb2 -0.02918 0.80590 -0.036 0.9713
>> dd$AA5:dd$Bb2 0.35574 0.80590 0.441 0.6616
>> dd$AA6:dd$Bb2 1.55424 0.80590 1.929 0.0617 .
>> ---
>> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>>
>> Residual standard error: 0.8059 on 36 degrees of freedom
>> Multiple R-squared: 0.2642, Adjusted R-squared: 0.03934
>> F-statistic: 1.175 on 11 and 36 DF, p-value: 0.3378
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
> --
> View this message in context: http://www.nabble.com/question-about-contrast-in-R-for-multi-factor-linear-regression-models--tp20413510p20416877.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list