That's interesting and useful -- thanks for the test script, I will use that from now on. I must have made a mistake in compiling my test C program then.

On Sat, Jul 26, 2014 at 4:20 PM, Allin Cottrell <> wrote:
On Sat, 26 Jul 2014, Al wrote:

> Hello everybody and thanks for your work on gretl.
> I am experimenting in porting parts of libgretl to javascript via
> emscripten. After a couple of afternoons i have been able to "compile" to
> javascript some unit root tests, mostly thanks to some kind soul who did
> the same for GMP and mpfr and posted their work to github.
> My first intent was to verify if there are differences in the output from
> the C and JS versions, and the only one I could find is this, in adf_test()
> :
> 59c59
> <   lagged differences: F(3, 5) = 0.395 [0.7626]
> ---
>>   lagged differences: F(3, 5) = 0.344 [0.7954]
> 80c80
> <   lagged differences: F(3, 4) = 20.327 [0.0070]
> ---
>>   lagged differences: F(3, 4) = 1.297 [0.3904]
> (all other results, pvalues, statistics and values were the same btw)
> The results were created using the dataset generated in simple_client.c ;
> the only relevant change I've made is stitching some plugin code in the
> main code in order to avoid using dlopen() (which didnt work well in
> emscripten). I then ran adf_test() and kpss_test() on the same dataset.
> I was wondering if you had any insights into this small discrepancy; are
> the lagged differences computed using GMP or lapack? I am thinking it is a
> CLAPACK+emscripten+different architecture issue.
> Output for both versions is attached.

OK, the differences pertain to the F-tests on the 3 lagged differences in
an augmented DF test of order 3 on the second variable in this dataset,
"sqft". Here is a small script that replicates the analysis in gretl
itself, using the built-in adf command and then doing the ADF regression

open data4-1
setobs 1 1 --time-series
adf 3 sqft
diff sqft
ols d_sqft 0 sqft(-1) d_sqft(-1 to -3)
omit d_sqft_1 d_sqft_2 d_sqft_3 --test-only

The results agree with your OUTPUT_FROM_JS. I don't know where the errors
are coming from in your OUTPUT_FROM_C.txt. GMP is certainly not used in
this analysis, and I don't think lapack should get involved either.

For good measure, I also tried running a C program (based on
simple_client.c and linked against libgretl) which calls adf_test() as

list[0] = 1;
list[1] = 2;
int err = adf_test(3, list, dataset, OPT_NONE, prn);

This gives output in agreement with gretl istelf, and your JS output.

Allin Cottrell

Gretl-devel mailing list