[R] Relating Spectral Density to Chi-Square distribution

From: Keith Chamberlain <Keith.Chamberlain_at_colorado.edu>
Date: Tue 24 Jan 2006 - 19:10:44 EST


Dear list,  

I had some confusion regarding what function too use in order too relate results from spec.pgram() too a chi-square distribution. The documentation indicates that the PSD estimate can be approximated by a chi-square distribution with 2 degrees of freedom, but I am having trouble figuring out how to do it in R, and figuring out what specifically that statement in the documentation means. I have very little exposure to distribution functions in R.  

I have started with a signal that is simply a sine function, with a visible periodicity within the nyquist range.

>a <- sin(2*pi *(0:127)/16)

>plot(a, type="l")
 

I then get the raw power spectrum using, for instance:

>PSD <- spec.pgram(a, spans=NULL, detrend=F)
 

Next I did a search for information on chi-square.

>help.search("chi square")

. provided a list of potentials, of which Chisquare() seemed to fit because it mentioned the distribution.  

>?Chisquare

. provided the documentation, which shows four functions and their descriptions. I've assumed that I need too use dchisq() for my purposes, so that the fitted distribution would be: [assuming the power returned by spec.pgram() ARE regarded as quantiles.]  

>plot(dchisq(PSD$spec, df=2))

. but the values are not between (0,1).  

>plot(PSD$freq, pchisq(PSD$spec, df=2, lower.tail=F))

. looks better because values range from 0-1.  

Please clarify how to fit the PSD estimate to a chi-square distribution and any transforms that may be needed to get the quantiles from the PSD. Is what I tried what the documentation 'had in mind' when it says "df: The distribution of the spectral density estimate can be approximated by a chi square distribution with 'df' degrees of freedom." ? If so, what is the appropriate function call too use (pchisq(), dchisq(), or qchisq())? If not, what function should I consider?  

Thanks in advance,

Keith C.

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jan 24 19:23:06 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:09 EST