differencing a time series
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
dpb
2013-8-10
编辑:dpb
2013-8-10
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);
回答(1 个)
dpb
2013-8-11
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!