[S] Summary: Help with spectrum()

Jan Schelling (schelling@ivuk.mavt.ethz.ch)
Thu, 18 Jun 1998 21:42:36 +0200


Thanks to Prof. Ripley, Don Murdoch and Don Percival who responded to my
question about a deviation between the integral of the spectrum and the
variance of a time series.

My mistake was a missing factor in the integral (I used Chatfield "The
Analysis of Time Series", 1980 and not V&R...) and the omission to turn off
tapering. (Also detrending should be turned off which did not make much of
a difference in my case though)
Don Percival also supplied a method for correcting the spectrum when
tapering is used.

Further reading:
"Spectral Analysis for Physical Applications," Percival &
Walden, Cambridge University Press, 1993

WRONG:
> x <- arima.sim(n=1000, model=list(ar=0.7)) # simulate AR process
> spec <- spectrum(x, span=20) # calculate smoothed spectrum
> f <- 10^(spec$spec/10) # convert dB into real numbers
> n <- length(f)
> w <- 2*pi*spec$freq # convert frequency into angular frequency
> sum(f[-n]*diff(w)) # simple integration
[1] 5.442544

> var(x)
[1] 2.021829

CORRECT:
x <- arima.sim(n=1000, model=list(ar=0.7)) # simulate AR process
spec <- spectrum(x, span=20, detrend=T, taper=0.0) # calculate smoothed
spectrum
f <- 10^(spec$spec/10) # convert dB into real numbers
2*(sum(f)-f[1])*diff(spec$freq[1:2]) # simple integration
[1] 2.153871

var(x)
[1] 2.167155

-----------------------------------------------------------------
Jan Schelling
Institute of Process Engineering
ETH Zurich, 8092 Switzerland
phone: ++41-1-633 62 63
fax: ++41-1-633 11 19
email: schelling@ivuk.mavt.ethz.ch
internet: http://www.ivuk.ethz.ch/staff/schelling/
-----------------------------------------------------------------
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news