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

From: Michael <comtech.usa_at_gmail.com>
Date: Sun, 09 Nov 2008 18:28:22 -0800

I am using "lm" to fit some anova factor models with interactions.

The default setting for my unordered factors is "treatment". I understand the resultant "lm" coefficients for one factors, but when it comes to the interaction term, I got confused.

> options()\$contrasts

```        unordered           ordered
"contr.treatment"      "contr.poly"

```

Here is my question:

Factor A has 6 levels, B has 2 levels,

> levels(dd\$A)=c("A1", "A2", "A3", "A4", "A5", "A6")
> levels(dd\$B)=c("b1", "b2")

I am having a hard time to understand the result and making sense out of the numbers...

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

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
dd\$AA2:dd\$Bb2  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