简体   繁体   English

如何使用python中的statsmodels保存由OLS估计的系数的变量显着性?

[英]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.

相关问题 Python statsmodels OLS:如何将学习的模型保存到文件中 - Python statsmodels OLS: how to save learned model to file 如何在Python中使用statsmodels.api.OLS - How to use statsmodels.api.OLS in Python 当我使用python statsmodels在OLS中添加外生变量时,为什么R-Squared会减少 - Why would R-Squared decrease when I add an exogenous variable in OLS using python statsmodels 使用 statsmodels.formula.api package ols ZC1C425268E68385D1AB5074C17A94F13BDD2565DDDFCZEBEE7B43 时单个变量的重复列 - Repeated columns of a single variable when using statsmodels.formula.api package ols function in python 在Python Statsmodels中创建文件OLS - Create file OLS in Python Statsmodels Python - StatsModels,OLS置信区间 - Python - StatsModels, OLS Confidence interval Python Statsmodels:OLS 回归器无法预测 - Python Statsmodels: OLS regressor not predicting 使用OLS回归预测未来值(Python,StatsModels,Pandas) - Predicting out future values using OLS regression (Python, StatsModels, Pandas) 如何在 statsmodels/python 中计算 OLS 系数的同时置信区域? - How to compute simultaneous confidence region of OLS coefficients in statsmodels/python? Statsmodels - Wald检验线性回归模型(OLS)中系数趋势的显着性 - Statsmodels - Wald Test for significance of trend in coefficients in Linear Regression Model (OLS)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM