965-R-Learning-Repo/test/t-code/2720047/R1006.R
2024-11-20 17:04:40 +08:00

12 lines
1.0 KiB
R
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

_______("longley.rdata") #读取longley.rdata数据集 (2分)
longley=________(longley,select=-Year) #删除掉Year属性 (2分)
cat("删除后,此时数据框还剩",___,"列")#填写剩余的列数(2分)
longley=as.data.frame(_______(longley))#对数据进行z-score规范化(2分)
md=lm(__________,data=longley)#以GNP.deflator为因变量建立它与其他所有变量之间的多元线性回归模型(4分)
_______(md)#显示模型结果 (2分)
cat("查看模型结果,此模型的拟合度","______")#填 好/不好(2分)
md_best=step(md)#对模型进行逐步法筛选出最优回归方程(2分)
cat("最优模型删除了",______,"个变量") #根据生成的结果填写删除的变量数量(2分)
new=_______(GNP=-1.3,Unemployed=-0.9,Armed.Forces=-1.45, Population=-1.46, Employed=-1.4) #填写合适的函数,生成一条新数据 (2分)
predict(md_best,new)
cat("预测的GNP.deflator结果是",_______) #将预测的数值结果填写在下划线处,按程序运行结果填写不要四舍五入。(2分)