Beruflich Dokumente
Kultur Dokumente
> abline(coef(g))
>
ONE-WAY Model in lm
1.0
0.6
0.8
drywt
1.2
1.0
2.0
2.5
3.0
trt
Max
0.192667
0.6
0.8
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.72933
0.11046
6.603 1.71e-05 ***
trt
0.14900
0.05113
2.914
0.0121 *
--Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
1.0
3Q
0.131667
drywt
1.2
Call:
lm(formula = drywt ~ trt)
Residuals:
Min
1Q
Median
-0.288333 -0.077833 -0.006333
1.5
factor(trt)
Call:
lm(formula = drywt ~ trt)
Residuals:
Min
1Q Median
-0.284 -0.080 -0.002
3Q
0.136
Max
0.188
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)
0.8740
0.0752 11.622 6.9e-08 ***
trt2
0.1620
0.1064
1.523
0.154
trt3
0.2980
0.1064
2.802
0.016 *
--Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Residual standard error: 0.1682 on 12 degrees of freedom
Multiple R-squared: 0.3961,
Adjusted R-squared: 0.2955
F-statistic: 3.936 on 2 and 12 DF, p-value: 0.0485
> model.matrix(g)
(Intercept) trt2 trt3
1
1
0
0
2
1
0
0
3
1
0
0
4
1
0
0
5
1
0
0
6
1
1
0
7
1
1
0
8
1
1
0
9
1
1
0
10
1
1
0
11
1
0
1
12
1
0
1
13
1
0
1
14
1
0
1
15
1
0
1
attr(,"assign")
[1] 0 1 1
attr(,"contrasts")
attr(,"contrasts")$trt
[1] "contr.treatment"
>
>
>
>
> # If you want to see the contrast coefficients w/o the whole
design matrix
> contr.treatment(3)
2 3
1 0 0
2 1 0
3 0 1
> contr.SAS(3)
1 2
1 1 0
2 0 1
3 0 0
> contr.sum(3)
[,1] [,2]
1
1
0
2
0
1
3
-1
-1
> contr.poly(3)
.L
.Q
[1,] -7.071068e-01 0.4082483
[2,] -9.073264e-17 -0.8164966
[3,] 7.071068e-01 0.4082483
> summary(g)
Call:
lm(formula = drywt ~ trt)
Residuals:
Min
1Q Median
-0.284 -0.080 -0.002
3Q
0.136
Max
0.188
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.02733
0.04342 23.662 1.94e-11 ***
trt1
-0.23000
0.09210 -2.497
0.0281 *
trt2
-0.13600
0.10635 -1.279
0.2252
--Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1
Residual standard error: 0.1682 on 12 degrees of freedom
Multiple R-squared: 0.3961,
Adjusted R-squared: 0.2955
F-statistic: 3.936 on 2 and 12 DF, p-value: 0.0485
>
>
>
>
> # Confidence intervals for contrasts the hard way: compare trt 1
to the average of trt 2 and trt 3.
>
> c <- c(1,-0.5,-0.5)
> est <- t(c)%*%coef(g)
> se.c <- sqrt(t(c)%*%vcov(g)%*%c)
> tval <- qt(0.975,df.residual(g))
> lcl <- est-tval*se.c
> ucl <- est+tval*se.c
> est
[,1]
[1,] -0.23
> lcl
[,1]
[1,] -0.4306756
> ucl
[,1]
[1,] -0.02932436
0.6
0.0
0.2
0.4
drywt
0.8
1.0
>
> # Comparing all pairs of individual means
>
> mn <- tapply(drywt,trt,mean)
#computes a table of means
> barplot(mn,xlab="trt",ylab="drywt")
trt
>
> pairwise.t.test(drywt,trt, p.adjust.method="none")
the model
1
2
2 0.154 3 0.016 0.225
P value adjustment method: none
10