Estimate Power Spectra via the Autocovariance Function
SpecACF.Rd
Estimates the power spectrum from a single time series, or the mean spectrum of a set of timeseries stored as the columns of a matrix. Timeseries can contain (some) gaps coded as NA values. Gaps results in additional estimation error so that the power estimates are no longer chi-square distributed and can contain additional additive error, to the extent that power at some frequencies can be negative. We do not have a full understanding of this estimation uncertainty, but simulation testing indicates that the estimates are unbiased such that smoothing across frequencies to remove negative estimates results in an unbiased power spectrum.
Usage
SpecACF(
x,
bin.width,
demean = TRUE,
detrend = TRUE,
TrimNA = TRUE,
pos.f.only = TRUE,
return.working = FALSE
)
Arguments
- x
a vector or matrix of binned values, possibly with gaps
- bin.width
the width of the bins, effectively delta_t
- demean
remove the mean from each record (column) in x, defaults to TRUE. If detrend is TRUE, mean will be removed during detrending regardless of the value of demean
- detrend
remove the mean and any linear trend from each record (column) in x, defaults to FALSE
- pos.f.only
return only positive frequencies, defaults to TRUE If TRUE, freq == 0, and frequencies higher than 1/(2*bin.width) which correspond to the negative frequencies are removed
See also
Other functions to estimate power spectra:
SpecMTM()
Examples
set.seed(20230312)
x <- cumsum(rgamma(200, shape = 1.5, rate = 1.5/10))
y <- SimProxySeries(a = 0.1, b = 1, t.smpl = x, nt = 2000,
smth.lab = list(type = "rect", tau = 1))
y_binned <- BinTimeseries(x, y, bin.width = 15)
sp1 <- SpecACF(y_binned$mean.value, bin.width = 15)
sp2 <- LogSmooth(sp1)
LPlot(sp1)
#> Warning: 22 y values <= 0 omitted from logarithmic plot
LLines(sp2, col = "red")