From: Kirk Hammett on
Hello - I have a seasonal time series that I want to convert to a stationary time series. I was curious if I could difference it at a specified lag using the diff() function in Matlab (or any other function). diff(ts,12) would difference it 12 times! Definitely do not want that. Is there some way I can tell it to basically X_{t} - X_{t-12}? If not I'll write my own function but this seems really basic so I think Matlab should be able to do this.
Thank you for your time.
From: Jan Simon on
Dear Kirk!

> Hello - I have a seasonal time series that I want to convert to a stationary time series. I was curious if I could difference it at a specified lag using the diff() function in Matlab (or any other function). diff(ts,12) would difference it 12 times! Definitely do not want that. Is there some way I can tell it to basically X_{t} - X_{t-12}?

x = rand(1, 100);
d = x(1:100 - 12 + 1) - x(12:100)

Jan
From: Kirk Hammett on
"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hpln67$k73$1(a)fred.mathworks.com>...
> Dear Kirk!
>
> > Hello - I have a seasonal time series that I want to convert to a stationary time series. I was curious if I could difference it at a specified lag using the diff() function in Matlab (or any other function). diff(ts,12) would difference it 12 times! Definitely do not want that. Is there some way I can tell it to basically X_{t} - X_{t-12}?
>
> x = rand(1, 100);
> d = x(1:100 - 12 + 1) - x(12:100)
>
> Jan

Thanks! I have to get used to the Matlab way of doing things!