【发布时间】:2017-11-05 16:24:50
【问题描述】:
我试图使用以下代码来计算标准化系数:
rm(list=ls())
#install.packages("AER")
library(AER)
data("CASchools",package="AER")
CASchools$score=with(CASchools,(math+read)/2)
attach(CASchools)
#regular regressopm
lm1<-lm(score~income)
#standardized regression
stdscore<-(score-mean(score)/sd(score))
stdincome<-(income-mean(income))/sd(income)
lm1e<-lm(stdscore~stdincome)
#standardized regression provided by different package
#install.packages("QuantPsyc")
library(QuantPsyc)
lm.beta(lm1)
#but lm.beta is different from the coefficients I calculated with standardized regression
lm1e$coef
但是,QuantPsyc 包的输出似乎与我自己标准化回归量和因变量获得的结果不同。
两个输出是:
> lm.beta(lm1)
income
0.7124308
> lm1e$coef
(Intercept) stdincome
619.82365 13.57419
如您所见,其中一个结果是 0.7124308,另一个是 13.57419。根据我的理解,它们应该是等价的。
知道为什么吗?
【问题讨论】:
标签: r statistics regression