set verbose off nulldata 50 set seed 76543 # generate an AR(1) process series e = normal() series x = 0 x = 0.9*x(-1) + e # compute the periodogram F = fft({x}) # note that the series is turned into a matrix on the fly S = abs(F).^2 S = S[2:($nobs/2)+1] / (2*$pi*$nobs) sfreq = seq(1,($nobs/2))' omega = sfreq .* (2*$pi/$nobs) period = $nobs ./ sfreq omega = omega ~ sfreq ~ period ~ S # compare the built-in command pergm x print omega