A quick follow-up with another error.
As part of trying to figure out the
initial error, I moved the nulldata command inside the first loop and got an
error saying it’s not available in loop mode. Ok, but moving ‘nulldata’ back to
where it initially was now results in the same error (ie, gretl still thinks
nulldata is inside the first loop). Closing the script & reopening doesn’t
help.
PS
From:
gretl-users-bounces@lists.wfu.edu [mailto:gretl-users-bounces@lists.wfu.edu] On Behalf Of
Sent: Tuesday, February 02, 2010
1:25 PM
To:
Subject: [Gretl-users] scalar in
loop condition
Hi folks,
The following has me at a complete loss. This script runs
fine:
\begin{script}
# program to perform calculations in problem 1.2 of Davidson
& MacKinnon
nlist = {10; 100; 1000; 10000}
n = rows(nlist)
means = zeros(n,2)
loop i=1..n --quiet
jnk1 = cauchy(nlist[i])
jnk2 = mnormal(nlist[i],1)
means[i,] = {meanc(jnk1), meanc(jnk2)}
endloop
print means
\end{script}
(“Cauchy” is a function I wrote – see attached).
However, when I try to run the following one, I get an error
saying “undefined variable nreps in loop condition”. This happens even though
the script output says “generated scalar nreps = 1:”
\begin{script}
n = 25; # sample size
nreps = 1; # number of replications
beta1 = 1;
beta2 = 0.8; # true values of parameters
b1 = 0;
b2 = 0;
nulldata n
loop ii=1..nreps
# simulate data
series y = zeros(n,1)
series u = normal()
#y[1] = beta1 + u[1]
loop jj=2..n --quiet
y[jj] = beta1 +
beta2[jj-1] + u[jj]
endloop
series y1 = y(-1)
# run regression
ols y 0 y1
b1 = b1 + $coeff(1)
b2 = b2 + $coeff(2)
print b1 b2
endloop
\end{script}
I’ve attached both scripts. Note that I’ve just started on
ETM_3_1, so there may well be other errors (still getting used to gretl
scripts). I can’t for the life of me figure out why either both work or both
don’t run. I’m using gretl 1.8.7 on WinXP.
TIA,
PS
===============================
Dr. Peter Summers
Assistant Professor
Department of Economics
===============================