import numpy as np
import statsmodels.api as sm
n = 50
np.random.seed(42)
x = np.random.rand(n)
y = np.random.rand(n) + 1
X2 = sm.add_constant(x)
est = sm.OLS(y, X2).fit()
print(est.summary())
est.summary()
gives me a nice printout of many summary statistics of my data. But I would like to retrieve the actual values of R^2 and the p-values (in this case, just the pvalue listed for x1). Something like:
pValue = est.pvalue()
R_squared = est.rsquared()
Is there a simple way to do this?