Discussion:
[Gretl-users] Applying an ARIMA Model
Oliver Heering
2009-08-31 22:31:39 UTC
Permalink
Hi,

coming from data mining and machine learning i have the following
question which may or may not sound stupid for you, but as i have no
clue and there are no stupid questions (just stupid answers) i take my
chance posting the question to this list:

I already figured out how to fit an ARIMA process to my data (ok, how
to actually find GOOD AR/MA/difference orders would be another
question). And i can save the resulting model as Icon to my session.
Does that mean i can also apply my model to any other data (of the
same type of course)? Let's say i fit my model against a timeseries
range A. How can i find out how my model fits to another timeseries
range B?

Maybe this isn't possible at all and i am misunderstanding the whole
concept of ARIMA models and -forecasting. I am primary working with
the data mining tool "RapidMiner", which allows you to easily apply
any learned model to new and unseen data (classification mainly, but
regression as well) and i wonder if it is the same with an estimated
ARIMA model.

Thanks (again) for any answer. :-)

By the way, i appreciate that case markers can now be up to 15 chars
in length, but what are they actually used for? Of course i'd like to
have them show up on my plots, which i currently do by manually
tweaking the gnuplot commands, but i think this functionality is still
missing in gretl, am i correct? So what's left? Is there any practical
use-case for case markers in timeseries analysis?
--
Oliver
Allin Cottrell
2009-08-31 23:37:57 UTC
Permalink
Post by Oliver Heering
coming from data mining and machine learning i have the
following question which may or may not sound stupid for you,
but as i have no clue and there are no stupid questions (just
stupid answers) i take my chance posting the question to this
Fine.
Post by Oliver Heering
I already figured out how to fit an ARIMA process to my data
(ok, how to actually find GOOD AR/MA/difference orders would be
another question). And i can save the resulting model as Icon to
my session. Does that mean i can also apply my model to any
other data (of the same type of course)? Let's say i fit my
model against a timeseries range A. How can i find out how my
model fits to another timeseries range B?
Maybe this isn't possible at all and i am misunderstanding the
whole concept of ARIMA models and -forecasting. I am primary
working with the data mining tool "RapidMiner", which allows you
to easily apply any learned model to new and unseen data
(classification mainly, but regression as well) and i wonder if
it is the same with an estimated ARIMA model.
In the gretl GUI, an existing model is in effect defined by an
estimation method (e.g. ARIMA). On opening a saved model you can
use the menu item "/Edit/Modify model..." in the model window to
create a new, related model. You can substitute a new dependent
variable, and/or edit the list of regressors, and/or tweak things
such as the lag order.

In a gretl script, there's no limit to the extent to which you can
use an existing model as the basis for a new one. Just copy,
paste and edit.
Post by Oliver Heering
By the way, i appreciate that case markers can now be up to 15
chars in length, but what are they actually used for? Of course
i'd like to have them show up on my plots, which i currently do
by manually tweaking the gnuplot commands, but i think this
functionality is still missing in gretl, am i correct? So what's
left? Is there any practical use-case for case markers in
timeseries analysis?
With time-series data there's little or no use for case markers,
since the general assumption is that date strings should be used.
Case markers are most useful for cross-sectional data where
otherwise the observations would be anonymous.

Allin Cottrell
Sven Schreiber
2009-09-01 07:44:49 UTC
Permalink
Post by Allin Cottrell
Post by Oliver Heering
I already figured out how to fit an ARIMA process to my data
(ok, how to actually find GOOD AR/MA/difference orders would be
another question). And i can save the resulting model as Icon to
my session. Does that mean i can also apply my model to any
other data (of the same type of course)? Let's say i fit my
model against a timeseries range A. How can i find out how my
model fits to another timeseries range B?
Maybe this isn't possible at all and i am misunderstanding the
whole concept of ARIMA models and -forecasting. I am primary
working with the data mining tool "RapidMiner", which allows you
to easily apply any learned model to new and unseen data
(classification mainly, but regression as well) and i wonder if
it is the same with an estimated ARIMA model.
In the gretl GUI, an existing model is in effect defined by an
estimation method (e.g. ARIMA). On opening a saved model you can
use the menu item "/Edit/Modify model..." in the model window to
create a new, related model. You can substitute a new dependent
variable, and/or edit the list of regressors, and/or tweak things
such as the lag order.
See Allin how cool this feature is? ;-)
Post by Allin Cottrell
In a gretl script, there's no limit to the extent to which you can
use an existing model as the basis for a new one. Just copy,
paste and edit.
Actually, I thought that what Oliver had in mind when he spoke of a
model was the estimated coefficients as well, not "just" the general
specification. Then it wouldn't be so easy I guess, because a saved
model in gretl terms is tied to the used data sample as well, right?

But maybe I didn't understand him correctly...

cheers,
sven
Oliver Heering
2009-09-01 10:54:15 UTC
Permalink
Post by Sven Schreiber
Post by Allin Cottrell
In a gretl script, there's no limit to the extent to which you can
use an existing model as the basis for a new one. ?Just copy,
paste and edit.
Actually, I thought that what Oliver had in mind when he spoke of a
model was the estimated coefficients as well, not "just" the general
specification. Then it wouldn't be so easy I guess, because a saved
model in gretl terms is tied to the used data sample as well, right?
But maybe I didn't understand him correctly...
Yes, you are correct. With RapidMiner for example your saved model is
ready to use with any new data of the same type the model was created
with. It works like a blackbox that is feeded with data and magically
spits out the corresponding estimation (e.g. the class for
classification tasks or the number value for regression tasks). The
model stores all its coefficients, so you don't have to do anything
other than to say "apply my ready-to-use model on this and that data".

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. :-)
--
Oliver
Sven Schreiber
2009-09-01 11:58:28 UTC
Permalink
Post by Oliver Heering
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 the GUI model window, I don't know if it's possible, I doubt it.

-sven
Allin Cottrell
2009-09-01 15:52:22 UTC
Permalink
Post by Sven Schreiber
Post by Oliver Heering
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.

Allin Cottrell
Allin Cottrell
2009-09-01 17:18:51 UTC
Permalink
Post by Allin Cottrell
Post by Sven Schreiber
Post by Oliver Heering
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.
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
Oliver Heering
2009-09-01 17:30:54 UTC
Permalink
Thanks a lot, will try that. :-)
Post by Allin Cottrell
Post by Allin Cottrell
Post by Sven Schreiber
Post by Oliver Heering
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.
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
<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.
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 at lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users
--
mfg,
Oliver
Continue reading on narkive:
Loading...