My apologies if I have missed something, but I would like to ask
whether it is possible to extend genr in some way so as to provide
conditional definitions of variables. To give an illustration, in
Stata one can do the following:
gen ln_x = -10000 [where ln_x is a series]
replace ln_x = ln(x) if x > 0
This is very useful in a whole range of circumstances where one wants
to avoid the generation of missing values by handling the cases that
might generate them explicitly, but there are many other
circumstances where the syntax may be useful.
As far as I can work out, there are two ways of doing this in gretl
at present, both of them clumsy. One is by an explicit loop over
each of the elements of x with an if .. else .. endif. The other,
slightly more baroque method and not always possible, is to use
matrix functions combined with dummy variables.
The context in which I want to use something of this kind is in
writing a function to calculate residuals derived from a stochastic
frontier. In this case the calculation may fail because the divisor
is zero, but I know that the correct residual is 0 in such cases so I
would like to return zero rather than a missing value.
I use the syntax above very frequently when handling data in
Stata. As far as I understand from the manual Boolean constructs in
genr are restricted to the creation of dummy variables, so they do
not serve the purpose I have in mind.
Gordon Hughes