differencing a time series

4 visualizzazioni (ultimi 30 giorni)
Chithralekha
Chithralekha il 10 Ago 2013
I want to difference a time series till it becomes stationary.how to code it using matlab.i am writing my code below.please help me to continue it acf=autocorr of time series
l(k)=lower limit
u(k)=upper limit
if ((acf(k+1)<l(k)) || (acf(k+1)>u(k))),a time series is non-stationary.now i have to difference a time series till it becomes stationary.how to write using a single expression.
  2 Commenti
dpb
dpb il 10 Ago 2013
Modificato: dpb il 10 Ago 2013
What's k supposed to represent--the k-th lag of the acf series or the acf after the k-th difference of x?
Maybe my utility function can help some w/ the complexity -- it's just syntactic sugar but by putting the logic expressions at a lower level it can often lead to seeing how to reduce expressions...
while ~all(iswithin(acf,l,u))
... do another difference here
end
where acf is presumed to be the acf at the kth iteration
iswithin is
function flg=iswithin(x,lo,hi)
% returns T for values within range of input
% SYNTAX:
% [log] = iswithin(x,lo,hi)
% returns T for x between lo and hi values, inclusive
flg= (x>=lo) & (x<=hi);
Chithralekha
Chithralekha il 11 Ago 2013
k is the kth lag of time series.

Accedi per commentare.

Risposte (1)

dpb
dpb il 11 Ago 2013
OK, presuming you have a vector of given length and the limits of the same, then
(acf(k+1)<l(k)) || (acf(k+1)>u(k)))
is
acf(2:end)<l || acf(2:end)>u
if do want the short-circuiting operator here.

Categorie

Scopri di più su Mathematics and Optimization in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by