Introduction to Computational Analysis




Pay Notebook Creator: Roy Hyunjin Han0
Set Container: Numerical CPU with TINY Memory for 10 Minutes 0
Total0

Statsmodels is a collection of statistical models, tests and tools

In [5]:
# Adapted from
# https://github.com/statsmodels/statsmodels/examples/example_ols_minimal.py
import numpy as np
import statsmodels.api as sm

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

results = sm.OLS(y, X).fit()
print results.summary()
In [ ]:
# Cut and paste an example here and press CTRL-ENTER