specenv {astsa}  R Documentation 
Computes the spectral envelope of categoricalvalued or realvalued time series.
specenv(xdata, section = NULL, spans = NULL, significance = 1e04, plot = TRUE, ylim = NULL, real = FALSE, ...)
xdata 
For categoricalvalued sequences, a matrix with rows that are indicators
of the categories represented by the columns, possibly a sequence converted using

section 
of the form 
spans 
specify smoothing used in 
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 categoricalvalued sequences and TRUE for realvalued sequences. 
... 
other graphical parameters. 
Calculates the spectral envelope for categoricalvalued series as discussed in https://www.stat.pitt.edu/stoffer/dss_files/spenv.pdf and summarized in https://doi.org/10.1214/ss/1009212816. Alternately, calculates the spectral envelope for realvalued series as discussed in https://doi.org/10.1016/S03783758(96)000444.
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 categoricalvalued series, the input xdata
must be a matrix of indicators which is perhaps a sequence preprocessed using dna2vector
.
For realvalued series, the input xdata
should be a matrix whose columns are various transformations of the univariate series.
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.
D.S. Stoffer
You can find demonstrations of astsa capabilities at FUN WITH ASTSA.
The most recent version of the package can be found at https://github.com/nickpoison/astsa/.
In addition, the News and ChangeLog files are at https://github.com/nickpoison/astsa/blob/master/NEWS.md.
The webpages for the texts are https://www.stat.pitt.edu/stoffer/tsa4/ and https://www.stat.pitt.edu/stoffer/tsda/.
## Not run: # a DNA sequence data = 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 realvalued 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 = .001 beta = u[2, 3:5] b = beta/beta[2] # makes abs(x) coef=1 gopt = 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)