# arma¶

Filename: arma.py Authors: Doc-Jin Jang, Jerry Choi, Thomas Sargent, John Stachurski

Provides functions for working with and visualizing scalar ARMA processes.

class quantecon.arma.ARMA(phi, theta=0, sigma=1)[source]

Bases: object

This class represents scalar ARMA(p, q) processes.

If phi and theta are scalars, then the model is understood to be

$X_t = \phi X_{t-1} + \epsilon_t + \theta \epsilon_{t-1}$

where $$epsilon_t$$ is a white noise process with standard deviation $$sigma$$. If phi and theta are arrays or sequences, then the interpretation is the ARMA(p, q) model

$X_t = \phi_1 X_{t-1} + ... + \phi_p X_{t-p} +$$\epsilon_t + \theta_1 \epsilon_{t-1} + ... + \theta_q \epsilon_{t-q}$

where

• $$\phi = (\phi_1, \phi_2,..., \phi_p)$$
• $$\theta = (\theta_1, \theta_2,..., \theta_q)$$
• $$\sigma$$ is a scalar, the standard deviation of the white noise
Parameters: phi : scalar or iterable or array_like(float) Autocorrelation values for the autocorrelated variable. See above for explanation. theta : scalar or iterable or array_like(float) Autocorrelation values for the white noise of the model. See above for explanation sigma : scalar(float) The standard deviation of the white noise

Attributes

 phi, theta, sigma (see Parmeters) ar_poly (array_like(float)) The polynomial form that is needed by scipy.signal to do the processing we desire. Corresponds with the phi values ma_poly (array_like(float)) The polynomial form that is needed by scipy.signal to do the processing we desire. Corresponds with the theta values

Methods

 autocovariance([num_autocov]) Compute the autocovariance function from the ARMA parameters over the integers range(num_autocov) using the spectral density and the inverse Fourier transform. impulse_response([impulse_length]) Get the impulse response corresponding to our model. plot_autocovariance([ax, show]) plot_impulse_response([ax, show]) plot_simulation([ax, show]) plot_spectral_density([ax, show]) quad_plot() Plots the impulse response, spectral_density, autocovariance, and one realization of the process. set_params() Internally, scipy.signal works with systems of the form simulation([ts_length]) Compute a simulated sample path assuming Gaussian shocks. spectral_density([two_pi, res]) Compute the spectral density function.
autocovariance(num_autocov=16)[source]

Compute the autocovariance function from the ARMA parameters over the integers range(num_autocov) using the spectral density and the inverse Fourier transform.

Parameters: num_autocov : scalar(int), optional(default=16) The number of autocovariances to calculate
impulse_response(impulse_length=30)[source]

Get the impulse response corresponding to our model.

Returns: psi : array_like(float) psi[j] is the response at lag j of the impulse response. We take psi[0] as unity.
phi
plot_autocovariance(ax=None, show=True)[source]
plot_impulse_response(ax=None, show=True)[source]
plot_simulation(ax=None, show=True)[source]
plot_spectral_density(ax=None, show=True)[source]
quad_plot()[source]

Plots the impulse response, spectral_density, autocovariance, and one realization of the process.

set_params()[source]

Internally, scipy.signal works with systems of the form

$ar_{poly}(L) X_t = ma_{poly}(L) \epsilon_t$

where L is the lag operator. To match this, we set

$ar_{poly} = (1, -\phi_1, -\phi_2,..., -\phi_p)$$ma_{poly} = (1, \theta_1, \theta_2,..., \theta_q)$

In addition, ar_poly must be at least as long as ma_poly. This can be achieved by padding it out with zeros when required.

simulation(ts_length=90)[source]

Compute a simulated sample path assuming Gaussian shocks.

Parameters: ts_length : scalar(int), optional(default=90) Number of periods to simulate for vals : array_like(float) A simulation of the model that corresponds to this class
spectral_density(two_pi=True, res=1200)[source]

Compute the spectral density function. The spectral density is the discrete time Fourier transform of the autocovariance function. In particular,

$f(w) = \sum_k \gamma(k) exp(-ikw)$

where gamma is the autocovariance function and the sum is over the set of all integers.

Parameters: two_pi : Boolean, optional Compute the spectral density function over [0, pi] if two_pi is False and [0, 2 pi] otherwise. Default value is True res : scalar or array_like(int), optional(default=1200) If res is a scalar then the spectral density is computed at res frequencies evenly spaced around the unit circle, but if res is an array then the function computes the response at the frequencies given by the array w : array_like(float) The normalized frequencies at which h was computed, in radians/sample spect : array_like(float) The frequency response
theta