Flávio Fagundes
2011-Jun-21 04:21 UTC
[R] function to undo the DIFF command in ARIMA command
Hi users. I'm new user in R. I'm workiing with Time series and I would like to know how can I do to undo the command DIFF(X), for exemple: If I have the model: m=arima(X, order=c(0,1,1), seasonal=list(order=c(0,0,1))) (note that have d=1 one difference), to find, in the same scale, the original numbers (like one "unDiff"), after the forecast, I need to develop some function or in R there is some command ready or function? Thanks Flávio [[alternative HTML version deleted]]
Jeff Newmiller
2011-Jun-21 05:08 UTC
[R] function to undo the DIFF command in ARIMA command
cumsum, but you have to add back the information lost in the diff operation by generating an extra zero at the beginning or end of the sequence and adding the appropriate offset to the resulting vector. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. "Flávio Fagundes" <flavio2f@gmail.com> wrote: Hi users. I'm new user in R. I'm workiing with Time series and I would like to know how can I do to undo the command DIFF(X), for exemple: If I have the model: m=arima(X, order=c(0,1,1), seasonal=list(order=c(0,0,1))) (note that have d=1 one difference), to find, in the same scale, the original numbers (like one "unDiff"), after the forecast, I need to develop some function or in R there is some command ready or function? Thanks Fl�vio [[alternative HTML version deleted]] _____________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]]
(Ted Harding)
2011-Jun-21 07:15 UTC
[R] function to undo the DIFF command in ARIMA command
On 21-Jun-11 04:21:08, Fl?vio Fagundes wrote:> Hi users. > I'm new user in R. > I'm workiing with Time series and I would like to know how > can I do to undo the command DIFF(X), for exemple: > If I have the model: m=arima(X, order=c(0,1,1), > seasonal=list(order=c(0,0,1))) > (note that have d=1 one difference), to find,in the same scale, > the original numbers (like one "unDiff"), after the forecast, > I need to develop some function or in R there is some command > ready or function? > Thanks > Fl?vioConsider the sequence X = x1, x2, x3, x4 diff(X) = (x2-x1), (x3-x2), (x4-x3) cumsum(diff(X)) = (x2-x1), (x3-x1), (x4-x1) c(x1, x1 + cumsum(diff(X)) ) = x1, x2, x3, x4 So, provided you have a value for the first point x1, you can "undiff" using cumsum() as shown. If you do not have a value for x1, then you can only get as far as cumsum(diff(X)) which is a sequence shorter by 1 and indeterminate to within an additive constant. (Or you could extend it be prepending "0" as in c(0,cumsum(diff(X))) but you still have the undetermined additive constant). Hoping this helps, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <ted.harding at wlandres.net> Fax-to-email: +44 (0)870 094 0861 Date: 21-Jun-11 Time: 08:15:03 ------------------------------ XFMail ------------------------------