gpt4 book ai didi

pandas - 如何从 Pandas 的 OLS-summary 中提取特定值?

转载 作者:行者123 更新时间:2023-12-04 05:47:04 25 4
gpt4 key购买 nike

是否有可能从 pandas 的线性回归摘要中获得其他值(目前我只知道一种获取 beta 和截距的方法)?我需要得到 R 平方。
这是手册的摘录:

In [244]: model = ols(y=rets['AAPL'], x=rets.ix[:, ['GOOG']])

In [245]: model
Out[245]:
-------------------------Summary of Regression Analysis--------------------- ----
Formula: Y ~ <GOOG> + <intercept>
Number of Observations: 756
Number of Degrees of Freedom: 2
R-squared: 0.2814
Adj R-squared: 0.2805
Rmse: 0.0147
F-stat (1, 754): 295.2873, p-value: 0.0000
Degrees of Freedom: model 1, resid 754
-----------------------Summary of Estimated Coefficients------------------------
Variable Coef Std Err t-stat p-value CI 2.5% CI 97.5%
--------------------------------------------------------------------------------
GOOG 0.5442 0.0317 17.18 0.0000 0.4822 0.6063
intercept 0.0011 0.0005 2.14 0.0327 0.0001 0.0022
---------------------------------End of Summary---------------------------------

谢谢

最佳答案

Docs handling the results of the regression - 这将允许您从回归结果中提取一些值:

# Given
model = ols(y=rets['AAPL'], x=rets.ix[:, ['GOOG']]).fit()
r-squared 的情况下采用:
# retrieving model's r-squared value
model.rsquared
p-values 的情况下采用:
# return p-values and corresponding coefficients in model
model.pvalues
更多参数( fvalues ess )请引用 doc

关于pandas - 如何从 Pandas 的 OLS-summary 中提取特定值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37508158/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com