全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 HLM专版
2192 1
2014-05-24
I have been reading Applied Linear Statistical Models 5th Edition. The ridge regression is done on a data set available at body fat data. The textbook matches the output in SAS, where the back transformed coefficients are given in the fitted model as Y=-7.3978+0.5553*X1+0.3681*X2-0.1917*X3.

This is shown from SAS as:

proc reg data = ch7tab1a outest = temp outstb noprint;
  model y = x1-x3 / ridge = 0.02;
run;
quit;
proc print data = temp;
  where _ridge_ = 0.02 and y = -1;
  var y intercept x1 x2 x3;
run;
Obs     Y    Intercept       X1         X2         X3

2     -1     -7.40343    0.55535    0.36814    -0.19163
3     -1      0.00000    0.54633    0.37740    -0.13687
But R gives very different coefficients:
data<-read.table("http://www.cst.cmich.edu/users/lee1c/spss/V16_materials/DataSets_v16/BodyFat-TxtFormat.txt",sep=" ",header=FALSE)
data<-data[,c(1,3,5,7)]
colnames(data)<-c("x1","x2","x3","y")
ridge<-lm.ridge(y ~ ., data, lambda=0.02)   
ridge$coef
coef(ridge)

>   ridge$coef
       x1        x2        x3
10.126984 -4.682273 -3.527010
>   coef(ridge)
                   x1         x2         x3
42.2181995  2.0683914 -0.9177207 -0.9921824
>

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-5-24 05:23:58
标记一下。准备学习。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群