MATH05, Regression analysis
Back to the previous page | Statistics
List of posts to read before reading this article
Contents
Ordinary Least Squares
import statsmodels.api as sm
X = range(1,8)
X = sm.add_constant(X)
Y = [1,3,4,5,2,3,4]
model = sm.OLS(Y,X)
results = model.fit()
results.summary()
OUTPUT 1
OUTPUT 2
results.tvalues
array([ 1.87867287, 0.98019606])
results.t_test([1, 0])
<class 'statsmodels.stats.contrast.ContrastResults'>
Test for Constraints
==============================================================================
coef std err t P>|t| [0.025 0.975]
------------------------------------------------------------------------------
c0 2.1429 1.141 1.879 0.119 -0.789 5.075
==============================================================================
import numpy as np
results.f_test(np.identity(2))
<class 'statsmodels.stats.contrast.ContrastResults'>
<F test: F=array([[19.46078431]]), p=0.004372505910945688, df_denom=5, df_num=2>
title2
title3
List of posts followed by this article
Reference