Thanks for the tip. I think I've got the main message, though it looks a bit complicated.
I think it's worhtwile consider having vector accessors in comung versions of Gretl, also for test where you 'test down'. Thanks Torben Citat Allin Cottrell <cottrell(a)wfu.edu>: > > 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 > _______________________________________________ > Gretl-users mailing list > Gretl-users(a)lists.wfu.edu > http://lists.wfu.edu/mailman/listinfo/gretl-users > ***************************************************************** Torben Schmith Senior scientist Center for Ocean and Ice Danish Meteorological Institute Lyngbyvej 100 DK-2100 Copenhagen Ø DENMARK Phone direct : +45 39 15 74 44 Phone switch : +45 39 15 75 00 Fax : +45 39 15 73 00 E-mail : ts(a)dmi.dk Homepage : http://ocean.dmi.dk/staff/ts/ts.html *****************************************************************