Repository navigation
ENH: Statespace: Postestimation - #2566
Conversation
|
Initial push adds support to state space results objects for:
|
|
Ah, looks live I've messed up this branch. I'll clean this up with Git and force push in a bit. |
|
Okay, that did it, this branch is clean. |
3f0e3d3 to
bf230aa
Compare
|
Rebased. Currently this branch includes:
and I think that is enough for now. The FEVD and asymptotic confidence intervals for IRFs that I have in mind are specific to VARMA-type models, so I think I'd like to add them there instead of generally for the state space classes. So, pending review and assuming Travis is green, I think this branch can be merged. |
There was a problem hiding this comment.
What is k_posdef? not defined or explained
shape specification in numpy notation would be easier to understand, e.g.
"a column vector with shape (k_posdef, 1)"
There was a problem hiding this comment.
k_posdef is defined in the general state space model; I'll add a note giving that reference.
Good idea about the shape specification.
|
@ChadFulton general question (about possible future design changes) Would it be difficult to add an option that the estimation uses only a subsample of the attached data? My guess would be that this could be a good speedup for rolling or expanding backtesting, or crossvalidation on out of sample prediction, depending on how expensive it is to set up a state space model from scratch. |
There was a problem hiding this comment.
The signature of the method still has full_results
|
Please rebase again, so we get the Travis run after the test fixes. master is on 0.8 version, so I can merge this today or tomorrow I didn't completely review, not enough to understand how all the pieces fit together. I didn't see any real problems. |
|
Just one comment that might not be immediately relevant. There are some use cases to allow for custom covariance matrices for generalized impulse response functions |
|
On impulse response function options, especially concerning orthogonalized and generalized IRFs: (Note: I haven't thought about this too deeply, but I'm pretty sure the below is a first-pass correct way to view the differences. I'm going to dump some information here, which may or may not be useful to you, but will be useful to me to put down somewhere.) The main difference is that the VAR specification knows the moving average form (dynamic multipliers) from the coefficient matrices. Then orthogonalized or generalized impulse responses can be computed by selecting (possibly scaled) columns from the dynamic multipliers multiplied by some matrix (e.g. Cholesky decomposition or otherwise). The key here is that the VAR impulse responses are usually described in terms of the selection of columns from matrices that can be generically known / calculated. The problem here is calculating the matrices we want. In our generic case we do not know the moving average form, and so we don't know the dynamic multipliers, so instead I have set this up to think about simulating the process from a given initial shock. Thought about this way, the problem is selecting the initial shock. In the naive case, this leads to doing a 1-unit shock to a specific error component. In the "orthogonalized" shocks case, this leads to taking a 1-unit shock to a specific error component and using the Cholesky factor to "spread the shock out" according to the true correlation structure. In the "generalized" case, again spread the shock out, but this time according to the scaled covariance matrix. A byproduct of this difference is that the function in the state space package can only compute a single impulse response at a time, whereas in the VAR model it can compute them all simultaneously through matrix multiplication. Right now, the implementation allows specification of the (single) impulse itself, so it is generic to any formulation someone might want. i.e. you could get orthogonalized impulse responses as follows: mod = ...
res = mod.fit()
base_impulse = np.array([1,0,0])
var_decomp = np.linalg.cholesky(res.filter_results.state_cov)
impulse = np.dot(var_decomp, base_impulse)
res.impulse_responses(steps=10, impulse=impulse)or generalized impulses by doing: mod = ...
res = mod.fit()
base_impulse = np.array([1,0,0])
state_cov = res.filter_results.state_cov
impulse = np.dot(state_cov, base_impulse) / np.sqrt(state_cov[0,0])
res.impulse_responses(steps=10, impulse=impulse)Right now there are two additional conveniences; first, instead of providing the impulse vector, you can instead provide the index of the error component to be shocked; the following does a 1-unit impulse to the second error component. mod = ...
res = mod.fit()
res.impulse_responses(steps=10, impulse=1)The second helper allows orthogonalized shocks using the mod = ...
res = mod.fit()
res.impulse_responses(steps=10, impulse=1, orthogonalized=True)so this just generates the base impuse vector as So maybe I should remove the |
removes support for `full_results` in predict.
and do not use `full_results`.
(in case subclasses expect that the model is in the original state).
to MLEResults object.
methods to the model, with `params` argument.
cannot be calculated due to singular info. mat.
matches the existing behavior for attributes.
in PredictionResults.
bb62488 to
72a5fd4
Compare
|
Rebased. I think I have fixed all the above comments, except for the question about whether to replace |
|
That took a long time for Travis to run the tests. Py 2.6 timed out this time. Something is still fragile somewhere. The first py 2.7 times out sometimes, it's the first time I saw it with py2.6, AFAIR.
I'm planning to merge this after another brief look. |
ENH: Statespace: Postestimation
|
Thanks @ChadFulton number 1 is merged |
A PR corresponding to #2564. Would like to add support for (at least):
Possibly will also address (but may punt for later):