> out = lm(Postwt ~ Prewt + Treat, data=anorexia)
> anova(out)
Analysis of Variance Table
Response: Postwt
Df Sum Sq Mean Sq F value Pr(>F)
Prewt 1 506.5 506.51 10.4017 0.0019364 **
Treat 2 766.3 383.14 7.8681 0.0008438 ***
Residuals 68 3311.3 48.70
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> summary(out)
Call:
lm(formula = Postwt ~ Prewt + Treat, data = anorexia)
Residuals:
Min 1Q Median 3Q Max
-14.1083 -4.2773 -0.5484 5.4838 15.2922
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 45.6740 13.2167 3.456 0.000950 ***
Prewt 0.4345 0.1612 2.695 0.008850 **
TreatCBT 4.0971 1.8935 2.164 0.033999 *
TreatFT 8.6601 2.1931 3.949 0.000189 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 6.978 on 68 degrees of freedom
Multiple R-squared: 0.2777, Adjusted R-squared: 0.2458
F-statistic: 8.713 on 3 and 68 DF, p-value: 5.719e-05
> library(multcomp)
> dunnett = glht(out, linfct=mcp(Treat="Dunnett"))
> summary(dunnett)
Simultaneous Tests for General Linear Hypotheses
Multiple Comparisons of Means: Dunnett Contrasts
Fit: lm(formula = Postwt ~ Prewt + Treat, data = anorexia)
Linear Hypotheses:
Estimate Std. Error t value Pr(>|t|)
CBT - Cont == 0 4.097 1.893 2.164 0.062939 .
FT - Cont == 0 8.660 2.193 3.949 0.000373 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Adjusted p values reported -- single-step method)
> tri = read.csv("tri.csv")
> out = lm(trichg ~ hgba1c + trt, data=tri)
> anova(out)
Analysis of Variance Table
Response: trichg
Df Sum Sq Mean Sq F value Pr(>F)
hgba1c 1 5442.7 5442.7 58.1068 1.353e-08 ***
trt 1 865.4 865.4 9.2387 0.004783 **
Residuals 31 2903.7 93.7
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1