Time series autocorrelation with missing years

3 次查看(过去 30 天)
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 中查找有关 Data Preprocessing 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by