回归分析作业4

时间:2021-11-09 16:50:12

作业内容:

回归分析作业4

数据:

y x1 x2 x3 x4 x5
271.8 783.35 33.53 40.55 16.66 13.2
264 748.45 36.5 36.19 16.46 14.11
238.8 684.45 34.66 37.31 17.66 15.68
230.7 827.8 33.13 32.52 17.5 10.53
251.6 860.45 35.75 33.71 16.4 11
257.9 875.15 34.46 34.14 16.28 11.31
263.9 909.45 34.6 34.85 16.06 11.96
266.5 905.55 35.38 35.89 15.93 12.58
229.1 756 35.85 33.53 16.6 10.56
239.3 769.35 35.68 33.79 16.41 10.85
258 793.5 35.35 34.72 16.17 11.41
257.6 801.65 35.04 35.22 15.92 11.91
267.3 819.65 34.07 36.5 16.04 12.85
267 808.55 32.2 37.6 16.19 13.58
259.6 774.95 34.32 37.89 16.62 14.21
240.4 711.85 31.08 37.71 17.37 15.56
227.2 694.85 35.73 37 18.12 15.83
196 638.1 34.11 36.76 18.53 16.41
278.7 774.55 34.79 34.62 15.54 13.1
272.3 757.9 35.77 35.4 15.7 13.63
267.4 753.35 36.44 35.96 16.45 14.51
254.5 704.7 37.82 36.26 17.62 15.38
224.7 666.8 35.07 36.34 18.12 16.1
181.5 568.55 35.26 35.9 19.05 16.73
227.5 653.1 35.56 31.84 16.51 10.58
253.6 704.05 35.73 33.16 16.02 11.28
263 709.6 36.46 33.83 15.89 11.91
265.8 726.9 36.26 34.89 15.83 12.65
263.8 697.15 37.2 36.27 16.71 14.06
参考实现(use R)

data<-read.csv("data4th.csv")
lm1<-lm(y~.,data=data)
#向前法
step(lm1,direction="forward")
#逐步回归
step(lm1)
#所有可能回归
library(leaps)
regsubsets(y~.,data=data)#基于调整R^2