[英]How to save in a variable significance of a coefficient estimated by OLS using statsmodels in python?
I performed a linear regression(OLS) using statsmodels.formula.api and showing the paramenters and summary the following way: 我使用statsmodels.formula.api执行了线性回归(OLS),并通过以下方式显示了参数和摘要:
result = sm.ols(formula="items ~ views + price", data=nvo).fit()
print result.params
This is very usefull but I would like to save the significance of a the coefficient of price in a variable, how can I acces the elements of the summary object? 这非常有用,但是我想将价格系数的意义保留在变量中,我如何添加汇总对象的元素? Specificly how can I save the R squared, significance and the confidence interval? 具体来说,如何保存R平方,有效值和置信区间?
Oh, I managed to answer my own question. 哦,我设法回答了我自己的问题。 You just have to go ahead and do the following: 您只需要继续执行以下操作:
print result.pvalue
print result.conf_int()
print result.rsquared
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.