Periodogram {ptest} | R Documentation |
Periodogram computation at Fourier or non-Fourier frequencies. When UseC=TRUE, a direct algorithm is used and non-Fourier frequencies are allowed as well as missing values. Missing values are indicated by NA in the input series z. When UseC=FALSE, the FFT is used. With the FFT, no missing values are allowed and the periodogram is obtained only at the Fourier frequencies, (1:[n/2])/n.
Periodogram(z, m = "default", UseC = TRUE, plot = FALSE)
z |
time series, missing values indicated by NA |
m |
number of |
UseC |
UseC=TRUE, use compiled code, other the R funciton fft is used |
plot |
If plot=TRUE, a plot of the periodogra is produced instead of the table |
A recursive algorithm is used to compute the necessary sine and cosine functions.
returns matrix with 2 columns corresponding to frequency and periodogram value.
A.I. McLeod
#Compute the periodogram using 3 different algorithm and check accuracy. #The absolute sum of the differences should be very small. #First using fft method in R out1<-Periodogram(sunspot.year, UseC=FALSE) #Second using compiled code for the non-Fourier case out2<-Periodogram(sunspot.year) sum(abs(out1[,2]-out2[,2])) #Third using compiled code for the non-Fourier case out3<-Periodogram(sunspot.year, m=144) sum(abs(out1[,2]-out3[,2]))