Learn R Programming

astsa (version 1.12)

spec.ic: 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(data, BIC = FALSE, order.max = 30, main = NULL, plot = TRUE, 
         detrend = FALSE, method=NULL, ...)

Arguments

data

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 models to fit. Defaults to 30.

main

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, detrends the data first. 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".

additional arguments.

Value

[[1]]

Matrix with columns: ORDER, AIC, BIC

[[2]]

Matrix with columns: freq, spec

Details

Uses ar to fit the best AR model based on pseudo AIC or BIC. No likelihood is calculated unless method='mle' is used, however, the calculations will be slow. The minimum centered AIC and BIC values and the spectral and frequency ordinates are returned silently.

References

https://www.stat.pitt.edu/stoffer/tsa4/ and https://www.stat.pitt.edu/stoffer/tsda/

See Also

ar, spec.ar

Examples

Run this code
# 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)  
# }

Run the code above in your browser using DataLab