spec_dsp | R Documentation |
Compute the spectrum of an AR(p) model
spec_dsp(ar_coefs, sigma_e, n.freq = 500)
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 |
A (n.freq x 2) matrix where the first column is the frequencies and the second column is the spectrum evaluated at that frequency
# 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]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.