MyNixOS website logo
Description

Adaptive, Sine-Multitaper Power Spectral Density and Cross Spectrum Estimation.

Produces power spectral density estimates through iterative refinement of the optimal number of sine-tapers at each frequency. This optimization procedure is based on the method of Riedel and Sidorenko (1995), which minimizes the Mean Square Error (sum of variance and bias) at each frequency, but modified for computational stability. The same procedure can now be used to calculate the cross spectrum (multivariate analyses).

psd

Adaptive, sine multitaper power spectral density estimation for R

by Andrew J Barbour, Jonathan Kennel, and Robert L Parker

R-CMD-check Code Coverage Downloads License Citation

Latest News

As of version 2.0, one can calculate the multivariate PSD ("cross spectrum") between two signals.

Description

This is an R package for computing univariate power spectral density estimates with little or no tuning effort. We employ sine multitapers, allowing the number to vary with frequency in order to reduce mean square error, the sum of squared bias and variance, at each point. The approximate criterion of Riedel and Sidorenko (1995) is modified to prevent runaway averaging that otherwise occurs when the curvature of the spectrum goes to zero. An iterative procedure refines the number of tapers employed at each frequency. The resultant power spectra possess significantly lower variances than those of traditional, non-adaptive estimators. The sine tapers also provide useful spectral leakage suppression. Resolution and uncertainty can be estimated from the number of degrees of freedom (twice the number of tapers).

This technique is particularly suited to long time series, because it demands only one numerical Fourier transform, and requires no costly additional computation of taper functions, like the Slepian functions. It also avoids the degradation of the low-frequency performance associated with record segmentation in Welch's method. Above all, the adaptive process relieves the user of the need to set a tuning parameter, such as time-bandwidth product or segment length, that fixes frequency resolution for the entire frequency interval; instead it provides frequency-dependent spectral resolution tailored to the shape of the spectrum itself.

psd elegantly handles spectra with large dynamic range and mixed-bandwidth features|features typically found in geophysical datasets.

How to Cite

Bob and Andy have a paper in Computers & Geosciences to accompany this software (download a pdf, 1MB); it describes the theory behind the estimation process, and how we apply it in practice. If you find psd useful in your research, we kindly request you cite our paper. See also:

citation("psd")

Getting Started

You can to install the package and it's dependencies with CRAN (from within the R environment):

install.packages("psd")

then load the package library

library(psd)

We have included a dataset to play with, namely Tohoku, which represents recordings of high-frequency borehole strainmeter data during teleseismic waves from the 2011 Mw 9.0 Tohoku earthquake (original data source). Access and inspect these data with:

data(Tohoku)
print(str(Tohoku))

The 'preseismic' data has interesting spectral features, so we subset it, and analyze the areal strain (the change in borehole diameter):

Dat <- subset(Tohoku, epoch=="preseismic")
Areal <- ts(Dat$areal)

For the purposes of improving the accuracy of the spectrum, we remove a linear trend:

Dat <- prewhiten(Areal, plot=FALSE)

Now we can calculate the adaptive PSD:

mtpsd <- pspectrum(Dat[['prew_lm']], plot=TRUE)
print(class(mtpsd))

In the previous example the plot=TRUE flag produces a comparison with a basic periodogram, but we can also visualize the spectrum with builtin plotting methods:

plot(mtpsd, log="dB")

The spectral uncertainty can be easily calculated:

sprop <- spectral_properties(mtpsd)
with(sprop, {
    plot(taper/max(taper), type="h", ylim=c(0,2), col="dark grey") 
    lines(stderr.chi.lower)
    lines(stderr.chi.upper)
})

Installing the Development Version

Should you wish to install the development version of this software, the remotes library will be useful:

library(remotes)
install_github("abarbour/psd")
Metadata

Version

2.1.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows