Basic & Econometrics - Misspecified model - pitfalls
import pandas as pd
import numpy as np
import statsmodels.api as sm
$y_t = \beta y_{t-1}+u_t$
$u_t = \rho u_{t-1}+v_t$
Suppose we want to estimate $\beta$ by running an OLS regression of $y_t$ on $y_{t-1}$
T = 100
y = np.zeros([T,1])
u = np.zeros([T,1])
beta = .7
rho = .5
u[0] = np.random.normal()
y[0] = u[0]
for t in range(1,T):
u[t] = rho*u[t-1]+np.random.normal()
y[t] = beta*y[t-1]+u[t]
np.random.normal()
-0.09498498374286703
model = sm.OLS(y[1:],y[:-1])
model = sm.OLS(y[2:],np.concatenate([y[:-2],y[1:-1]],axis = 1))
res = model.fit()
res.summary()
| Dep. Variable: | y | R-squared (uncentered): | 0.764 |
|---|---|---|---|
| Model: | OLS | Adj. R-squared (uncentered): | 0.759 |
| Method: | Least Squares | F-statistic: | 155.4 |
| Date: | Mon, 25 Jan 2021 | Prob (F-statistic): | 7.95e-31 |
| Time: | 10:13:18 | Log-Likelihood: | -140.81 |
| No. Observations: | 98 | AIC: | 285.6 |
| Df Residuals: | 96 | BIC: | 290.8 |
| Df Model: | 2 | ||
| Covariance Type: | nonrobust |
| coef | std err | t | P>|t| | [0.025 | 0.975] | |
|---|---|---|---|---|---|---|
| x1 | -0.2794 | 0.099 | -2.825 | 0.006 | -0.476 | -0.083 |
| x2 | 1.1097 | 0.099 | 11.257 | 0.000 | 0.914 | 1.305 |
| Omnibus: | 0.819 | Durbin-Watson: | 2.050 |
|---|---|---|---|
| Prob(Omnibus): | 0.664 | Jarque-Bera (JB): | 0.866 |
| Skew: | 0.074 | Prob(JB): | 0.649 |
| Kurtosis: | 2.564 | Cond. No. | 3.67 |
Notes:
[1] R² is computed without centering (uncentered) since the model does not contain a constant.
[2] Standard Errors assume that the covariance matrix of the errors is correctly specified.
rho = beta-0.2794
-rho*beta = -(beta-0.2794)*beta = 1.1097
0.2794-beta^2 = 1.