[R] using forecast() in dse2 with an ARMA model having a trend component

Waichler, Scott R Scott.Waichler at pnl.gov
Tue Jun 14 19:38:02 CEST 2005


(My apologies if this is a repeated posting.  I couldn't find any trace
of my previous attempt in the archive.)  

I'm having trouble with forecast() in the dse2 package.  It works fine
for me on a model without a trend, but gives me NaN output for the
forecast values when using a model with a trend.  An example:

# Set inputs and outputs for the ARMA model fit and test periods
arma.fit.input <- c(105.3332, 105.3573, 105.3113, 105.1493, 105.1209,
105.2111, 104.9161,
                    105.3654, 105.4682, 105.6789, 105.6297, 106.0155,
105.8454, 105.4322,
                    105.6062, 106.0739, 106.1109, 105.4470, 104.9739,
105.3427, 105.4305,
                    105.2563, 104.8501, 105.0358, 105.2827, 104.8977)

arma.fit.output <- c(106.0376, 106.0514, 106.0716, 106.0570, 106.0442,
106.0414, 106.0375,
                     106.0169, 106.0268, 106.0670, 106.1169, 106.1544,
106.1898, 106.2252,
                     106.2605, 106.2959, 106.3324, 106.3974, 106.3460,
106.2357, 106.1897,
                     106.1811, 106.1556, 106.1130, 106.0805, 106.0791)

arma.pred.input <- c(104.9916, 104.8207, 104.8936, 104.8767, 104.9435,
104.8885, 104.9217,
                     104.9029, 104.9508, 105.0065, 105.0557, 105.1982,
105.3392, 105.4007,
                     105.6212, 105.5979, 105.2410, 105.4832, 105.8735,
105.5944, 105.1063,
                     104.9809, 105.0821, 104.9362, 105.3037, 105.2322)
arma.pred.output <- c(106.0528, 106.0293, 106.0053, 105.9850, 105.9697,
105.9604, 105.9509,
                      105.9430, 105.9357, 105.9314, 105.9333, 105.9420,
105.9640, 105.9994,
                      106.0290, 106.0855, 106.1265, 106.1197, 106.1245,
106.1893, 106.2118,
                      106.1503, 106.0883, 106.0511, 106.0194, 106.0221)

# Set TSdata object
arma.fit.TSdata <- TSdata(input = arma.fit.input, output =
arma.fit.output)

# Fit the model
arma.model.without.trend <- estVARXls(arma.fit.TSdata, max.lag=1,
trend=F)
arma.model.with.trend    <- estVARXls(arma.fit.TSdata, max.lag=1,
trend=T)

# Apply the model for the test period
arma.pred.TSdata <- TSdata(input = arma.pred.input, output =
arma.pred.output[1:2]) arma.pred.without.trend <-
forecast(TSmodel(arma.model.without.trend), arma.pred.TSdata)
arma.pred.with.trend    <- forecast(TSmodel(arma.model.with.trend),
arma.pred.TSdata)

The results:
> arma.pred.without.trend$forecast[[1]][,1]
 [1] 106.0038 105.9789 105.9605 105.9396 105.9224 105.9052 105.8926
105.8849  [9] 105.8812 105.8880 105.9043 105.9240 105.9579 105.9878
105.9901 106.0095 [17] 106.0555 106.0782 106.0644 106.0427 106.0297
106.0072 106.0126 106.0125
> arma.pred.with.trend$forecast[[1]][,1]
 [1] 5.76056e+228          NaN          NaN          NaN          NaN
 [6]          NaN          NaN          NaN          NaN          NaN
[11]          NaN          NaN          NaN          NaN          NaN
[16]          NaN          NaN          NaN          NaN          NaN
[21]          NaN          NaN          NaN          NaN

I read help on this function and the PDF manuals but can't see what I
might be missing.  
Any ideas?  

Thanks, Sott Waichler
Pacific Northwest National Laboratory
scott.waichler at pnl.gov




More information about the R-help mailing list