frequency domain linear regression

1 view (last 30 days)
Jan
Jan on 6 Jan 2017
Edited: David Goodmanson on 6 Jan 2017
I am using tutorial frequency domain linear regression but I can't understand some parts.
First, is about frequency bin termin. In this tutorial we have frequency bin for positive and negative frequency, and it can be calculated like lengths of time series / period of time series + 1, for positive frequencies. For negative frequencies frequency bin is length of time series - lengths of time series / period of time series + 1. In my example, length of time series is odd number and I need to use it later like index in other time series, but than I have decimal number. I am not sure, what to do and is this principle of calculating frequency bins ok?
%
freqbin = 72/12;
freqbins = [freqbin 72-freqbin]+1;
tsfit = zeros(72,1);
tsfit(freqbins) = tsdft(freqbins);
tsfit = ifft(tsfit);
mu = mean(ts);
tsfit = mu+tsfit;
Second, at the and of tutorial we need to form linear regression model. X matrix which is neccessary for that is formed here like:
X = ones(72,7);
X(:,2) = cos(2*pi/72*(0:71))';
X(:,3) = sin(2*pi/72*(0:71))';
X(:,4) = cos(2*pi*6/72*(0:71))';
X(:,5) = sin(2*pi*6/72*(0:71))';
X(:,6) = cos(2*pi*12/72*(0:71))';
X(:,7) = sin(2*pi*12/72*(0:71))';
I don't understand from where they get numbers 6 and 12 in sin and cos term? This model is opposite of model formed with 3 Fourier frequencies, or 6 Fourier coefficients, but I can't find rule for numbers 6 and 12. Linear model need to have terms cos(2*pi*k*n/N) and sin(2*pi*k*n/N), where n is number of that term, N length of time series, and is k frequency?

Answers (1)

David Goodmanson
David Goodmanson on 6 Jan 2017
Edited: David Goodmanson on 6 Jan 2017
Hi Jan, You are correct that k is the index corresponding to frequency. In an fft, k = 6 always corresponds to 6 oscillations over the entire time period, whatever the period happens to be. Here the period is 72 months so k corresponds to 6 oscillations in 72 months, i.e. one oscillation per year. Similarly k = 12 corresponds to two oscillations per year, and k = 1 is one oscillation over the entire 72 months. In the tutorial those frequency peaks are the largest so just those are used in the reconstruction. (k=0, the constant term, would have been the largest but it was removed).

Community Treasure Hunt

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

Start Hunting!