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ávio
Consider 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.hard...@wlandres.net> Fax-to-email: +44 (0)870 094 0861 Date: 21-Jun-11 Time: 08:15:03 ------------------------------ XFMail ------------------------------ ______________________________________________ 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.