In: Statistics and Probability
> x=c(rep(1,5),rep(2,5))
> x1=as.factor(x)
> e=rnorm(10,0,3)
> y=4*x+e
> fit=lm(y~x1)
> summary(fit)
Call:
lm(formula = y ~ x1)
Residuals:
Min 1Q Median 3Q Max
-4.7426 -2.4395 0.5468 2.1125 5.0009
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.399 1.514 3.565 0.00734 *
x12 3.173 2.142 1.482 0.17670 ***
- - -
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.386 on 8 degrees of freedom
Multiple R-squared: 0.2153, Adjusted R-squared: 0.1173
F-statistic: 2.195 on 1 and 8 DF, p-value: 0.1767
> fit=lm(y~x1-1)
> summary(fit)
Call:
lm(formula = y ~ x1 - 1)
Residuals:
Min 1Q Median 3Q Max
-4.7426 -2.4395 0.5468 2.1125
Coefficients:
Estimate Std. Error t value Pr(>|t|)
x11 5.399 1.514 3.565 x11 0.007345 *
x12 8.572 1.514 5.661 x12 0.000476 ***
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 3.386 on 8 degrees of freedom
Multiple R-squared: 0.8484, Adjusted R-squared: 0.8104
F-statistic: 22.38 on 2 and 8 DF, p-value: 0.0005289
>fit1=lm(y~x1,contrasts=list(X1=”contr.sum”))
Summary(fit1)
the question is what is summary(fit1)
Here summary(fit1) shows the test for the contrast of the X1 i.e. the treatment effect. From the p-value, we can say that the test is accepted as it is >0.05.