Autoregressive (AR) processes are processes of the form:
x(n) = a(1)x(n-1) + a(2)x(n-2) + ... + a(P)x(n-P) + e(n)
where e(n) is a white noise process. The usage of ‘e’ suggests interpreting the linear combination of P past values of x(n) as the minimum mean square error linear predictor of x(n) Thus
e(n) = x(n) - a(1)x(n-1) - a(2)x(n-2) - ... - a(P)x(n-P)
Due to whiteness, e(n) is also pointwise uncorrelated–ie,
These principles form the basis of the methods in this module for estimating the AR coefficients and the error/innovations power.
Levinson-Durbin algorithm for solving the Hermitian Toeplitz system R[m]w[m]=r[m+1]: (XXX review this definition for complex)
[[r(0) r(1) r(2) ... r(m-1)],
r[m+1] = [r(1), r(2), ..., r(m)].T
r(k) = E{X(t+k)X*(t)}
and w[m] is the vector of m AR coefficients
Parameters : | x: ndarray :
order : int
rxx : ndarray, optional
|
---|---|
Returns : | ak, sig_sq :
|
Determine the autoregressive (AR) model of a random process x using the Yule Walker equations. The AR model takes this convention:
x(n) = a(1)x(n-1) + a(2)x(n-2) + ... + a(P)x(n-P) + e(n)
where e(n) is a zero-mean white noise process with variance sig_sq, and P is the order of the AR model. This method returns the a_i and sigma
The orthogonality property of minimum mean square error estimates yields the Yule Walker equations.
Parameters : | x : ndarray
order : int
rxx : ndarray (optional)
|
---|---|
Returns : | ak, sig_sq: The estimated AR coefficients and innovations variance : |
Compute the PSD of an AR process, based on the process coefficients and covariance
Returns : | (w, ar_psd) : w : Array of normalized frequences from [-.5, .5) or [0,.5] ar_psd : A PSD estimate computed by sigma_v / |1-a(f)|**2 , where
|
---|
MAR estimation, using the LWR algorithm, as in Morf et al.
Parameters : | x : ndarray
order : int
rxx : ndarray (optional)
|
---|---|
Returns : | a, ecov: The system coefficients and the estimated covariance : |
Compute the spectral coherence between processes X and Y, given their spectral matrix S(w)
Parameters : | Sw : ndarray
|
---|
Compute the Granger causality between processes X and Y, which are linked in a multivariate autoregressive (mAR) model parameterized by coefficient matrices a(i) and the innovations covariance matrix
X[t] + sum_{k=1}^P a[k]X[t-k] = Err[t]
Parameters : | a : ndarray, (P,2,2)
cov : ndarray, (2,2)
n_freqs: int :
|
---|---|
Returns : | w, f_x_on_y, f_y_on_x, f_xy, Sw :
|
Compute the ‘total interdependence’ between processes X and Y, given their spectral matrix S(w)
Parameters : | Sw : ndarray
|
---|---|
Returns : | fxy(w) :
|
Perform a Levinson-Wiggins[Whittle]-Robinson recursion to find the coefficients a(i) that satisfy the matrix version of the Yule-Walker system of P+1 equations:
sum_{i=0}^{P} a(i)r(k-i) = 0, for k = {1,2,...,P}
with the additional equation
sum_{i=0}^{P} a(i)r(-k) = V
where V is the covariance matrix of the innovations process, and a(0) is fixed at the identity matrix
Also note that r is defined as:
r(k) = E{ X(t)X*(t-k) } ( * = conjugate transpose ) r(-k) = r*(k)
This routine adapts the algorithm found in eqs (1)-(11) in Morf, Vieira, Kailath 1978
Parameters : | r : ndarray, shape (P+1, nc, nc) |
---|---|
Returns : | a : ndarray (P,nc,nc)
sigma : ndarray (nc,nc)
|
Compute the spectral matrix S(w), from the convention:
X[t] + sum_{k=1}^P a[k]X[t-k] = Err[t]
The formulation follows from Ding, Chen, Bressler 2008, pg 6 eqs (11) to (15)
The transfer function H(w) should be computed first from transfer_function_xy()
Parameters : | Hw : ndarray (2, 2, n_freqs)
cov : ndarray (2, 2)
|
---|---|
Returns : | Sw: ndarrays :
|
Helper routine to compute the transfer function H(w) based on sequence of coefficient matrices A(i). The z transforms follow from this definition:
X[t] + sum_{k=1}^P a[k]X[t-k] = Err[t]
Parameters : | a : ndarray, shape (P, 2, 2)
n_freqs : int, optional
|
---|---|
Returns : | Hw : ndarray
|