Re: [R] Need help on ARIMA (time series analysis)

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Mon 17 Oct 2005 - 07:05:34 EST

Regarding the loop, the code below:

> ws <- i
> we <- i+w-1
> temp <- th16k[ws:we]

can be written as:

  temp <- th16k[seq(i, length = w)]

or you can get rid of the loop entirely using embed or using running in package gtools or rapply in the zoo package.

> park wrote:
> > Hi,
> >
> > I am so novice in using R. I have some problems in my R script below
> > which fits time series data and predict it one-step ahead. Here is a
> > brief explanation on what I try to achieve
> >
> > Th16k is time series data (500 data points). The size of window for
> > fitting and predicting is 50 (data points). As you can easily discover
> > from my code, (fixed) window is moving/sliding to get next one-step
> > ahead prediction. The predicted value will be saved in pth.
> >
> > The problem is, every time I execute following script, I got error
> > saying
> >
> >
> >>source("C:\\R\\arima.R")
> >
> > Error in arima(temp, order = c(1, 0, 1)) :
> > non-stationary AR part from CSS
> >
> > I think there should be better way to achieve this goal without using
> > for loop. If you can share your knowledge, please advise me!!! :-)
> >
> > <-----------------------------------------------------------------------
> > ----------------------------->
> > w <- 50
> > pth <- th16k[1:w]
> > limit <- length(th16k)-w
> > for (i in 1:limit) {
> > ws <- i
> > we <- i+w-1
> > temp <- th16k[ws:we]
> > fit <- arima(temp, order=c(1, 0, 1))
> > pred <- predict(fit, n.ahead=1)
> > pth[i+w] <- pred$pred
> > }
> > plot(pth)
> > <-----------------------------------------------------------------------
> > ----------------------------->
> >
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

>

> --
> Spencer Graves, PhD
> Senior Development Engineer
> PDF Solutions, Inc.
> 333 West San Carlos Street Suite 700
> San Jose, CA 95110, USA
>

> spencer.graves@pdf.com
> www.pdf.com <http://www.pdf.com>
> Tel: 408-938-4420
> Fax: 408-280-7915
>

> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Oct 17 07:09:33 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 18:57:10 EST