[R] ts startdate

Gregor Gawron gregor.gawron at rmf.ch
Fri Dec 6 17:09:18 CET 2002


Hi Dirk and Paul,

Thank you very, very much. Both methods seem to work excellent. You have
saved my weekend.
Paul, it sounds great that you are updating the dse package. I have
downloaded your documents a few weeks ago and had a look at them. There
were some issues I did not fully understand. As soon as I will have
completed the univariate project I will start with multivariate models,
which is scheduled to the beginning of next year. Then, I will give me
more time to understand it better and will surely return with some
questions.
Thanks again
Gregor
     



--------------------------
Gregor 

If my.length+6 was 15 you would do something like this.

 ts(1:20, start = c(1980 + 15 %/% 12 , 15 %% 12), frequency=12)

BTW, you might want to look at the functions featherForecasts and
horizonForecasts in package dse2 in the dse bundle on CRAN. (These may
be called feather.forecasts and horizon.forecasts in the version
currently on CRAN, I've changed some names recently. I hope to have a
new version out in a few weeks.) These do things very close to what you
appear to be trying, but the looping is done in the underlying fortran
code, so it is a lot faster.

Paul Gilbert

-----------------------


I typically use offsets relative to tsp() output which is already in the
fractional format of year + 1/12*(months-1) whereas using the
c(year,month) notation has wrap-around issues.

The following (contrived) example works:

> Zbase<-ts(rnorm(110),start=c(1993,1),frequency=12)
> tsp(Zbase)
[1] 1993.000 2002.083   12.000
> for (i in 1:24) 
> Zfcast<-ts(rnorm(110),start=tsp(Zbase)[2]+i/12,frequency=12)
> 

With that construct you can go any number of month past, or prior, a
given date.

Hope this helps,  Dirk

-----Original Message-----
From: Gregor Gawron 
Sent: Freitag, 6. Dezember 2002 15:39
To: r-help at stat.math.ethz.ch
Subject: [R] ts startdate


Dear R-users,

I am facing a trivial problem when trying to parameterise the start date
of a time series object. I am working with monthly data (104) performing
n-steps-ahead (6) forecasts and using a fixed window size (36). At the
end of calculations I have a list  that contains 69 forecasts. I have no
problems in fixing the window size by parametrization, e.g.

k<- control variable in a for loop
my.length<-36
past<-window(X,start=c(1980,k - my.length + 1),end=c(1980,k))

The integer defining the month number can be arbitrary set to: 6,16,46
etc and it always works. This, however, does not work when I try to
parameterise the start date of the result list

my.forecasts<-unlist(my.result.list) 
my.forecast.results<-ts(my.forecasts,start=c(1980,my.length+6),frequency
=12)

The message I recive is:

Error in ts(my.frecasts, start = c(1980, my.length + 6), frequency = 12)
: 
        invalid start

It seems that it works only for month integer up to 12. Does someone
know how to overcome this problem? Many thanks in advance.

I am using R 1.5.1 on Windows 2000




---
Gregor Gawron

______________________________________________
R-help at stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list