On Wed, 31 Mar 2010, Torben Schmith wrote:
I want to do Monte-Carlo simulations with the Johansen cointegration
test. However, as far as I can see the $value and $test are not assigned
new values when this test is carried out.
My question is if there is any way I can can get hold of the test output
(as variables) from the Johansen test? I can't find anything on this
issue in the Gretl-documentation.
Hmm, the trouble is that the Johansen cointegration test produces
an array of statistics (the lambda-max and trace tests for various
hypotheses), so it can't be put into the framework of a pair of
scalars ($test, $pvalue). I suppose the best thing would be to
enable a matrix accessor after this test.
In the meantime, however, it is possible to retrieve the test
matrix using gretl's string-handling facilities. I illustrate this
below (in somewhat rough and ready fashion), but note that for
this to work you will need current CVS or snapshot, where we have
some improvements in the sscanf function. The strategy is to write
the test results out to file, then parse that file from within
gretl.
<script>
open denmark
scalar r = 2
outfile "jtest" --write
coint2 r LRM LRY
outfile --close
matrix Jmat = zeros(r, 6)
string jtest = readfile("jtest")
string tmp
scalar x1 x2 x3 x4 x5 x6
# get to the start of the test matrix
jtest = strstr(jtest, "Rank")
sscanf(jtest, "%128[^\n]", tmp)
jtest = jtest + strlen(tmp) + 1
sscanf(jtest, "%128[^\n]", tmp)
jtest = jtest + strlen(tmp) + 1
sscanf(tmp, "%lf %lf %lf [%lf] %lf [%lf]", \
x1, x2, x3, x4, x5, x6)
Jmat = {x1, x2, x3, x4, x5, x6}
sscanf(jtest, "%128[^\n]", tmp)
tmp = jtest + strlen(tmp) + 1
sscanf(tmp, "%lf %lf %lf [%lf] %lf [%lf]", \
x1, x2, x3, x4, x5, x6)
Jmat |= {x1, x2, x3, x4, x5, x6}
print Jmat
</script>
Allin Cottrell