Prediction (out of sample) Link to Notebook GitHub In [1]: from __future__ import print_function
import numpy as np
import statsmodels.api as sm
Artificial data In [2]: nsample = 50
sig = 0.25
x1 = np.linspace(0, 20, nsample)
X = np.column_stack((x1, np.sin(x1), (x1-5)**2))
X = sm.add_constant(X)
beta = [5., 0.5, 0.5, -0.02]
y_true = np.dot(X, beta)
y = y_true + sig * np.random.normal(size=nsample)
Estimation In [3]: olsmod = sm.OLS(y, X)
olsres = olsmo