Learn R Programming

quantspec (version 1.0-0)

FreqRep-class: Class for Frequency Representation.

Description

FreqRep is an S4 class that encapsulates, for a time series $(Y_t)_{t=0,\ldots,n-1}$, the data structures for the storage of a frequency representation. Examples of such frequency representations include
  • the Fourier transformation of the clipped time series$({I{Y_t \leq q})$, or
  • the weighted$L_1$-projection of$(Y_t)$onto an harmonic basis.
Examples are realized by implementing a sub-class to FreqRep. Currently, implementations for the two examples mentioned above are available: ClippedFT and QRegEstimator.

Arguments

Details

It is always an option to base the calculations on the pseudo data $R_{t,n} / n$ where $R_{t,n}$ denotes the rank of $Y_t$ among $(Y_t)_{t=0,\ldots,n-1}$. To allow for a block bootstrapping procedure a number of B estimates determined from bootstrap replications of the time series which are yield by use of a BootPos-object can be stored on initialization. The data in the frequency domain is stored in the array values, which has dimensions (J,K,B+1), where J is the number of frequencies, K is the number of levels and B is the number of bootstrap replications requested on intialization. In particular, values[j,k,1] corresponds to the time series' frequency representation with frequencies[j] and levels[k], while values[j,k,b+1] is the for the same, but determined from the bth block bootstrapped replicate of the time series.

Examples

Run this code
Y       <- rnorm(32)
freq    <- 2*pi*c(0:31)/32 
levels  <- c(0.25,0.5,0.75)
cFT     <- clippedFT(Y, freq, levels)

plot(cFT)

# Get values for all Fourier frequencies and all levels available.
V.all    <- getValues(cFT)

# Get values for every second frequency available
V.coarse <- getValues(cFT, frequencies = 2*pi*c(0:15)/16, levels = levels)

# Trying to get values on a finer grid of frequencies than available will
# yield a warning and then all values with frequencies closest to that finer
# grid.
V.fine   <- getValues(cFT, frequencies = 2*pi*c(0:63)/64, levels = levels)

# Finally, get values for the available Fourier frequencies from [0,pi] and
# only for tau=0.25
V.part   <- getValues(cFT, frequencies = 2*pi*c(0:16)/32, levels = c(0.25))

# Alternatively this can be phrased like this:
V.part.alt <- getValues(cFT, frequencies = freq[freq <= pi], levels = c(0.25))

Run the code above in your browser using DataLab