Re: [R] question about contrast in R for multi-factor linear regression models?

From: Mark Difford <mark_difford_at_yahoo.co.uk>
Date: Mon, 10 Nov 2008 23:32:14 -0800 (PST)

Hi losemind,

>> What's wrong?

What's wrong is probably that you never read the help page for dummy.coef properly. But that is a wild guess, since I have no idea what your yy is. And one is strongly inclined to say, "Why, oh why?"

Your first posting on this subject has your linear model fit, which is the object that the help page for dummy.coef says should be given to it, as zz:

> zz=lm(formula = (dd$Y) ~ dd$A * dd$B)
> summary(zz)

It is also, by the way, a courtesy to address the list, since you are asking its members for help. And perhaps also to thank them.

I do hope that helps,
Mark.

losemind wrote:
>

>> 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.
>>

>
> ______________________________________________
> 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--tp20413510p20434736.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.
Received on Tue 11 Nov 2008 - 07:34:34 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 11 Nov 2008 - 08:30:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive