这是一个说明r特点的很好的例子。与其他软件相比,r在标准化方面做得不算好。比如r的lm功能是不输出标准化回归系数的。
此时,只好对着公式去自己一个一个去算了。
Beta.x1=(b.x1*sd.x1)/sd.y1
如果你有很多回归系数,还是写个function比较方便。
r里的计量经济学的包QuantPsyc里的lm.beta可以很方便的输出这个结果。一个例子:#install.packages("QuantPsyc")library(QuantPsyc)us <- USJudgeRatingsnames(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 ignorethe independent variable'sscaleof units, which makes comparisons easy.
- Disadvantages
- Critics voice concerns that such a standardization can bemisleading; a change of one standard deviation in one variable hasno reason to be equivalent to a similar change in anotherpredictor.
Some variables are easy to affect externally, e.g., the amount oftime spent on an action. Weight or cholesterol level are moredifficult, and some, like height or age, are impossible to affectexternally.