Time series autocorrelation with missing years

조회 수: 1 (최근 30일)
Cecilia Wang
Cecilia Wang 2020년 5월 17일
답변: azim 2020년 6월 8일
I have a time series that is missing some years. I want to calculate the autocorrelation function. But autocorr does not allow us to specify a vector for the time points corresponding to the vector we are calculating autocorrelation for.
In other words, if I use autocorr(herbicide_amount), because I only have data for the years 1996, 1997, 1998, 1999, 2000, 2001, 2005, and 2010, the autocorrelation calculated and plotted will consider the herbicide_amount in 2005 to be one lag away from 2001, when it should actually be four lags away, and so on.
Is there a way to make this work? Or am I stuck with using just the data that's available in consecutive years (1996 to 2001)?
I realize that this may be more of a mathematical question than a coding one.

답변 (1개)

azim
azim 2020년 6월 8일
hi,
did you consider using retime and filling in the time gap in your timetable data. for eg. as per the documentation example:
Time = datetime({'2015-12-18 07:02:12';'2015-12-18 08:00:47';...
'2015-12-18 09:01:37';'2015-12-18 10:03:10';...
'2015-12-18 10:59:34'});
Temp = [37.3;41.9;45.7;42.3;39.8];
Pressure = [30.1;29.9;30.03;29.9;29.8];
TT = timetable(Time,Temp,Pressure)
TT2 = retime(TT,'hourly','spline')
you can read about it on the link mathworks.com/help/matlab/ref/timetable.retime.html
there are many methods for filling in the gaps like spline, mean, linear etc. so you can choose the method which suits your data the best. hope this helps

카테고리

Help CenterFile Exchange에서 Time Series에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by