pyulear: Autoregressive PSD estimate - Yule-Walker method

View source: R/pyulear.R

pyulearR Documentation

Autoregressive PSD estimate - Yule-Walker method

Description

Calculate Yule-Walker autoregressive power spectral density.

Usage

pyulear(
  x,
  p,
  freq = 256,
  fs = 1,
  range = NULL,
  method = if (length(freq) == 1 && bitwAnd(freq, freq - 1) == 0) "fft" else "poly"
)

Arguments

x

input data, specified as a numeric or complex vector or matrix. In case of a vector it represents a single signal; in case of a matrix each column is a signal.

p

model order; number of poles in the AR model or limit to the number of poles if a valid criterion is provided. Must be < length(x) - 2.

freq

vector of frequencies at which power spectral density is calculated, or a scalar indicating the number of uniformly distributed frequency values at which spectral density is calculated. Default: 256.

fs

sampling frequency (Hz). Default: 1

range

character string. one of:

"half" or "onesided"

frequency range of the spectrum is from zero up to but not including fs / 2. Power from negative frequencies is added to the positive side of the spectrum.

"whole" or "twosided"

frequency range of the spectrum is -fs / 2 to fs / 2, with negative frequencies stored in "wrap around order" after the positive frequencies; e.g. frequencies for a 10-point 'twosided' spectrum are 0 0.1 0.2 0.3 0.4 0.5 -0.4 -0.3 -0.2. -0.1.

"shift" or "centerdc"

same as "whole" but with the first half of the spectrum swapped with second half to put the zero-frequency value in the middle. If freq is vector, "shift" is ignored.

Default: If model coefficients a are real, the default range is "half", otherwise the default range is "whole".

method

method used to calculate the power spectral density, either "fft" (use the Fast Fourier Transform) or "poly" (calculate the power spectrum as a polynomial). This argument is ignored if the freq argument is a vector. The default is "poly" unless the freq argument is an integer power of 2.

Value

An object of class "ar_psd" , which is a list containing two elements, freq and psd containing the frequency values and the estimates of power-spectral density, respectively.

Note

This function is a wrapper for arburg and ar_psd.

Author(s)

Peter V. Lanspeary, pvl@mecheng.adelaide.edu.au.
Conversion to R by Geert van Boxtel, gjmvanboxtel@gmail.com

See Also

ar_psd, arburg

Examples

A <- Arma(1, c(1, -2.7607, 3.8106, -2.6535, 0.9238))
y <- filter(A, 0.2 * rnorm(1024))
py <- pyulear(y, 4)


gsignal documentation built on Sept. 12, 2024, 6:27 a.m.