cross-sectional mean, variance
by Allin Cottrell

Serendipitous fallout from adding lists to genr.
It turns out that two of my students this semester are working on
research papers dealing with convergence or non-convergence (of
GDP per capita among ASEAN countries in one case, and of
employment characteristics among US cities in the other).
There are several ways of assessing convergence, but one nice
simple way to start is to create a time-series plot of the
cross-sectional variance (or coefficient of variation, perhaps)
of the variable of interest. Sigma-convergence, it's called: does
the variance show a declining trend, or what?
You can compute this in gretl, but it's a bit fiddly because gretl
is "column-oriented". Suppose you have a time-series data set
with GDP for k countries or regions represented as k distinct
variables. You can compute the desired time-series of
cross-sectional variance by (a) transposing the data set or (b)
stacking the data into a panel then looping across sub-samples
restricted by year. Perfectly do-able but a bit daunting for a
beginner.
Lists to the rescue. I've extended the functions mean(), sd() and
var() so that if you supply a list argument the result is a series
each of whose values is the cross-sectional statistic for the
listed variables in the given period.
Here's an example illustrating strong sigma-convergence of per
capita income across the regions of the US from the onset of the
second world war till around 1980. (Run in the GUI when connected
to the internet, and I hope you'll agree it's quite cool.)
<script>
# open US state/regional database on server
open beapira --www
setobs 1 1929 1973
# d/l regional income per capita
data a91200 a92200 a93200 a94200 a95200 a96200 a97200 a98200
list L = a*
# cross-sectional mean, std. dev., coeff of variation
genr Lm = mean(L)
genr Ls = sd(L)
genr Lcv = Ls/Lm
# print results
print Lm Ls Lcv --byobs
# time series plot of coeff of variation
convplot <- gnuplot Lcv time --with-lines \
{ set title "See the convergence?"; }
convplot.show
</script>
--
Allin Cottrell
Department of Economics
Wake Forest University, NC
16 years, 8 months

matrix from null list
by Sven Schreiber

I propose that the following should work in order to make generic code
possible; the matrix should be simply empty ({}).
list myl = null
matrix checkmat = { myl }
thanks,
sven
16 years, 8 months

changes regarding genr and lists
by Allin Cottrell

Fairy long, I'm afraid, but probably worth reading if you do a lot
of scripting, particularly with lists or matrices.
In working on some scripts lately I've been building lists using
the syntax
list foo = null
loop <something>
...
list foo += varname
...
endloop
This works OK, but I kept forgetting to say "list foo += .."
rather than just "foo += ...". The result was an "unknown
variable in command" error message, which I found confusing at
first, then annoying. (Appearing on the left-hand side of a
genr-type expression, "foo" was not recognized as the name of
anything, unless you prompted gretl to look for lists with the
"list" keyword.)
So I've made a start on incorporating lists into the genr
mechanism more fully. You no longer have to repeat "list" in
front of listnames, as above. Once a list is created, you can add
to it, subtract from it, or redefine it, just using its name.
While working in this area I discovered a bug or two in genr.
For example, up till today, if you typed
scalar x = 3 4
you'd get a scalar x with value 3 and no error message, despite
the syntactically incorrect trailing " 4". No more. Now, one or
more spaces between variables or constants in a genr formula (with
no intervening operator or punctuation) has a specific meaning,
namely, concatenation of list elements. So, the following is OK:
list xlist = 1 2 3
xlist += 4 5 6
But "scalar x = 3 4" will produce an error: it's trying to assign
a list to a scalar.
One side effect is worth noting. According to the manual, the way
to create a matrix out of data series is, e.g.,
matrix m = { x1, x2, x3 }
with the names of the series separated by commas. Up till now,
however, this would also work:
matrix m = { x1 x2 x3 }
This was just sloppiness, and it won't work any more.
The other bug I found was the possible masking of lists by scalars
or series. E.g.
list X = x1 x2 x3
X = log(x1)
The second command would go through without flagging any error:
you'd get a variable named X, but the list named "X" would now be
inaccessible. This can't happen any more:
open data4-10
list X = 1 2 3
X = log(ENROLL)
> Data types not conformable for operation
However, if you replace the third line with
list X = log(ENROLL)
you get the effect you might expect, namely, replacing the
original list with a new one that has one element,
l_ENROLL.
There are no doubt some new issues introduced by this change
that will need to be hashed out. But the warning I gave earlier
about the state of CVS related to breakage of previously valid
uses of genr, and I believe that problem is now fixed.
Allin.
16 years, 8 months

is loop_maxiter really honored?
by Sven Schreiber

I'm not complaining when gretl is tolerant, but I'm really wondering why
the following script works in the sense that all 20 loop iterations are
performed, when I thought it should be interrupted after 10:
set loop_maxiter 10
i=1
loop 20
print i
i = i+1
end loop
thanks,
sven
16 years, 8 months

vecm --quiet behavior
by Sven Schreiber

I just found out that 'vecm' supports the --quiet option, which is
useful for me. But that leads to some questions:
- Apparently it's not documented, or am I missing something? I could try
to add that.
- Is --quiet available for all estimation commands? If it is, it also
doesn't seem to be documented (apart from ols). If not, the feature
would be useful for all estimators I guess.
- vecm --quiet still prints beta, alpha, and the cov-matrix omega. Is it
feasible to also support some sort of --silent option that doesn't print
anything (apart from errors of course)? The same question would apply to
all estimation commands, actually.
thanks,
sven
16 years, 8 months

matrix indexing error message?
by Sven Schreiber

Hi,
I don't get any error message when trying to index matrices beyond their
actual dimensions, see the example script below. Don't know if it's a
bug or a missing feature but the information would be very helpful for
debugging (as I just learned the hard way)...
thanks,
sven
open denmark
matrix check = I(4)
tix = 1
loop while tix<=5
print tix
matrix my = check[5,]
tix = tix + 1
end loop
16 years, 8 months

Feature Request 1886987
by Allin Cottrell

Ignacio writes:
> I think may be useful to have a command that clears the series
> in the dataset without deleting from memory the currently
> defined matrices. This will do easier to deal with data in
> different disagregation periods.
> It can be also convenient to have a text command equivalent to
> /File/clear dataset, and another text command equivalent to
> /File/Append data
The simple point first: the "append" command does what
/File/Append data does.
As for clearing data, I've put some experimental things is place.
For the script equivalent of "/File/Clear data set" I've added a
"clear" argument to the "dataset" command. That is, you say
dataset clear
But this has a "preserve" option:
dataset clear --preserve
which has the effect that existing named matrices are not
destroyed.
Similarly, the commands "open" and "nulldata" have a --preserve
option: clear most stuff out, but keep matrices.
At present the --preserve option does not have a GUI counterpart.
Allin.
16 years, 8 months

auto indent
by Sven Schreiber

Some small feedback about the new "smart" script editor:
when I type 'function'+<return> in a script file with existing
functions, 'function' gets indented, a bug IMHO.
-sven
16 years, 9 months

crash with fdjac
by Sven Schreiber

The example script below crashes gretl every time (on linux with the cvs
version from a couple of days ago).
Note that the embedded function call in the string argument of fdjac is
missing one required argument.
Let me know if there is currently no time to address this, then I will
file it in the bug tracker.
thanks,
sven
<script>
function getGGcoeffvec(const matrix coeffvec, const matrix beta_starmat,\
int numendo, int lagorder, int determcase, int numuexo, int numrexo)
matrix result = vec(I(2))
return matrix result
end function
open denmark
lagorder = 2
cirank = 1
determcase = 3
numendo = 4
numrexo = 0
numuexo = 0
matrix beta_starmat = ones(4,1)
matrix coeffvec = vec(I(3)) # just a dummy for illustration
matrix GGcoeffvec = getGGcoeffvec(coeffvec,beta_starmat,\
numendo,lagorder,determcase,numuexo,numrexo)
matrix GGvecjacmat = fdjac(coeffvec, "getGGcoeffvec(coeffvec,beta_starmat,\
numendo,lagorder,determcase,numuexo)") # note the missing numrexo arg!
</script>
16 years, 9 months