Logo

statsmodels.tsa.filters.arfilter

statsmodels.tsa.filters.arfilter(x, a)

apply an autoregressive filter to a series x

x can be 2d, a can be 1d, 2d, or 3d

Parameters :

x : array_like

data array, 1d or 2d, if 2d then observations in rows

a : array_like

autoregressive filter coefficients, ar lag polynomial see Notes

Returns :

y : ndarray, 2d

filtered array, number of columns determined by x and a

Notes

In general form this uses the linear filter

y = a(L)x

where x : nobs, nvars a : nlags, nvars, npoly

Depending on the shape and dimension of a this uses different Lag polynomial arrays

case 1 : a is 1d or (nlags,1)
one lag polynomial is applied to all variables (columns of x)
case 2 : a is 2d, (nlags, nvars)
each series is independently filtered with its own lag polynomial, uses loop over nvar
case 3 : a is 3d, (nlags, nvars, npoly)

the ith column of the output array is given by the linear filter defined by the 2d array a[:,:,i], i.e.

y[:,i] = a(.,.,i)(L) * x
y[t,i] = sum_p sum_j a(p,j,i)*x(t-p,j)
         for p = 0,...nlags-1, j = 0,...nvars-1,
         for all t >= nlags

All filtering is done with scipy.signal.convolve, so it will be reasonably fast for medium sized arrays. For large arrays fft convolution would be faster.

Note: maybe convert to axis=1, Not

TODO:
initial conditions, make sure tests for 3d case are done, I don’t remember how much I tested the 3d case

Previous topic

statsmodels.tsa.filters.hpfilter

Next topic

statsmodels.tsa.filters.cffilter

This Page