On Sat, 16 Jan 2016, Allin Cottrell wrote:
My test was admittedly kinda silly, in that there's not really
any reason to
delegate to a "foreign" program stuff that gretl handles well natively. One
would be more likely to get Julia to do MCMC or the like.
That said, among the various "foreign" programs on which I've tried the
notorious Longley exercise, only numpy comes close to gretl for numerical
precision. However, Anders makes a fair point in saying that the statistical
error (and I would add, data error) swamps the numerical error for this sort
of linear problem.
This is problaby more akin to a real-life case:
<hansl>
matrix X = mnormal(6,6)
mwrite(X, "X.mat")
foreign language=julia
function ReadGretlMat(fname)
moo = readdlm(fname);
rows = moo[1,1];
cols = moo[1,2];
v = Array(Float64,rows,cols);
[v[i] = convert(Float64,moo'[i+cols]) for i=1:cols*rows]
return(v');
end
function WriteGretlMat(A, fname)
r,c = size(A)
v = Array(Any,(r+1)*c);
v[1] = r;
v[2] = c;
[v[i] = "" for i=3:c];
[v[i+c] = A'[i] for i=1:r*c];
writedlm(fname,reshape(v,c,r+1)');
end
X = ReadGretlMat("X.mat");
WriteGretlMat(inv(X), "invX.mat");
end foreign
iX = mread("invX.mat")
check = X * iX
print check
</hansl>
(with apologies for my poor and non-idiomatic use of Julia --- but I'll
improve, promise).
In fact, I'm beginning to thing that we ought to provide a Julia package
("GretlLink"?) on
pkg.julialang.org for communication with gretl with
functions such as the above and more, ideally written by a specialist
(Andreas, are you interested?). So in practice, a "using GretlLink"
statement would be implicit every time we enter a "foreign" environment,
possibly preceded by a 'Pkg.Add("GretlLink")' if necessary.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------