加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

让r输出标准回归系数

(2012-03-18 20:44:58)
标签:

杂谈

分类: R

这是一个说明r特点的很好的例子。与其他软件相比,r在标准化方面做得不算好。
比如r的lm功能是不输出标准化回归系数的。

此时,只好对着公式去自己一个一个去算了。

Beta.x1=(b.x1*sd.x1)/sd.y1

如果你有很多回归系数,还是写个function比较方便。

r里的计量经济学的包QuantPsyc里的lm.beta可以很方便的输出这个结果。
一个例子:
# install.packages("QuantPsyc")
library(QuantPsyc)
us <- USJudgeRatings
names(us)
lm1 <- lm ( CONT ~ INTG + DMNR + DILG, us)
lm.beta(lm1)


其中的lm.beta其实是:
function (MOD)
{
b <- summary(MOD)$coef[-1, 1]
sx <- sd(MOD$model[-1])
sy <- sd(MOD$model[1])
beta <- b * sx/sy
return(beta)
}

Advantages
Standard coefficients' advocates note that the coefficients ignore the independent variable's scale of units, which makes comparisons easy.
Disadvantages
Critics voice concerns that such a standardization can be misleading; a change of one standard deviation in one variable has no reason to be equivalent to a similar change in another predictor.

Some variables are easy to affect externally, e.g., the amount of time spent on an action. Weight or cholesterol level are more difficult, and some, like height or age, are impossible to affect externally.

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有