练习R:stepAIC多元逐步回归
线性关系观察
chart.Correlation(murder[,-4], histogram=TRUE,method="pearson",pch=19)
强制拟合线性关系
fit <- lm(
Murder~
Population+Income+Illiteracy+HsGrad+Frost+Area,
data=murder
)
summary(fit)
逐步回归筛选变量
step.fit <- stepAIC(fit,direction = "both")
summary(step.fit)
drop1(step.fit)
重新拟合模型
opt.lm <- lm(
Murder~Population + Illiteracy + Area,
data = murder
)
summary(opt.lm)
本文完
文/图=数据小兵
赞 (0)