On Thu, 11 Oct 2007, Allin Cottrell wrote:
In case it's helpful, I'm putting below a script that solves
a
simpler but related problem, namely printing an F-test for the
hypothesis that the variance is the same, for some given variable,
in the first and second halves of the sample. A couple of
comments follow.
<gretlscript>
function vfun (series y)
set messages on
set echo on
scalar n2 = $nobs/2
smpl ; -n2
n1 = $nobs - 1
v1 = var(y)
smpl --full
smpl +n2 ;
n2 = $nobs - 1
v2 = var(y)
printf "v1 = %g, v2 = %g\n", v1, v2
Ft = (v1 > v2)? v1/v2 : v2/v1
pval = pvalue(F, n1, n2, Ft)
printf "F(%d,%d) = %g, p-value %g\n", n1, n2, Ft, pval
return scalar pval
end function
[ ... ]
(2) Unfortunately there's an annoying bug in smpl, whereby a "-"
indicating retard-the-sample-end-or-start gets confused with the
"-" that precedes an option flag. The form I used above, "-n2",
happens to be a lucky string that doesn't trigger the problem.
(I think the solution to this is to insist that the options to
smpl be given in their full form, with two dashes. I'll fix that
for gretl 1.6.6.)
Bug or feature?
I personally like the short form for options, and I'm a bit wary of
"exceptions". I'd keep things as they are now and use a string
substitution trick instead, as in
sprintf foo "-%d", $nobs/2
smpl ; @foo
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
r.lucchetti(a)univpm.it
http://www.econ.univpm.it/lucchetti