Sinusoidal regression

Two columns must be selected (x and y values). A sum of up to eight sinusoids with periods specified by the user, but with unknown amplitudes and phases, is fitted to the data. This can be useful for modeling periodicities in time series, such as annual growth cycles or climatic cycles, usually in combination with spectral analysis. The algorithm is based on a least-squares criterion and singular value decomposition. By default, the periods are set to the range of the x values, and harmonics (1/2, 1/3, 1/4, 1/5, 1/6, 1/7 and 1/8 of the fundamental period). These values can be changed, and need not be in harmonic proportion.

The “Fit periods” option will sequentially optimize the period of each sinusoid (over the full meaningful range from one period to the Nyquist frequency), after subtracting all previously fitted sinusoids. This is a simple example of the “Matching pursuit” algorithm. The algorithm is slow but robust and will fairly reliably find the global optimum.

The chi-squared value is a measure of fitting error - larger values mean poorer fit. The Akaike Information Criterion has a penalty for the number of sinusoids (the equation used assumes that the periods are estimated from the data). The AIC should be as low as possible to maximize fit but avoid overfitting.

R2 is the coefficient of determination, or proportion of variance explained by the model. Finally, a p value, based on an F test, gives the significance of the fit.

It is not meaningful to specify periodicities that are smaller than two times the typical spacing of data points.

Each sinusoid is given by y = a*cos(2*pi*(x-x0) / T - p), where a is the amplitude, T is the period and p is the phase. x0 is the first (smallest) x value. An overall constant offset (mean) is also given.

There are also options to enforce a pure sine or cosine series, i.e. with fixed phases.

Published Aug. 31, 2020 9:48 PM - Last modified Aug. 31, 2020 9:48 PM