spec_dsp: Compute the spectrum of an AR(p) model

spec_dspR Documentation

Compute the spectrum of an AR(p) model

Description

Compute the spectrum of an AR(p) model

Usage

spec_dsp(ar_coefs, sigma_e, n.freq = 500)

Arguments

ar_coefs

(p x 1) vector of AR(p) coefficients

sigma_e

observation standard deviation

n.freq

number of frequencies at which to evaluate the spectrum

Value

A (n.freq x 2) matrix where the first column is the frequencies and the second column is the spectrum evaluated at that frequency

Examples

# Example 1: periodic function
t01 = seq(0, 1, length.out = 100);
y = sin(2*pi*t01) + 0.1*rnorm(length(t01))
ar_mod = ar(y)
spec = spec_dsp(ar_mod$ar, sigma_e = sqrt(ar_mod$var.pred))
# Dominant frequency:
spec[which.max(spec[,2]),1]

# Example 2: white noise
y = rnorm(length(t01))
ar_mod = ar(y)
spec = spec_dsp(ar_mod$ar, sigma_e = sqrt(ar_mod$var.pred))
# Dominant frequency:
spec[which.max(spec[,2]),1]


drkowal/dsp documentation built on July 19, 2023, 11:42 a.m.