I would like to assign a specific exogenous variable to a specific regression. In specific, consider the code below. How can I restrict beta.exog_only_for_inc_equation coefficient to be zero for equation dln_inv and restrict beta.exog_only_for_inv_equation coefficient to be zero for equation dln_inc?
import numpy as np
import pandas as pd
import statsmodels.api as sm
import matplotlib.pyplot as plt
dta = sm.datasets.webuse('lutkepohl2', 'https://www.stata-press.com/data/r12/')
dta.index = dta.qtr
endog = dta.loc['1960-04-01':'1978-10-01', ['dln_inv', 'dln_inc', 'dln_consump']]
endog['exog_only_for_inv_equation']=[endog.index[i].quarter for i in range(len(endog.index))]
endog['exog_only_for_inc_equation']=endog['dln_consump']
exog = endog[['exog_only_for_inv_equation','exog_only_for_inc_equation']]
mod = sm.tsa.VARMAX(endog[['dln_inv', 'dln_inc']], order=(2,0), trend='n', exog=exog)
res = mod.fit(maxiter=1000, disp=False)
print(res.summary())
Statespace Model Results
==================================================================================
Dep. Variable: ['dln_inv', 'dln_inc'] No. Observations: 75
Model: VARX(2) Log Likelihood 363.197
Date: Wed, 22 Apr 2020 AIC -696.394
Time: 22:49:07 BIC -661.631
Sample: 04-01-1960 HQIC -682.513
- 10-01-1978
Covariance Type: opg
===================================================================================
Ljung-Box (Q): 60.43, 38.85 Jarque-Bera (JB): 8.31, 4.57
Prob(Q): 0.02, 0.52 Prob(JB): 0.02, 0.10
Heteroskedasticity (H): 0.46, 0.42 Skew: 0.13, -0.55
Prob(H) (two-sided): 0.06, 0.04 Kurtosis: 4.61, 3.48
Results for equation dln_inv
===================================================================================================
coef std err z P>|z| [0.025 0.975]
---------------------------------------------------------------------------------------------------
L1.dln_inv -0.2468 0.094 -2.624 0.009 -0.431 -0.062
L1.dln_inc 0.2937 0.481 0.610 0.542 -0.649 1.237
L2.dln_inv -0.1873 0.152 -1.235 0.217 -0.485 0.110
L2.dln_inc -0.0805 0.413 -0.195 0.846 -0.891 0.730
beta.exog_only_for_inv_equation -0.0007 0.004 -0.172 0.863 -0.009 0.008
beta.exog_only_for_inc_equation 1.2446 0.639 1.947 0.052 -0.008 2.497
Results for equation dln_inc
===================================================================================================
coef std err z P>|z| [0.025 0.975]
---------------------------------------------------------------------------------------------------
L1.dln_inv 0.0606 0.033 1.830 0.067 -0.004 0.126
L1.dln_inc 0.0170 0.133 0.128 0.898 -0.243 0.277
L2.dln_inv 0.0116 0.035 0.333 0.739 -0.056 0.080
L2.dln_inc -0.0187 0.130 -0.143 0.886 -0.273 0.236
beta.exog_only_for_inv_equation 0.0018 0.001 1.756 0.079 -0.000 0.004
beta.exog_only_for_inc_equation 0.7046 0.111 6.321 0.000 0.486 0.923
Error covariance matrix
============================================================================================
coef std err z P>|z| [0.025 0.975]
--------------------------------------------------------------------------------------------
sqrt.var.dln_inv 0.0434 0.004 12.267 0.000 0.036 0.050
sqrt.cov.dln_inv.dln_inc 5.319e-06 0.002 0.003 0.998 -0.004 0.004
sqrt.var.dln_inc 0.0106 0.001 10.475 0.000 0.009 0.013
============================================================================================
Warnings:
[1] Covariance matrix calculated using the outer product of gradients (complex-step).
I had to dig through the documentation at statsmodels.tsa.statespace.dynamic_factor.DynamicFactor.
Right after mod, change the code with the following lines
which will yield:
To find the names of the parameters just type
which will show you all the param names you can use. For the above example,
Hope this proves to be useful.