I've been using gretl for a recent project and I have a couple of
quesions/observations about syntax.
In Allin's code snippet below, why would you use means[i] instead of
means[$i] in the loop. I've used
loop i=start..end
$i
endloop
which seems to work with one letter loop variables, i, j, k, etc., but not
loop iloop=start..end
$iloop
endloop
when "iloop" is not recognized. With that I had to construct a
scalar iloop=start-1
loop while iloop < end
iloop=iloop+1
iloop
endloop
Also, my current script is a couple of hundred lines long with a couple
of big loops. If I run the script and there's an error, sometimes I
cannot "recover" the script because it's stopped in the middle and left
something "hanging" so that if I correct the error and re-run, the
script doesn't actually run, the output is simply a list of the script.
I just kill the session and re-start, which works. Is there a different
method for killing the script. A couple of times I highlighted "endloop"
and ran just that, which caused gretl to crash.
I also noticed that if X is a matrix
X[i,j]^(exponent)
does not work, when
temp=X[i,j]
temp^(exponent)
is necessary.
Finally, my data set consists of 15146 cross-sectional units with
varying observations over time. Monthly data within the interval 1962:01
through 2007:12. Any way to get gretl to recognize a pattern like this
as some sort of panel?
Thanks.
Rob
Allin Cottrell wrote:
On Fri, 7 Nov 2008, Rebecca Zhang wrote:
> I have time series data for 50 variables. I want to calculated
> the mean for each variable and store the data as a cross-section
> dataset that has two columns: one for 50 means and one for their
> correpeponding varibles.
Sorry, I don't understand: the first (new) column is to contain 50
means, but what is the second column to contain?
You can create a series that contains the means of the variables
in the current dataset (provided the number of variables is not
greater than the number of observations) using something like:
list L = dataset
series means = 0
loop foreach i L
means[i] = mean($i)
endloop