spec.ic {astsa} | R Documentation |
Estimate Spectral Density of a Time Series from AR Fit
Description
Fits an AR model to data and computes (and by default plots) the spectral density of the fitted model based on AIC (default) or BIC.
Usage
spec.ic(xdata, BIC=FALSE, order.max=NULL, main=NULL, plot=TRUE, detrend=TRUE,
lowess=FALSE, method=NULL, cex.main=NULL, xlab=NULL, ...)
Arguments
xdata |
a univariate time series. |
BIC |
if TRUE, fit is based on BIC. If FALSE (default), fit is based on AIC. |
order.max |
maximum order of model to fit. Defaults (if NULL) to the minimum of 100 and 10% of the number of observations. |
main |
plot title. Defaults to name of series, method and chosen order. |
plot |
if TRUE (default) produces a graphic of the estimated AR spectrum. |
detrend |
if TRUE (default), detrends the data first. If FALSE, the series is demeaned. |
lowess |
if TRUE, detrends using lowess. Default is FALSE. |
method |
method of estimation - a character string specifying the method to fit the model chosen from the following: "yule-walker", "burg", "ols", "mle", "yw". Defaults to "yule-walker". |
cex.main |
magnification for main title; default is 1. |
xlab |
label for frequency axis; if NULL (default), a totally awesome label is generated for your viewing pleasure. |
... |
additional graphical arguments. |
Details
Uses ar
to fit the best AR model based on pseudo AIC or BIC.
Using method='mle'
will be slow. The minimum centered AIC and BIC values and the
spectral and frequency ordinates are returned silently.
Value
[[1]] |
Matrix with columns: ORDER, AIC, BIC |
[[2]] |
Matrix with columns: freq, spec |
Author(s)
D.S. Stoffer
References
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 and some help on using R for time series analysis can be found at https://nickpoison.github.io/.
See Also
Examples
## Not run:
# AIC
spec.ic(soi)
spec.ic(sunspotz, method='burg', col=4)
# BIC after detrending on log scale
spec.ic(soi, BIC=TRUE, detrend=TRUE, log='y')
# plot AIC and BIC without spectral estimate
tsplot(0:30, spec.ic(soi, plot=FALSE)[[1]][,2:3], type='o', xlab='order', nxm=5)
## End(Not run)