## Create Regression Models with MA Errors

These examples show how to create regression models with MA errors using `regARIMA`

. For details on specifying regression models with MA errors using
the Econometric
Modeler app, see Specify Regression Model with ARMA Errors Using Econometric Modeler App.

### Default Regression Model with MA Errors

This example shows how to apply the shorthand `regARIMA(p,D,q)`

syntax to specify the regression model with MA errors.

Specify the default regression model with MA(2) errors:

$$\begin{array}{l}{y}_{t}=c+{X}_{t}\beta +{u}_{t}\\ {u}_{t}={\epsilon}_{t}+{b}_{1}{\epsilon}_{t-1}+{b}_{2}{\epsilon}_{t-2}.\end{array}$$

Mdl = regARIMA(0,0,2)

Mdl = regARIMA with properties: Description: "ARMA(0,2) Error Model (Gaussian Distribution)" SeriesName: "Y" Distribution: Name = "Gaussian" Intercept: NaN Beta: [1×0] P: 0 Q: 2 AR: {} SAR: {} MA: {NaN NaN} at lags [1 2] SMA: {} Variance: NaN

The software sets each parameter to `NaN`

, and the innovation distribution to `Gaussian`

. The MA coefficients are at lags 1 and 2.

Pass `Mdl`

into `estimate`

with data to estimate the parameters set to `NaN`

. Though `Beta`

is not in the display, if you pass a matrix of predictors ($${X}_{t}$$) into `estimate`

, then `estimate`

estimates `Beta`

. The `estimate`

function infers the number of regression coefficients in `Beta`

from the number of columns in $${X}_{t}$$.

Tasks such as simulation and forecasting using `simulate`

and `forecast`

do not accept models with at least one `NaN`

for a parameter value. Use dot notation to modify parameter values.

### MA Error Model Without an Intercept

This example shows how to specify a regression model with MA errors without a regression intercept.

Specify the default regression model with MA(2) errors:

$$\begin{array}{l}{y}_{t}={X}_{t}\beta +{u}_{t}\\ {u}_{t}={\epsilon}_{t}+{b}_{1}{\epsilon}_{t-1}+{b}_{2}{\epsilon}_{t-2}.\end{array}$$

Mdl = regARIMA('MALags',1:2,'Intercept',0)

Mdl = regARIMA with properties: Description: "ARMA(0,2) Error Model (Gaussian Distribution)" SeriesName: "Y" Distribution: Name = "Gaussian" Intercept: 0 Beta: [1×0] P: 0 Q: 2 AR: {} SAR: {} MA: {NaN NaN} at lags [1 2] SMA: {} Variance: NaN

The software sets `Intercept`

to 0, but all other parameters in `Mdl`

are `NaN`

values by default.

Since `Intercept`

is not a `NaN`

, it is an equality constraint during estimation. In other words, if you pass `Mdl`

and data into `estimate`

, then `estimate`

sets `Intercept`

to 0 during estimation.

You can modify the properties of `Mdl`

using dot notation.

### MA Error Model with Nonconsecutive Lags

This example shows how to specify a regression model with MA errors, where the nonzero MA terms are at nonconsecutive lags.

Specify the regression model with MA(12) errors:

$$\begin{array}{l}{y}_{t}=c+{X}_{t}\beta +{u}_{t}\\ {u}_{t}={\epsilon}_{t}+{b}_{1}{\epsilon}_{t-1}+{b}_{12}{\epsilon}_{t-12}.\end{array}$$

`Mdl = regARIMA('MALags',[1, 12])`

Mdl = regARIMA with properties: Description: "ARMA(0,12) Error Model (Gaussian Distribution)" SeriesName: "Y" Distribution: Name = "Gaussian" Intercept: NaN Beta: [1×0] P: 0 Q: 12 AR: {} SAR: {} MA: {NaN NaN} at lags [1 12] SMA: {} Variance: NaN

The MA coefficients are at lags 1 and 12.

Verify that the MA coefficients at lags 2 through 11 are 0.

Mdl.MA'

`ans=`*12×1 cell array*
{[NaN]}
{[ 0]}
{[ 0]}
{[ 0]}
{[ 0]}
{[ 0]}
{[ 0]}
{[ 0]}
{[ 0]}
{[ 0]}
{[ 0]}
{[NaN]}

After applying the transpose, the software displays a 12-by-1 cell array. Each consecutive cell contains the corresponding MA coefficient value.

Pass `Mdl`

and data into `estimate`

. The software estimates all parameters that have the value `NaN`

. Then `estimate`

holds $${b}_{2}$$ = $${b}_{3}$$ =...= $${b}_{11}$$ = 0 during estimation.

### Known Parameter Values for a Regression Model with MA Errors

This example shows how to specify values for all parameters of a regression model with MA errors.

Specify the regression model with MA(2) errors:

$$\begin{array}{l}{y}_{t}={X}_{t}\left[\begin{array}{l}0.5\\ -3\\ 1.2\end{array}\right]+{u}_{t}\\ {u}_{t}={\epsilon}_{t}+0.5{\epsilon}_{t-1}-0.1{\epsilon}_{t-2},\end{array}$$

where $${\epsilon}_{t}$$ is Gaussian with unit variance.

Mdl = regARIMA('Intercept',0,'Beta',[0.5; -3; 1.2],... 'MA',{0.5, -0.1},'Variance',1)

Mdl = regARIMA with properties: Description: "Regression with ARMA(0,2) Error Model (Gaussian Distribution)" SeriesName: "Y" Distribution: Name = "Gaussian" Intercept: 0 Beta: [0.5 -3 1.2] P: 0 Q: 2 AR: {} SAR: {} MA: {0.5 -0.1} at lags [1 2] SMA: {} Variance: 1

The parameters in `Mdl`

do not contain `NaN`

values, and therefore there is no need to estimate `Mdl`

using `estimate`

. However, you can simulate or forecast responses from `Mdl`

using `simulate`

or `forecast`

.

### Regression Model with MA Errors and t Innovations

This example shows how to set the innovation distribution of a regression model with MA errors to a *t* distribution.

Specify the regression model with MA(2) errors:

$$\begin{array}{l}{y}_{t}={X}_{t}\left[\begin{array}{l}0.5\\ -3\\ 1.2\end{array}\right]+{u}_{t}\\ {u}_{t}={\epsilon}_{t}+0.5{\epsilon}_{t-1}-0.1{\epsilon}_{t-2},\end{array}$$

where $${\epsilon}_{t}$$ has a *t* distribution with the default degrees of freedom and unit variance.

Mdl = regARIMA('Intercept',0,'Beta',[0.5; -3; 1.2],... 'MA',{0.5, -0.1},'Variance',1,'Distribution','t')

Mdl = regARIMA with properties: Description: "Regression with ARMA(0,2) Error Model (t Distribution)" SeriesName: "Y" Distribution: Name = "t", DoF = NaN Intercept: 0 Beta: [0.5 -3 1.2] P: 0 Q: 2 AR: {} SAR: {} MA: {0.5 -0.1} at lags [1 2] SMA: {} Variance: 1

The default degrees of freedom is `NaN`

. If you don't know the degrees of freedom, then you can estimate it by passing `Mdl`

and the data to `estimate`

.

Specify a $${t}_{15}$$ distribution.

Mdl.Distribution = struct('Name','t','DoF',15)

Mdl = regARIMA with properties: Description: "Regression with ARMA(0,2) Error Model (t Distribution)" SeriesName: "Y" Distribution: Name = "t", DoF = 15 Intercept: 0 Beta: [0.5 -3 1.2] P: 0 Q: 2 AR: {} SAR: {} MA: {0.5 -0.1} at lags [1 2] SMA: {} Variance: 1

You can simulate and forecast responses from by passing `Mdl`

to `simulate`

or `forecast`

because `Mdl`

is completely specified.

In applications, such as simulation, the software normalizes the random *t* innovations. In other words, `Variance`

overrides the theoretical variance of the *t* random variable (which is `DoF`

/(`DoF`

- 2)), but preserves the kurtosis of the distribution.

## See Also

### Apps

### Objects

### Functions

## Related Examples

- Analyze Time Series Data Using Econometric Modeler
- Specifying Univariate Lag Operator Polynomials Interactively
- Create Regression Models with ARIMA Errors
- Specify Default Regression Model with ARIMA Errors
- Create Regression Models with AR Errors
- Create Regression Models with ARMA Errors
- Create Regression Models with SARIMA Errors
- Specify ARIMA Error Model Innovation Distribution