利用swiss数据集进行多元线性回归研究
# 先查看各变量间的散点图
pairs(swiss, panel = panel.smooth, main = "swiss data",
col = 3 + (swiss$Catholic > 50))
# 利用全部变量建立多元线性回
a=lm(Fertility ~ . , data = swiss)
summary(a)
##
## Call:
## lm(formula = Fertility ~ ., data = swiss)
##
## Residuals:
## Min 1Q Median 3Q Max
## -15.274 -5.262 0.503 4.120 15.321
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 66.9152 10.7060 6.25 1.9e-07 ***
## Agriculture -0.1721 0.0703 -2.45 0.0187 *
## Examination -0.2580 0.2539 -1.02 0.3155
## Education -0.8709 0.1830 -4.76 2.4e-05 ***
## Catholic 0.1041 0.0353 2.95 0.0052 **
## Infant.Mortality 1.0770 0.3817 2.82 0.0073 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.17 on 41 degrees of freedom
## Multiple R-squared: 0.707, Adjusted R-squared: 0.671
## F-statistic: 19.8 on 5 and 41 DF, p-value: 5.59e-10
# 从结果看,Education变量的p值一颗星就都没有,说明对模型极不显著。