fit2 <- lm(weight ~ height + I(height^2), data=women)
> fit2 <- lm(weight ~ height + I(height^2), data=women)
> summary(fit2)
Call:
lm(formula=weight ~ height + I(height^2), data=women)
Residuals:
Min 1Q Median 3Q Max
-0.5094 -0.2961 -0.0094 0.2862 0.5971
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 261.87818 25.19677 10.39 2.4e-07 ***
Height -7.34832 0.77769 -9.45 6.6e-07 ***
I(height^2) 0.08306 0.00598 13.89 9.3e-09 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.384 on 12 degrees of freedom
Multiple R-squared: 0.999, Adjusted R-squared: 0.999
F-statistic: 1.14e+04 on 2 and 12 DF, p-value: <2e-16
> plot(women$height,women$weight,
xlab="Height (in inches)",
ylab="Weight (in lbs)")
> lines(women$height,fitted(fit2))
新的预测等式为:
在p<0.001水平下,回归系数都非常显著。模型的方差解释率已经增加到了99.9%。二次项的 显著性(t=13.89,p<0.001)表明包含二次项提高了模型的拟合度。从图8-2也可以看出曲线确实 拟合得较好。