Last active
August 29, 2015 14:15
-
-
Save thisfred/3d876d686a34d7752d91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import numpy as np | |
>>> import statsmodels.api as sm | |
>>> Y = [1,3,4,5,2,3,4] | |
>>> X = range(1,8) | |
>>> X = sm.add_constant(X) | |
>>> model = sm.OLS(Y,X) | |
>>> results = model.fit() | |
>>> results.params | |
array([ 2.14285714, 0.25 ]) | |
>>> results.tvalues | |
array([ 1.87867287, 0.98019606]) | |
>>> print(results.t_test([1, 0])) # note there was one closing paren too many in the example... | |
Test for Constraints | |
============================================================================== | |
coef std err t P>|t| [95.0% Conf. Int.] | |
------------------------------------------------------------------------------ | |
c0 2.1429 1.141 1.879 0.119 -0.789 5.075 | |
============================================================================== | |
>>> print(results.f_test(np.identity(2))) | |
<F test: F=array([[ 19.46078431]]), p=0.00437250591095, df_denom=5, df_num=2> | |
>>> X | |
array([[ 1., 1.], | |
[ 1., 2.], | |
[ 1., 3.], | |
[ 1., 4.], | |
[ 1., 5.], | |
[ 1., 6.], | |
[ 1., 7.]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment