xdata: For categorical-valued sequences, a matrix with rows that are indicators of the categories represented by the columns, possibly a sequence converted using dna2vector. For real-valued sequences, a matrix with at least two columns that are various transformations of the data.
section: of the form start:end where start < end are positive integers; specifies the section used in the analysis - default is the entire sequence.
spans: specify smoothing used in mvspec.
kernel: specify kernel to be used in mvspec.
taper: specify amount of tapering to be used in mvspec.
significance: significance threshold exhibited in plot - default is .0001; set to NA to cancel
plot: if TRUE (default) a graphic of the spectral envelope is produced
ylim: limits of the spectral envelope axis; if NULL (default), a suitable range is calculated.
real: FALSE (default) for categorical-valued sequences and TRUE for real-valued sequences.
...: other graphical parameters.
Details
Calculates the spectral envelope for categorical-valued series as discussed in
These concepts are also presented (with examples) in Section 7.9 (Chapter 7) of Time Series Analysis and Its Applications: With R Examples: https://www.stat.pitt.edu/stoffer/tsa4/ .
For categorical-valued series, the input xdata must be a matrix of indicators which is perhaps a sequence preprocessed using dna2vector.
For real-valued series, the input xdata should be a matrix whose columns are various transformations of the univariate series.
The script does not detrend the data prior to estimating spectra. If this is an issue, then detrend the data prior to using this script.
Returns
By default, will produce a graph of the spectral envelope and an approximate significance threshold. A matrix containing: frequency, spectral envelope ordinates, and (1) the scalings of the categories in the order of the categories in the alphabet or (2) the coefficients of the transformations, is returned invisibly.
References
You can find demonstrations of astsa capabilities at FUN WITH ASTSA.
The webpages for the texts and some help on using R for time series analysis can be found at https://nickpoison.github.io/.
Author(s)
D.S. Stoffer
See Also
dna2vector
Examples
## Not run:# a DNA sequencedata = bnrf1ebv
xdata = dna2vector(data)u = specenv(xdata, section=1:1000, spans=c(7,7))head(u)# scalings are for A, C, G, and last one T=0 always# a real-valued series (nyse returns)x = astsa::nyse
xdata = cbind(x, abs(x), x^2)u = specenv(xdata, real=TRUE, spans=c(3,3))# plot optimal transform at freq = .001beta = u[2,3:5]b = beta/beta[2]# makes abs(x) coef=1gopt =function(x){ b[1]*x+b[2]*abs(x)+b[3]*x^2}curve(gopt,-.2,.2, col=4, lwd=2, panel.first=Grid())g2 =function(x){ b[2]*abs(x)}# corresponding to |x|curve(g2,-.2,.2, add=TRUE, col=6)## End(Not run)