【发布时间】:2016-02-28 02:05:35
【问题描述】:
我想使用 Python 中的标准工具(numpy、pandas、scipy.stats 等)计算线性回归模型的 beta or standardized coefficient。
我的一个朋友告诉我,这是在 R 中使用以下命令完成的:
lm(scale(y) ~ scale(x))
目前,我在 Python 中这样计算它:
from scipy.stats import linregress
from scipy.stats.mstats import zscore
(beta_coeff, intercept, rvalue, pvalue, stderr) = linregress(zscore(x), zscore(y))
print('The Beta Coeff is: %f' % beta_coeff)
有没有更直接的函数可以在 Python 中计算这个数字?
【问题讨论】:
-
如果您有多个自变量。请看这个post
标签: python numpy scipy statistics linear-regression