How to calculate the 99% confidence interval for the slope in a linear regression model in python?

import numpy as np, statsmodels.api as sm

nsample = 100
x = np.linspace(0, 10, nsample)
X = np.column_stack((x, x**2))
beta = np.array([1, 0.1, 10])
e = np.random.normal(size=nsample)

X = sm.add_constant(X)
y = np.dot(X, beta) + e

mod = sm.OLS(y, X)
res = mod.fit()
print res.conf_int(0.01)   # 99% confidence interval
Published an original article · won praise 0 · Views 2

Guess you like

Origin blog.csdn.net/qq_36017395/article/details/104650650