早安/晚安,我有一个简单的问题,并针对我的编码问题进行了研究。
我稍后会查看我的图表中的线性回归:
import statsmodels.api as sm
#for the linear regression equations on HLOG plotted graph
#define response variable
y = b
#define explanatory variable
x = a1
#add constant to predictor variables
x = sm.add_constant(x)
#fit linear regression model
model = sm.OLS(y, x).fit()
#view model summary
print(model.summary())
OLS Regression Results
==============================================================================
Dep. Variable: y R-squared: 0.782
Model: OLS Adj. R-squared: 0.781
Method: Least Squares F-statistic: 1729.
Date: Sun, 21 Nov 2021 Prob (F-statistic): 1.10e-161
Time: 08:40:03 Log-Likelihood: -1319.0
No. Observations: 485 AIC: 2642.
Df Residuals: 483 BIC: 2650.
Df Model: 1
Covariance Type: nonrobust
==============================================================================
coef std err t P>|t| [0.025 0.975]
------------------------------------------------------------------------------
const -12.6145 0.338 -37.300 0.000 -13.279 -11.950
x1 -1.4197 0.034 -41.576 0.000 -1.487 -1.353
==============================================================================
Omnibus: 43.065 Durbin-Watson: 0.014
Prob(Omnibus): 0.000 Jarque-Bera (JB): 52.374
Skew: -0.752 Prob(JB): 4.24e-12
Kurtosis: 3.577 Cond. No. 20.2
==============================================================================
Warnings:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.
我的线性回归方程是y = -12.6145-1.4197x 我指的是Linear regression。
从这里开始,我很困惑该怎么做。我搜索它以区分我需要从我的图表中的一个方程。后来我可以使用bisection
方法或fsolve
方法
作为参考,我看到一个完美地拟合图表。牛顿多项式插值
在我完成线性回归后,谁能给我任何建议,让我从图中提取方程?
先感谢您。