Description Usage Arguments Details Value Note Author(s) References See Also Examples
Computes the multi-taper estimate of the power spectral density
1 2 |
y |
a vector containing a time series of data |
bdw |
bandwidth for the Diploid Prolate Spherical Sequences. |
order |
an integer defining the number of tapers to use with the Prolate sequences. |
normalize |
Logical. If TRUE, taper will be normalized. |
tape |
a character string denoting the type of taper to create. See sapa. Default: "dpss" |
Utilizes the sapa library for tapers.
f |
vector of spectral density function estimates |
h |
vector of tapers |
I |
periodogram estimates for each segment, from 1 to order. |
~~further notes~~
Patrick Crutcher
D.B. Percival and A. Walden (1993), Spectral Analysis for Physical Applications: Multitaper and Conventional Univariate Techniques, Cambridge University Press, Cambridge, UK.
~~objects to See Also as help
, ~~~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
# y <- data(tsoi)
# mtm(y,bdw=0.05,order=10,normalize=TRUE,tape=c("dpss"))
# mtm(y,bdw=0.025,order=5,normalize=FALSE,tape=c("sine"))
## The function is currently defined as
function(y,bdw=0.05,order=10,normalize=TRUE,tape=c("dpss")) {
ly <- length(y)
if (missing(tape))
h<-taper(type="dpss",bandwidth=0.05,n.taper=8,n.sample=ly,normalize=TRUE)
else
h<-taper(type=tape,bandwidth=bdw,n.taper=order,n.sample=ly,normalize=TRUE)
#
Y<-as.matrix(h)*matrix(rep(y,order),dim(h),byrow=TRUE)
I<-t(abs(mvfft(t(Y)))^2)/(2*pi)
f<-apply(I,2,cumsum)
f<-f/matrix(rep(1:nrow(f),ncol(f)),dim(f))
return(list(f=f,h=h,I=I))
}
{ ts }
|
function (y, bdw = 0.05, order = 10, normalize = TRUE, tape = c("dpss"))
{
ly <- length(y)
if (missing(tape))
h <- taper(type = "dpss", bandwidth = 0.05, n.taper = 8,
n.sample = ly, normalize = TRUE)
else h <- taper(type = tape, bandwidth = bdw, n.taper = order,
n.sample = ly, normalize = TRUE)
Y <- as.matrix(h) * matrix(rep(y, order), dim(h), byrow = TRUE)
I <- t(abs(mvfft(t(Y)))^2)/(2 * pi)
f <- apply(I, 2, cumsum)
f <- f/matrix(rep(1:nrow(f), ncol(f)), dim(f))
return(list(f = f, h = h, I = I))
}
function (data = NA, start = 1, end = numeric(), frequency = 1,
deltat = 1, ts.eps = getOption("ts.eps"), class = if (nseries >
1) c("mts", "ts", "matrix") else "ts", names = if (!is.null(dimnames(data))) colnames(data) else paste("Series",
seq(nseries)))
{
if (is.data.frame(data))
data <- data.matrix(data)
if (is.matrix(data)) {
nseries <- ncol(data)
ndata <- nrow(data)
dimnames(data) <- list(NULL, names)
}
else {
nseries <- 1
ndata <- length(data)
}
if (ndata == 0)
stop("'ts' object must have one or more observations")
if (missing(frequency))
frequency <- 1/deltat
else if (missing(deltat))
deltat <- 1/frequency
if (frequency > 1 && abs(frequency - round(frequency)) <
ts.eps)
frequency <- round(frequency)
if (length(start) > 1L) {
start <- start[1L] + (start[2L] - 1)/frequency
}
if (length(end) > 1L) {
end <- end[1L] + (end[2L] - 1)/frequency
}
if (missing(end))
end <- start + (ndata - 1)/frequency
else if (missing(start))
start <- end - (ndata - 1)/frequency
if (start > end)
stop("'start' cannot be after 'end'")
nobs <- floor((end - start) * frequency + 1.01)
if (nobs != ndata)
data <- if (NCOL(data) == 1) {
if (ndata < nobs)
rep_len(data, nobs)
else if (ndata > nobs)
data[1L:nobs]
}
else {
if (ndata < nobs)
data[rep_len(1L:ndata, nobs), ]
else if (ndata > nobs)
data[1L:nobs, ]
}
attr(data, "tsp") <- c(start, end, frequency)
if (!is.null(class) && class != "none")
attr(data, "class") <- class
data
}
<bytecode: 0x3112860>
<environment: namespace:stats>
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.