# arma2ma

Convert ARMA model to MA model

## Description

returns the coefficients of the truncated, infinite-order MA model approximation to
an ARMA model with input AR and MA coefficients.`ma`

= arma2ma(`ar0`

,`ma0`

)

`arma2ma:`

Accepts:

Vectors or cell vectors of matrices in difference-equation notation.

`LagOp`

lag operator polynomials corresponding to the AR and MA polynomials in lag operator notation.

Accommodates time series models that are univariate or multivariate (i.e.,

`numVars`

variables compose the model), stationary or integrated, structural or in reduced form, and invertible.Assumes that the model constant

*c*is 0.

## Examples

### Convert an ARMA model to an MA Model

Find the lag coefficients of the truncated, MA approximation of this univariate, stationary, and invertible ARMA model

$${y}_{t}=0.2{y}_{t-1}-0.1{y}_{t-2}+{\epsilon}_{t}+0.5{\epsilon}_{t-1}.$$

The ARMA model is in difference-equation notation because the left side contains only $${y}_{t}$$ and its coefficient 1. Create a vector containing the AR lag term coefficients in order starting from *t* - 1.

ar0 = [0.2 -0.1];

Alternatively, you can create a cell vector of the scalar coefficients.

Create a vector containing the MA lag term coefficient.

ma0 = 0.5;

Convert the ARMA model to an MA model by obtaining the coefficients of the truncated approximation of the infinite-lag polynomial.

ma = arma2ma(ar0,ma0)

`ma = `*1×4*
0.7000 0.0400 -0.0620 -0.0164

`ma`

is a numeric vector because `ar0`

and `ma0`

are numeric vectors.

The approximate MA model truncated at 4 lags is

$$\begin{array}{l}{y}_{t}={\epsilon}_{t}+0.7{\epsilon}_{t-1}+0.04{\epsilon}_{t-2}-0.062{\epsilon}_{t-3}-0.0164{\epsilon}_{t-4}.\end{array}$$

### Convert an AR(3) Model to an MA(5) Model

Find the first five lag coefficients of the MA approximation of this univariate and stationary AR(3) model

$${y}_{t}=-0.2{y}_{t-1}+0.5{y}_{t-3}+{\epsilon}_{t}.$$

The AR model is in difference-equation notation because the left side contains only $${y}_{t}$$ and its coefficient of 1. Create a cell vector containing the AR lag term coefficient in order starting from t - 1. Because the second lag term of the MA model is missing, specify a `0`

for its coefficient.

ar0 = {-0.2 0 0.5};

Convert the AR model to an MA model with at most five lag coefficients of the truncated approximation of the infinite-lag polynomial. Because there is no MA contribution, specify an empty cell (`{}`

) for the MA coefficients.

numLags = 5; ma0 = {}; ma = arma2ma(ar0,ma0,numLags)

`ma=`*1×5 cell array*
{[-0.2000]} {[0.0400]} {[0.4920]} {[-0.1984]} {[0.0597]}

`ma`

is a cell vector of scalars because at least one of `ar0`

and `ma0`

is a cell vector.

The approximate MA(5) model is

$${y}_{t}={\epsilon}_{t}-0.2{\epsilon}_{t-1}+0.04{\epsilon}_{t-2}+0.492{\epsilon}_{t-3}-0.1984{\epsilon}_{t-4}+0.0597{\epsilon}_{t-5}$$

### Convert a Structural VARMA model to a Structural VMA model

Find the coefficients of the truncated, structural VMA equivalent of the structural, stationary, and invertible VARMA model

$$\begin{array}{l}\left\{\left[\begin{array}{ccc}1& 0.2& -0.1\\ 0.03& 1& -0.15\\ 0.9& -0.25& 1\end{array}\right]+\left[\begin{array}{ccc}0.5& -0.2& -0.1\\ -0.3& -0.1& 0.1\\ 0.4& -0.2& -0.05\end{array}\right]{L}^{4}+\left[\begin{array}{ccc}0.05& -0.02& -0.01\\ -0.1& -0.01& -0.001\\ 0.04& -0.02& -0.005\end{array}\right]{L}^{8}\right\}{y}_{t}=\\ \left\{\left[\begin{array}{ccc}1& 0& 0\\ 0& 1& 0\\ 0& 0& 1\end{array}\right]+\left[\begin{array}{ccc}-0.02& 0.03& 0.3\\ 0.003& 0.001& 0.01\\ 0.3& 0.01& 0.01\end{array}\right]{L}^{4}\right\}{\epsilon}_{t}\end{array}$$

where $${y}_{t}={\left[{y}_{1t}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}{y}_{2t}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}{y}_{3t}\right]}^{\prime}$$ and $${\epsilon}_{t}={\left[{\epsilon}_{1t}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}{\epsilon}_{2t}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}{\epsilon}_{3t}\right]}^{\prime}$$.

The VARMA model is in lag operator notation because the response and innovation vectors are on opposite sides of the equation.

Create a cell vector containing the VAR matrix coefficients. Because this model is a structural model, start with the coefficient of $${y}_{t}$$ and enter the rest in order by lag. Construct a vector that indicates the degree of the lag term for the corresponding coefficients.

var0 = {[1 0.2 -0.1; 0.03 1 -0.15; 0.9 -0.25 1],... [0.5 -0.2 -0.1; -0.3 -0.1 0.1; 0.4 -0.2 -0.05],... [0.05 -0.02 -0.01; -0.1 -0.01 -0.001; 0.04 -0.02 -0.005]}; var0Lags = [0 4 8];

Create a cell vector containing the VMA matrix coefficients. Because this model is a structural model, start with the coefficient of $${\epsilon}_{t}$$ and enter the rest in order by lag. Construct a vector that indicates the degree of the lag term for the corresponding coefficients.

```
vma0 = {eye(3),...
[-0.02 0.03 0.3; 0.003 0.001 0.01; 0.3 0.01 0.01]};
vma0Lags = [0 4];
```

`arma2ma`

requires `LagOp`

lag operator polynomials for input arguments that comprise structural VAR or VMA models. Construct separate `LagOp`

polynomials that describe the VAR and VMA components of the VARMA model.

VARLag = LagOp(var0,'Lags',var0Lags); VMALag = LagOp(vma0,'Lags',vma0Lags);

`VARLags`

and `VMALags`

are `LagOp`

lag operator polynomials that describe the VAR and VMA components of the VARMA model.

Convert the VARMA model to a VMA model by obtaining the coefficients of the truncated approximation of the infinite-lag polynomial. Specify to return at most 12 lagged terms.

numLags = 12; VMA = arma2ma(VARLag,VMALag,numLags)

VMA = 3-D Lag Operator Polynomial: ----------------------------- Coefficients: [Lag-Indexed Cell Array with 4 Non-Zero Coefficients] Lags: [0 4 8 12] Degree: 12 Dimension: 3

`VMA`

is a `LagOP`

lag operator polynomial. All coefficients except those corresponding to lags 0, 4, 8, and 12 are 3-by-3 matrices of zeros.

Display the nonzero coefficients of the resulting VMA model.

lag2Idx = VMA.Lags + 1; % Lags start at 0. Add 1 to convert to indices. vmaCoeff = toCellArray(VMA); for j = 1:numel(lag2Idx) fprintf('___________Lag %d__________\n',lag2Idx(j) - 1) fprintf('%8.3f %8.3f %8.3f \n',vmaCoeff{lag2Idx(j)}) fprintf ('__________________________\n') end

___________Lag 0__________

0.943 -0.162 -0.889 -0.172 1.068 0.421 0.069 0.144 0.974

__________________________

___________Lag 4__________

-0.650 0.460 0.546 0.370 0.000 -0.019 0.383 -0.111 -0.312

__________________________

___________Lag 8__________

0.431 -0.138 -0.089 -0.170 0.122 0.065 -0.260 0.165 0.089

__________________________

___________Lag 12__________

-0.216 0.078 0.047 0.099 -0.013 -0.011 0.153 -0.042 -0.026

__________________________

### Unconditional Mean of ARMA Model

Find the lag coefficients and constant of the truncated MA approximation of this univariate, stationary, and invertible ARMA model

$${y}_{t}=1.5+0.2{y}_{t-1}-0.1{y}_{t-2}+{\epsilon}_{t}+0.5{\epsilon}_{t-1}.$$

The ARMA model is in difference-equation notation because the left side contains only $${y}_{t}$$ and its coefficient of 1. Create separate vectors for the AR and MA lag term coefficients in order starting from *t* - 1.

ar0 = [0.2 -0.1]; ma0 = 0.5;

Convert the ARMA model to an MA model by obtaining the first five coefficients of the truncated approximation of the infinite-lag polynomial.

numLags = 5; ar = arma2ma(ar0,ma0,numLags)

`ar = `*1×5*
0.7000 0.0400 -0.0620 -0.0164 0.0029

To compute the constant of the MA model, consider the ARMA model in lag operator notation.

$$(1-0.2L+0.1{L}^{2}){y}_{t}=1.5+(1+0.5L){\epsilon}_{t}$$

or

$$\Phi (L){y}_{t}=1.5+\Theta (L){\epsilon}_{t}$$

Part of the conversion involves premultiplying both sides of the equation by the inverse of the AR lag operator polynomial, as in this equation.

$${y}_{t}={\Phi}^{-1}(L)1.5+{\Phi}^{-1}(L)\Theta (L){\epsilon}_{t}$$

To compute the inverse of AR lag operator polynomial, use the lag operator left-division object function `mldivide`

.

```
Phi = LagOp([1 -0.2 0.1]);
PhiInv = mldivide(Phi,1,'RelTol',1e-5);
```

`PhiInv`

is a `LagOp`

lag operator polynomial.

The application of lag operator polynomials to constants results in the product of the constant with the sum of the coefficients. Apply `PhiInv`

to the ARMA model constant to obtain the MA model constant.

maConstant = 1.5*sum(cell2mat(toCellArray(PhiInv)))

maConstant = 1.6667

The approximate MA model is

$${y}_{t}=1.667+0.7{\epsilon}_{t-1}+0.04{\epsilon}_{t-2}-0.062{\epsilon}_{t-3}-0.0164{\epsilon}_{t-4}+0.0029{\epsilon}_{t-5}+{\epsilon}_{t}.$$

Since the unconditional expected value of all innovations is 0, the unconditional expected value (or mean) of the response series is

$$E\left({y}_{t}\right)=1.667.$$

## Input Arguments

`ar0`

— Autoregressive coefficients

numeric vector | cell vector of square, numeric matrices | `LagOp`

lag operator polynomial object

Autoregressive coefficients of the ARMA(*p*,*q*)
model, specified as a numeric vector, cell vector of square, numeric
matrices, or a `LagOp`

lag
operator polynomial object. If `ar0`

is a vector
(numeric or cell), then the coefficient of *y _{t}* is
the identity. To specify a structural AR polynomial (i.e., the coefficient
of

*y*is not the identity), use

_{t}`LagOp`

lag operator polynomials.For univariate time series models,

`ar0`

is a numeric vector, cell vector of scalars, or a one-dimensional`LagOp`

lag operator polynomial. For vectors,`ar0`

has length*p*and the elements correspond to lagged responses composing the AR polynomial in difference-equation notation. That is,`ar0(j)`

or`ar0{j}`

is the coefficient of*y*._{t-j}For

`numVars`

-dimensional time series models,`ar0`

is a cell vector of`numVars`

-by-`numVars`

numeric matrices or a`numVars`

-dimensional`LagOp`

lag operator polynomial. For cell vectors:`ar0`

has length*p*.`ar0`

and`ma0`

must contain`numVars`

-by-`numVars`

matrices.The elements of

`ar0`

correspond to the lagged responses composing the AR polynomial in difference equation notation. That is,`ar0{j}`

is the coefficient matrix of*y*._{t-j}Row

*k*of an AR coefficient matrix contains the AR coefficients in the equation of the variable*y*. Subsequently, column_{k}*k*must correspond to variable*y*, and the column and row order of all autoregressive and moving average coefficients must be consistent._{k}

For

`LagOp`

lag operator polynomials:The first element of the

`Coefficients`

property corresponds to the coefficient of*y*(to accommodate structural models). All other elements correspond to the coefficients of the subsequent lags in the_{t}`Lags`

property.To construct a univariate model in reduced form, specify

`1`

for the first coefficient. For`numVars`

-dimensional multivariate models, specify`eye(numVars)`

for the first coefficient.When you work from a model in difference-equation notation, negate the AR coefficient of the lagged terms to construct the lag-operator polynomial equivalent. For example, consider $${y}_{t}=0.5{y}_{t-1}-0.8{y}_{t-2}+{\epsilon}_{t}-0.6{\epsilon}_{t-1}+0.08{\epsilon}_{t-2}$$. The model is in difference-equation notation. To convert to an MA model, enter the following into the command window.

ma = arma2ma([0.5 -0.8], [-0.6 0.08]);

The ARMA model in lag operator notation is $$\left(1-0.5L+0.8{L}^{2}\right){y}_{t}=\left(1-0.6L+0.08{L}^{2}\right){\epsilon}_{t}.$$ The AR coefficients of the lagged responses are negated compared to the corresponding coefficients in difference-equation format. In this form, to obtain the same result, enter the following into the command window.

ar0 = LagOp({1 -0.5 0.8}); ma0 = LagOp({1 -0.6 0.08}); ma = arma2ma(ar0, ma0);

It is a best practice for `ar0`

to constitute
a stationary or unit-root stationary (integrated) time series model.

`ma0`

— Moving average coefficients

numeric vector | cell vector of square, numeric matrices | `LagOp`

lag operator polynomial object

Moving average coefficients of the ARMA(*p*,*q*)
model, specified as a numeric vector, cell vector of square, numeric
matrices, or a `LagOp`

lag
operator polynomial object. If `ma0`

is a vector
(numeric or cell), then the coefficient of *ε _{t}* is
the identity. To specify a structural MA polynomial (i.e., the coefficient
of

*ε*is not the identity), use

_{t}`LagOp`

lag operator polynomials.For univariate time series models,

`ma0`

is a numeric vector, cell vector of scalars, or a one-dimensional`LagOp`

lag operator polynomial. For vectors,`ma0`

has length*q*and the elements correspond to lagged innovations composing the AR polynomial in difference-equation notation. That is,`ma0(j)`

or`ma0{j}`

is the coefficient of*ε*._{t-j}For

`numVars`

-dimensional time series models,`ma0`

is a cell vector of numeric`numVars`

-by-`numVars`

numeric matrices or a`numVars`

-dimensional`LagOp`

lag operator polynomial. For cell vectors:`ma0`

has length*q*.`ar0`

and`ma0`

must both contain`numVars`

-by-`numVars`

matrices.The elements of

`ma0`

correspond to the lagged responses composing the AR polynomial in difference equation notation. That is,`ma0{j}`

is the coefficient matrix of*y*._{t-j}

For

`LagOp`

lag operator polynomials:The first element of the

`Coefficients`

property corresponds to the coefficient of*ε*(to accommodate structural models). All other elements correspond to the coefficients of the subsequent lags in the_{t}`Lags`

property.To construct a univariate model in reduced form, specify

`1`

for the first coefficient. For`numVars`

-dimensional multivariate models, specify`eye(numVars)`

for the first coefficient.

If the ARMA model is strictly an AR model, then specify `[]`

or `{}`

.

It is a best practice for `ma0`

to constitute
an invertible time series model.

`numLags`

— Maximum number of lag-term coefficients to return

positive integer

Maximum number of lag-term coefficients to return, specified as a positive integer.

If you specify `'numLags'`

, then `arma2ma`

truncates
the output polynomial at a maximum of `numLags`

lag
terms, and then returns the remaining coefficients. As a result, the
output vector has `numLags`

elements or is at most
a degree `numLags`

`LagOp`

lag
operator polynomial.

By default, `arma2ma`

determines the
number of lag coefficients to return by the stopping criteria of `mldivide`

.

**Data Types: **`double`

## Output Arguments

`ma`

— Lag-term coefficients of the truncated MA model

numeric vector | cell vector of square, numeric matrices | `LagOp`

lag operator polynomial object

Lag-term coefficients of the truncated MA model approximation
of the ARMA model, returned as a numeric vector, cell vector of square,
numeric matrices, or a `LagOp`

lag
operator polynomial object. `ma`

has `numLags`

elements,
or is at most a degree `numLags`

`LagOp`

lag
operator polynomial.

The data types and orientations of `ar0`

and `ma0`

determine
the data type and orientation of `ma`

. If `ar0`

or `ma0`

are
of the same data type or have the same orientation, then `ma`

shares
the common data type or orientation. If at least one of `ar0`

or `ma0`

is
a `LagOp`

lag operator polynomial, then `ma`

is
a `LagOp`

lag operator polynomial. Otherwise, if
at least one of `ar0`

or `ma0`

is
a cell vector, then `ma`

is a cell vector. If `ar0`

and `ma0`

are
cell or numeric vectors and at least one is a row vector, then `ma`

is
a row vector.

If `ma`

is a cell or numeric vector, then the
order of the elements of `ma`

corresponds to the
order of the coefficients of the lagged innovations in difference-equation notation starting with
the coefficient of *ε*_{t-1}.
The resulting MA model is in reduced form.

If `ma`

is a `LagOp`

lag operator
polynomial, then the order of the coefficients of `ma`

corresponds
to the order of the coefficients of the lagged innovations in lag operator notation starting
with the coefficient of *ε*_{t}.
If *Θ _{0}* ≠

*I*

_{numVars}, then the resulting MA model is structural.

## More About

### Difference-Equation Notation

A linear time series model written in *difference-equation
notation* positions the present value of the response and
its structural coefficient on the left side of the equation. The right
side of the equation contains the sum of the lagged responses, present
innovation, and lagged innovations with corresponding coefficients.

In other words, a linear time series written in difference-equation notation is

$${\Phi}_{0}{y}_{t}=c+{\Phi}_{1}{y}_{t-1}+\mathrm{...}+{\Phi}_{p}{y}_{t-p}+{\Theta}_{0}{\epsilon}_{t}+{\Theta}_{1}{\epsilon}_{t-1}+\mathrm{...}+{\Theta}_{q}{\epsilon}_{t-q},$$

where

*y*is a_{t}`numVars`

-dimensional vector representing the responses of`numVars`

variables at time*t*, for all*t*and for`numVars`

≥ 1.*ε*is a_{t}`numVars`

-dimensional vector representing the innovations at time*t*.*Φ*is the_{j}`numVars`

-by-`numVars`

matrix of AR coefficients of the response*y*, for_{t-j}*j*= 0,...,*p*.*Θ*is the_{k}`numVars`

-by-`numVars`

matrix of MA coefficients of the innovation*ε*,_{t-k}.*k*= 0,...,*q*.*c*is the*n*-dimensional model constant.*Φ*_{0}=*Θ*_{0}=*I*_{numVars}, which is the`numVars`

-dimensional identity matrix, for models in reduced form.

### Lag Operator Notation

A time series model written in *lag operator notation*
positions a *p*-degree lag operator polynomial on the present
response on the left side of the equation. The right side of the equation contains
the model constant and a *q*-degree lag operator polynomial on the
present innovation.

In other words, a linear time series model written in lag operator notation is

$$\Phi (L){y}_{t}=c+\Theta (L){\epsilon}_{t},$$

where

*y*is a_{t}`numVars`

-dimensional vector representing the responses of`numVars`

variables at time*t*, for all*t*and for`numVars`

≥ 1.$$\Phi (L)={\Phi}_{0}-{\Phi}_{1}L-{\Phi}_{2}{L}^{2}-\mathrm{...}-{\Phi}_{p}{L}^{p}$$, which is the autoregressive, lag operator polynomial.

*L*is the back-shift operator, in other words, $${L}^{j}{y}_{t}={y}_{t-j}$$.*Φ*is the_{j}`numVars`

-by-`numVars`

matrix of AR coefficients of the response*y*, for_{t-j}*j*= 0,...,*p*.*ε*is a_{t}`numVars`

-dimensional vector representing the innovations at time*t*.$$\Theta (L)={\Theta}_{0}+{\Theta}_{1}L+{\Theta}_{2}{L}^{2}+\mathrm{...}+{\Theta}_{q}{L}^{q}$$, which is the moving average, lag operator polynomial.

*Θ*is the_{k}`numVars`

-by-`numVars`

matrix of MA coefficients of the innovation*ε*,_{t-k}.*k*= 0,...,*q*.*c*is the`numVars`

-dimensional model constant.*Φ*_{0}=*Θ*_{0}=*I*

, which is the_{numVars}`numVars`

-dimensional identity matrix, for models in reduced form.

When comparing lag operator notation to difference-equation notation, the signs of the lagged AR coefficients appear negated relative to the corresponding terms in difference-equation notation. The signs of the moving average coefficients are the same and appear on the same side.

For more details on lag operator notation, see Lag Operator Notation.

## Tips

## Algorithms

The software computes the infinite-lag polynomial of the resulting MA model according to this equation in lag operator notation:

$${y}_{t}={\Phi}^{-1}(L)\Theta (L){\epsilon}_{t}$$

where $$\Phi (L)={\displaystyle \sum _{j=0}^{p}{\Phi}_{j}}{L}^{j}$$ and $$\Theta (L)={\displaystyle \sum _{k=0}^{q}{\Theta}_{k}}{L}^{k}.$$

`arma2ma`

approximates the MA model coefficients whether`ar0`

and`ma0`

compose a stable polynomial (a polynomial that is stationary or invertible). To check for stability, use`isStable`

.`isStable`

requires a`LagOp`

lag operator polynomial as input. For example, if`ar0`

is a vector, enter the following code to check`ar0`

for stationarity.ar0LagOp = LagOp([1 -ar0]); isStable(ar0LagOp)

A

`0`

indicates that the polynomial is not stable.You can similarly check whether the MA approximation to the ARMA model (

`ma`

) is invertible.

## References

[1] Box, G. E. P., G. M. Jenkins, and G. C. Reinsel. *Time
Series Analysis: Forecasting and Control* 3rd ed. Englewood
Cliffs, NJ: Prentice Hall, 1994.

[2] Hamilton, J. D. *Time Series Analysis*.
Princeton, NJ: Princeton University Press, 1994.

[3] Lutkepohl, H. *New Introduction to Multiple
Time Series Analysis.* Springer-Verlag, 2007.

## Version History

**Introduced in R2015a**

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)