Thanks a lot, will try that. :-)
On Tue, Sep 1, 2009 at 7:18 PM, Allin Cottrell<cottrell(a)wfu.edu> wrote:
On Tue, 1 Sep 2009, Allin Cottrell wrote:
> On Tue, 1 Sep 2009, Sven Schreiber wrote:
>
> > Oliver Heering schrieb:
> >
> > > The thing in gretl is, if i want to see how my estimated (on series A)
> > > model performs on series B, i don't know how to actually do this
> > > without fitting the model again, since i believe what Sven wrote: "a
> > > saved model in gretl terms is tied to the used data sample as well".
> > >
> > > Please correct me, if i'm wrong. :-)
> >
> > Well in a script you can of course retrieve and store the coefficient
> > vector of your model ($coeff) for further use. That wouldn't be so
> > difficult, but it's not a one-liner.
>
> In script mode you can do this sort of thing:
>
> open data9-7
> series y = QNC
> arma 1 1 ; y
> fcast yd1 --dynamic
> y = INCOME
> fcast yd2 --dynamic
>
> After replacement of the series "y", the series yd2 will contain
> dynamic forecasts for INCOME using the model estimated for QNC.
> This won't work for static forecasts because in that case gretl
> just outputs the fitted values that are saved with the original
> model. But dynamic forecasts are generated de novo so you can
> "trick" gretl into using a different series.
I should perhaps point out that the task in hand here is easily
performed for linear models, as shown below.
<script>
list X = 0 INCOME PRIME QNC(-1)
ols QNC X
matrix b = $coeff
# switch QNC -> STOCK
X = 0 INCOME PRIME STOCK(-1)
# use padding zeros to cover the missing lag
matrix Xm = zeros(1,4) | { X }
Xm
series yh = Xm*b
print yh
</script>
This script generates, in yh, a fitted series for the STOCK
variable using the model estimated on QNC.
With ARIMA models it's trickier, and in fact (on second thoughts)
I'm not quite sure what would count as "correct" output for
a forecast for z based on an ARIMA model for y. However,
if you're so inclined you can now (you'll need CVS or the current
Windows snapshot) do this piece of trickery:
<script>
open data9-7
arma 1 1 ; QNC
matrix b = $coeff
set initvals b
set bfgs_maxiter 0
arma 1 1 ; STOCK --opg
series yh2 = $yhat
</script>
The essential ingredient is "set bfgs_maxiter 0" (newly
permitted), which prevents the BFGS maximizer from making any
changes in the coefficients given via "set initvals". This gives
you a "fake" ARMA model for any variable you like using the
exact coefficients from some reference model.
Note that the --opg flag is required to avoid getting an error:
the default is to calculate standard errors using the Hessian, but
that will be a big mess in such a case.
Allin Cottrell
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users