On Fri, Jun 29, 2012 at 7:16 PM, Paul Sawaya <
m...@paulsawaya.com> wrote:
> Thanks, Josef. I had made a silly mistake, and had my columns/rows
> backwards. I transposed them, and my code works.
>
> I am getting still another error with grangercausalitytests, however. It
> happens with the below matrix:
>
> b=array( ( (555,13),(798,13),(755,14) ) )
> grangercausalitytests(b,1)
>
> I see:
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib64/python2.6/site-packages/statsmodels/tsa/stattools.py",
> line 804, in grangercausalitytests
> ftres = res2djoint.f_test(rconstr)
> File "/usr/lib64/python2.6/site-packages/statsmodels/base/model.py", line
> 1162, in f_test
> cparams = np.dot(r_matrix, self.params[:, None])
> ValueError: objects are not aligned
>
> Obviously it's pointless to look for a causal relationship with these test
> data, but I'm curious if there's anything else I'm doing wrong, and anything
> I can do to test for the error before it raises.
With one lag, the full model has 3 parameters to estimate, constant
plus two lag parameters.
Because of the initial condition, using lags, we are loosing one
observation. So three parameters with 2 observations, if my
calculation is correct.
With 4 observations, we would have the same number of observations in
OLS as parameters to estimate. So, 5 is the minumum number of
observations to have (striclty) more observations than parameters in
the full OLS model. Most parts of OLS will require then at leas 5
observations in the granger causality tests to have a "standard"
problem.
I don't think we ever checked the various methods of OLS for the
minimal number of observation, it will vary by method, f_test, pinv,
...
So I'm not surprised that it breaks in this case at different places.
I would have to work my way through the code, to see why in this case
it breaks at a different point.
grangercausality is taking the results from OLS, and we would have to
check the behavior of the OLSResults methods if there is an
insufficient number of observations.
Briefly playing with some random samples, it looks like with 7
observations the different test statistics in grangercausality start
to agree.
Josef