预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共49页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

第三章自变量的选择与逐步回归自变量选择与逐步回归§1自变量选择对估计和预测的影响所有子集回归所有子集回归所有子集回归所有子集回归所有子集回归所有子集回归所有子集回归所有子集回归所有子集回归所有子集回归所有子集回归所有子集回归所有子集回归Cp图所有子集回归所有子集回归所有子集回归所有子集回归逐步回归逐步回归逐步回归逐步回归逐步回归香港恒生指数逐步回归逐步回归逐步回归逐步回归逐步回归例(数据文件为eg2.1)模型的参数估计和检验#打开数据文件eg2.1.xls,选取A1:F37区域,然后复制 data2.1<-read.table("clipboard",header=T)#将eg2.1.xls数据读入到data2.1中 lm.salary<-lm(y~x1+x2+x3+x4,data=data2.1)#建立y关于x1、x2、x3和x4的线性回归方程,数据为data2.1 summary(lm.salary)#模型汇总,给出模型回归系数的估计和显著性检验等Call: lm(formula=y~x1+x2+x3+x4,data=data2.1) Residuals: Min1QMedian3QMax -12924.2-4588.1-269.61756.225215.7 Coefficients: EstimateStd.ErrortvaluePr(>|t|) (Intercept)48386.062011237.28824.3060.000155*** x11.68310.130212.9295.01e-14*** x2-34.5520130.2602-0.2650.792570 x3-13.000413.7882-0.9430.353043 x4808.3223547.80171.4760.150144 --- Signif.codes:0‘***’0.001‘**’0.01‘*’0.05‘.’0.1‘’1 Residualstandarderror:7858on31degreesoffreedom MultipleR-squared:0.919,AdjustedR-squared:0.9086 F-statistic:87.95on4and31DF,p-value:<2.2e-16 #假设eg2.1.xls中的数据已经读入到data2.1中, lm.salary<-lm(y~x1+x2+x3+x4,data=data2.1)#建立全变量回归方程 lm.step<-step(lm.salary,direction="both")#用“一切子集回归法”来进行逐步回归direction是确定逐步搜索的方向:"both"是“一切子集回归法”,"forward"是“向前法”,"backward"是“向后法”,默认值是"both".所以这个回归过程可以简写为lm.step<-step(lm.salary) Start:AIC=650.41 y~x1+x2+x3+x4 DfSumofSqRSSAIC -x214.3448e+061.9186e+09648.49 -x315.4896e+071.9692e+09649.43 <none>1.9143e+09650.41 -x411.3445e+082.0487e+09650.85 -x111.0323e+101.2237e+10715.19 Step:AIC=648.49 y~x1+x3+x4 DfSumofSqRSSAIC -x316.2078e+071.9807e+09647.64 <none>1.9186e+09648.49 -x411.3011e+082.0487e+09648.85 +x214.3448e+061.9143e+09650.41 -x111.0341e+101.2259e+10713.26 Step:AIC=647.64 y~x1+x4 DfSumofSqRSSAIC <none>1.9807e+09647.64 +x316.2078e+071.9186e+09648.49 +x211.1527e+071.9692e+09649.43 -x412.9640e+082.2771e+09650.66 -x111.1654e+101.3635e+10715.09Call: lm(formula=y~x1+x4,data=data2.1) Residuals: Min1QMedian3QMax -13632-4759-615176125076 Coefficients: EstimateStd.ErrortvaluePr(>|t|) (Intercept)42097.1655265.2187.9953.18e-09*** x11.6310.11713.9342.22e-15***