Scipio
Scipio

Reputation: 313

MATLAB - autocorrelation of unevenly spaced timeseries

In Matlab, I have an unevenly spaced timeseries described by a vector y and a vector t, together describing the value at points in time. The timeseries seems to be periodic. How can I determine the autocorrelation of this timeseries?

xcorr does not seem to provide the possibility to handle an unevenly spaced timeseries, and to my surprise I could not find much about it on google. Alternatively, I figured I might convert y to a regular spaced series using interpolation techniques, but I could not find a clearcut approach to that either. I feel there should be straight forward way to do this, any suggestions?

Upvotes: 1

Views: 1294

Answers (1)

Buck Thorn
Buck Thorn

Reputation: 5073

AFAIK MATLAB does not have builtin functions for processing unevenly sampled data (although you might search more thoroughly the toolboxes or MATLAB central - see below).

Interpolation, despite the potential problems it can introduce when computing a spectral estimate, should be easy with

 xnew = linspace(min(x),max(x),N);
 ynew = interp1(x,y,xnew);

giving N regularly spaced data points {xnew, ynew} interpolated over your 1D data set.

There is a nice lengthy thread here with details on various ways to obtain spectral estimates for unevenly sampled data. If you follow the advice in that thread, you will find a number of choices on how to compute the Lomb-Scargle periodogram from MATLAB central. That might just do the trick but I have not tried it myself.

You can alternately try implementing autocorrelation on nonlinearly sampled data with methods such as those delineated in http://www.eckner.com/papers/unevenly_spaced_time_series_analysis.pdf

Upvotes: 3

Related Questions