On Tue, 9 Nov 2010, Sven Schreiber wrote:
Am 09.11.2010 13:58, schrieb Ofer Cornfeld:
> Hi,
>
>
>
> What is the best way to construct commands such as GMM commands on the fly?
>
> Assuming I have the string containing the GMM command to be executed,
> built from other strings or from input file
>
> How can I execute it?
>
One possibility in principle:
1. use the 'outfile' command
2. use 'print'/'printf' statements to write your gretl commands to the
chosen file
3. use the 'run' and/or 'include' commands to execute the resulting
script file
Sven's approach is most definitely the "right" one if you have several
commands. However, for shorter stuff the "@" operator is your friend. Try
this:
<script>
open data3-1
string cmd = "summary"
@cmd
</script>
Having said this, for the gmm command it's probably advisable to rely on
functions, as in the follwing example, which uses GMM to compute an
average :-)
<script>
function series orthcond(series x, matrix theta)
m = theta[1]
return x - m
end function
open data3-1
m = {0}
matrix V = I(1)
list Z = const
series e
gmm e = orthcond(sqft, m)
orthog e ; Z
weights V
params m
end gmm --verbose
</script>
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
r.lucchetti(a)univpm.it
http://www.econ.univpm.it/lucchetti