[Gretl-devel] Re: gretl functions and lists
Riccardo (Jack) Lucchetti
r.lucchetti at univpm.it
Mon Jul 14 06:56:56 EDT 2008
On Mon, 14 Jul 2008, Gordon Hughes wrote:
> I would like to respond to Allin's note by drawing upon my experience of
> writing a variety of functions over the last 2-3 weeks. In doing this I was
> aware of the dangers of overwriting existing variables when returning a list
> of variables created in the functions. Hence, I would certainly favour the
> separation implied by the adoption of the PROTECT_LISTS 1 option.
>
> But, I have a further point that I would like to raise.
[... snip ...]
I agree the extension you propose would be nice. However, the underlying
machinery which deals with the dollar accessors doesn't lend itself to
accommodate it easily. Maybe using pointers is easier. Here's a small
proof-of-concept script:
<script>
function reverse_ols(series y, list X, matrix *rcoeff, series *rres)
ols y X --quiet
rcoeff = -$coeff
rres = -$uhat
end function
open data4-1
list reg = const sqft bedrms baths
ols price reg
u = $uhat
matrix foo
series bar
reverse_ols(price, reg, &foo, &bar)
print u bar -o
</script>
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
r.lucchetti at univpm.it
http://www.econ.univpm.it/lucchetti
More information about the Gretl-devel
mailing list