1
$\begingroup$

I've got some quarterly time series(see google drive link at the bottom), from which I should be getting a spectral density estimate that looks like the black line in the figure in the pdf (also provided in the link). I have verified that the data I'm using is exactly what goes into that spectral density. The zero-padding parameter the authors use is 1024, and the length of the Hamming window is 13. Also, the time series is demeaned. So far, what I have is the following code:

clc;
close all;
A = xlsread('nonfarmhours.xls','B2:B263');
xn=detrend(A)';
N=1024;
L=length(xn);
xn=[xn zeros(1,N-L)];
ymtlb=fft(xn);
ssd=abs(ymtlb).^2/length(xn);
plot(k,ssd);

Two obvious points-I haven't been able to include the effect of the Hamming window and to convert frequencies into periods on the x axis. Hopefully this is all that is missing. At the moment, I cannot proceed, so I'd greatly appreciate any input in reproducing that figure as far as the code is concerned.data and figure

$\endgroup$
  • 1
    $\begingroup$ "The length of the hamming window is 13"? Um, a window usually has the same length as the data $\endgroup$ – Marcus Müller Sep 2 '17 at 19:52
  • 1
    $\begingroup$ Exactly. It could be that I'm entirely misunderstanding what the authors are up to. Here's what they say they did: 'It turns out that the periodogram is asymptotically unbiased, but is not a consistent estimate of the spectrum, and in particular the estimate of the spectrum at a given frequency w(k) is generally quite unstable (i.e. it has a high standard error). Notwithstanding this fact, the overall pattern of the spectrum is much more stable, in the sense that the average value of the estimated spectrum within a given frequency band surrounding w(k) is in fact consistent. In order to obtain $\endgroup$ – FedeC Sep 3 '17 at 16:16
  • 1
    $\begingroup$ The statistical properties of frequency estimation are covered in detail in,The Estimation and Tracking of Frequency, B. G. Quinn and E. J. Hannan, Cambridge University Press, New York, NY, 2001, Estimating period and frequency are actually different. $\endgroup$ – Stanley Pawlukiewicz Sep 4 '17 at 1:34
  • 1
    $\begingroup$ thanks for your suggestion. Do you have any example code that shows how to tease out the estimate of the spectral density associated with the time domain, rather than with the frequency bins? Many thanks $\endgroup$ – FedeC Sep 4 '17 at 14:52
  • 1
    $\begingroup$ Please do not post "answers" that are not answers. If you don't have enough rep to post comments, please use the profile you posted the question in, rather than a new profile. You should be able to post comments on your own questions. The reason you can't now is because you logged in with different profile. $\endgroup$ – Peter K. Sep 4 '17 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.