本文是實驗設計與分析(第6版,Montgomery著,傅玨生譯) 第10章擬合回歸模型10.9節思考題10.1 R語言解題。主要涉及線性回歸、回歸的顯著性、回歸系數的置信區間。
vial <- seq(1, 10, 1)
Viscosity <- c(160,171,175,182,184,181,188,193,195,200)
Temperature <- c(10,15,15,20,20,20,25,25,28,30)
visc <- data.frame(vial, Viscosity, Temperature)
visc
lm.fit <- lm(Viscosity ~ Temperature, data=visc)
summary (lm.fit)
summary (aov(lm.fit))
> summary (lm.fit)
Call:
lm.default(formula = Viscosity ~ Temperature, data = visc)
Residuals:
??? Min????? 1Q? Median????? 3Q???? Max
-2.7903 -1.3206 -0.2903? 1.8080? 2.9961
Coefficients:
??????????? Estimate Std. Error t value Pr(>|t|)???
(Intercept) 143.8244???? 2.5215?? 57.04 9.91e-12 ***
Temperature?? 1.8786???? 0.1165?? 16.12 2.20e-07 ***
---
Signif. codes:?
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.203 on 8 degrees of freedom
Multiple R-squared:? 0.9701,?? Adjusted R-squared:? 0.9664
F-statistic:?? 260 on 1 and 8 DF,? p-value: 2.197e-07
op <- par(mfrow=c(2,2), las=1)
plot(lm.fit)
par(op)
library(car)
carPlots(lm.fit)