Designs with Two Factors

A Linear Model

Babies Walking

A linear model

m1 <- lm(walk ~ program, data = babies)
summary(m1)

Call:
lm(formula = walk ~ program, data = babies)

Residuals:
   Min     1Q Median     3Q    Max 
  -2.4   -0.7   -0.2    0.7    2.8 

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)           10.2000     0.5831  17.493 7.46e-12 ***
programRegular         0.4000     0.8246   0.485   0.6342    
programWeekly report   1.2000     0.8246   1.455   0.1649    
programSingle report   1.8000     0.8246   2.183   0.0443 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.304 on 16 degrees of freedom
Multiple R-squared:  0.2639,    Adjusted R-squared:  0.1258 
F-statistic: 1.912 on 3 and 16 DF,  p-value: 0.1684

The first level of the factor is the benchmark.

Applying the zero sum constraint

options(contrasts = c("contr.sum", "contr.poly"))
m2 <- lm(walk ~ program, data = babies)
summary(m2)

Call:
lm(formula = walk ~ program, data = babies)

Residuals:
   Min     1Q Median     3Q    Max 
  -2.4   -0.7   -0.2    0.7    2.8 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  11.0500     0.2915  37.901   <2e-16 ***
program1     -0.8500     0.5050  -1.683    0.112    
program2     -0.4500     0.5050  -0.891    0.386    
program3      0.3500     0.5050   0.693    0.498    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.304 on 16 degrees of freedom
Multiple R-squared:  0.2639,    Adjusted R-squared:  0.1258 
F-statistic: 1.912 on 3 and 16 DF,  p-value: 0.1684

Study: Battery Lifetime

Battery Lifetime Data

id material temp lifetime
1 1 15 130
2 1 15 155
3 1 70 34
4 1 70 40
5 1 125 20
6 1 125 70
7 1 15 74
8 1 15 180
9 1 70 80
10 1 70 75
11 1 125 82
12 1 125 58
13 2 15 150
14 2 15 188
15 2 70 136
16 2 70 122
17 2 125 25
18 2 125 70
19 2 15 159
20 2 15 126
21 2 70 106
22 2 70 115
23 2 125 58
24 2 125 45
25 3 15 138
26 3 15 110
27 3 70 174
28 3 70 120
29 3 125 96
30 3 125 104
31 3 15 168
32 3 15 160
33 3 70 150
34 3 70 139
35 3 125 82
36 3 125 60

Counts in each treatment group

material temp n
1 15 4
1 70 4
1 125 4
2 15 4
2 70 4
2 125 4
3 15 4
3 70 4
3 125 4

EDA