# arima

Create univariate autoregressive integrated moving average (ARIMA) model

## Description

The arima function returns an arima object specifying the functional form and storing the parameter values of an ARIMA(p,D,q) linear time series model for a univariate response process yt.

arima enables you to create variations of the ARIMA model, including:

• An autoregressive (AR(p)), moving average (MA(q)), or ARMA(p,q) model.

• A model containing multiplicative seasonal components (SARIMA(p,D,q)⨉(ps,Ds,qs)s).

• A model containing a linear regression component for exogenous covariates (ARIMAX).

• A composite conditional mean and conditional variance model. For example, you can create an ARMA conditional mean model containing a GARCH conditional variance model (garch).

The key components of an arima object are the polynomial degrees (for example, the AR polynomial degree p and the degree of integration D) because they completely specify the model structure. Given polynomial degrees, all other parameters, such as coefficients and innovation-distribution parameters, are unknown and estimable unless you specify their values.

To estimate a model containing unknown parameter values, pass the model and data to estimate. To work with an estimated or fully specified arima object, pass it to an object function.

Alternatively, you can:

## Creation

### Description

example

Mdl = arima creates an ARIMA(0,0,0) model containing only an unknown constant and a series of iid Gaussian innovations with mean 0 and an unknown variance.

example

Mdl = arima(p,D,q) creates an ARIMA(p,D,q) model containing nonseasonal AR polynomial lags from 1 through p, the degree D nonseasonal integration polynomial, and nonseasonal MA polynomial lags from 1 through q.

This shorthand syntax provides an easy way to create a model template in which you specify the degrees of the nonseasonal polynomials explicitly. The model template is suited for unrestricted parameter estimation. After you create a model, you can alter property values using dot notation.

example

Mdl = arima(Name,Value) sets properties and polynomial lags using name-value pair arguments. Enclose each name in quotes. For example, 'ARLags',[1 4],'AR',{0.5 –0.1} specifies the values –0.5 and 0.1 for the nonseasonal AR polynomial coefficients at lags 1 and 4, respectively.

This longhand syntax allows you to create more flexible models. arima infers all polynomial degrees from the properties that you set. Therefore, property values that correspond to polynomial degrees must be consistent with each other.

### Input Arguments

expand all

The shorthand syntax provides an easy way for you to create nonseasonal ARIMA model templates that are suitable for unrestricted parameter estimation. For example, to create an ARMA(2,1) model containing unknown coefficients and innovations variance, enter:

Mdl = arima(2,0,1);
To impose equality constraints on parameter values during estimation, or include seasonal components, set the appropriate property values using dot notation.

Nonseasonal autoregressive polynomial degree, specified as a nonnegative integer.

Data Types: double

Degree of nonseasonal integration (the degree of the nonseasonal differencing polynomial), specified as a nonnegative integer. D sets the property D.

Data Types: double

Nonseasonal moving average polynomial degree, specified as a nonnegative integer.

Data Types: double

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

The longhand syntax enables you to create seasonal models or models in which some or all coefficients are known. During estimation, estimate imposes equality constraints on any known parameters.

Example: 'ARLags',[1 4],'AR',{0.5 –0.1} specifies the nonseasonal AR polynomial $1-0.5{L}^{1}+0.1{L}^{4}$.

Lags associated with the nonseasonal AR polynomial coefficients, specified as the comma-separated pair consisting of 'ARLags' and a numeric vector of unique positive integers. The maximum lag is p.

AR{j} is the coefficient of lag ARLags(j).

Example: 'ARLags',[1 4] specifies the nonseasonal AR polynomial $1-{\varphi }_{1}{L}^{1}-{\varphi }_{4}{L}^{4}.$

Data Types: double

Lags associated with the nonseasonal MA polynomial coefficients, specified as the comma-separated pair consisting of 'MALags' and a numeric vector of unique positive integers. The maximum lag is q.

MA{j} is the coefficient of lag MALags(j).

Example: 'MALags',1:3 specifies the nonseasonal MA polynomial $1+{\theta }_{1}{L}^{1}+{\theta }_{2}{L}^{2}+{\theta }_{3}{L}^{3}.$

Data Types: double

Lags associated with the seasonal AR polynomial coefficients, specified as the comma-separated pair consisting of 'SARLags' and a numeric vector of unique positive integers. The maximum lag is ps.

SAR{j} is the coefficient of lag SARLags(j).

Specify SARLags as the periodicity of the observed data, and not as multiples of the Seasonality property. This convention does not conform to standard Box and Jenkins [1] notation, but it is more flexible for incorporating multiplicative seasonality.

Example: 'SARLags',[4 8] specifies the seasonal AR polynomial $1-{\Phi }_{4}{L}^{4}-{\Phi }_{8}{L}^{8}.$

Data Types: double

Lags associated with the seasonal MA polynomial coefficients, specified as the comma-separated pair consisting of 'SMALags' and a numeric vector of unique positive integers. The maximum lag is qs.

SMA{j} is the coefficient of lag SMALags(j).

Specify SMALags as the periodicity of the observed data, and not as multiples of the Seasonality property. This convention does not conform to standard Box and Jenkins [1] notation, but it is more flexible for incorporating multiplicative seasonality.

Example: 'SMALags',4 specifies the seasonal MA polynomial $1+{\Theta }_{4}{L}^{4}.$

Data Types: double

Note

Polynomial degrees are not estimable. If you do not specify a polynomial degree, or arima cannot infer it from other specifications, arima does not include the polynomial in the model.

## Properties

expand all

You can set writable property values when you create the model object by using name-value pair argument syntax, or after you create the model object by using dot notation. For example, to create a fully specified ARMA(2,1) model, enter:

Mdl = arima('Constant',1,'AR',{0.3 -0.15},'MA',0.2);
Mdl.Variance = 1;

Note

• NaN-valued properties indicate estimable parameters. Numeric properties indicate equality constraints on parameters during model estimation. Coefficient vectors can contain both numeric and NaN-valued elements.

• You can specify polynomial coefficients as vectors in any orientation, but arima stores them as row vectors.

Compound AR polynomial degree, specified as a nonnegative integer.

P does not necessarily conform to standard Box and Jenkins notation [1] because P captures the degrees of the nonseasonal and seasonal AR polynomials (properties AR and SAR, respectively), nonseasonal integration (property D), and seasonality (property Seasonality). Explicitly, P = p + D + ps + s. P conforms to Box and Jenkins notation for models without integration or a seasonal AR component.

P specifies the number of lagged observations required to initialize the AR components of the model.

Data Types: double

Compound MA polynomial degree, specified as a nonnegative integer.

Q does not necessarily conform to standard Box and Jenkins notation [1] because Q captures the degrees of the nonseasonal and seasonal MA polynomials (properties MA and SMA, respectively). Explicitly, Q = q + qs. Q conforms to Box and Jenkins notation for models without a seasonal MA component.

Q specifies the number of lagged innovations required to initialize the MA components of the model.

Data Types: double

Model description, specified as a string scalar or character vector. arima stores the value as a string scalar. The default value describes the parametric form of the model, for example "ARIMAX(1,1,1) Model (Gaussian Distribution)".

Example: "Model 1"

Data Types: string | char

Conditional probability distribution of the innovation process, specified as a string or structure array. arima stores the value as a structure array.

DistributionStringStructure Array
Gaussian"Gaussian"struct('Name',"Gaussian")
Student’s t"t"struct('Name',"t",'DoF',DoF)

The 'DoF' field specifies the t distribution degrees of freedom parameter.

• DoF > 2 or DoF = NaN.

• DoF is estimable.

• If you specify "t", DoF is NaN by default. You can change its value by using dot notation after you create the model. For example, Mdl.Distribution.DoF = 3.

• If you supply a structure array to specify the Student's t distribution, then you must specify both the 'Name' and 'DoF' fields.

Example: struct('Name',"t",'DoF',10)

Model constant, specified as a numeric scalar.

Example: 1

Data Types: double

Nonseasonal AR polynomial coefficients, specified as a cell vector. Cells contain numeric scalars or NaN values. A fully specified nonseasonal AR polynomial must be stable.

Coefficient signs correspond to the model expressed in difference-equation notation. For example, for the nonseasonal AR polynomial $\varphi \left(L\right)=1-0.5L+0.1{L}^{2},$ specify 'AR',{0.5 –0.1}.

• If you use the shorthand syntax to specify p > 0, AR{j} has the value NaN and it is the coefficient of lag j, j = 1,…,p.

• If you set the 'ARLags' name-value pair argument to ARLags, the following conditions apply.

• The lengths of AR and ARLags must be equal.

• AR{j} is the coefficient of lag ARLags(j), for all j in ARLags.

• By default, AR{j} = NaN for all j in ARLags.

• Otherwise, AR is empty and the model does not contain a nonseasonal AR polynomial.

The coefficients in AR correspond to coefficients in an underlying LagOp lag operator polynomial, and are subject to a near-zero tolerance exclusion test. If you set a coefficient to 1e–12 or below, arima excludes that coefficient and its corresponding lag in ARLags from the model.

Example: {0.8}

Example: {NaN –0.1}

Data Types: cell

Seasonal AR polynomial coefficients, specified as a cell vector. Cells contain numeric scalars or NaN values. A fully specified seasonal AR polynomial must be stable.

Coefficient signs correspond to the model expressed in difference-equation notation. For example, for the seasonal AR polynomial $\Phi \left(L\right)=1-0.5{L}^{4}+0.1{L}^{8},$ specify 'SAR',{0.5 –0.1}.

• If you set the 'SARLags' name-value pair argument to SARLags, the following conditions apply.

• The lengths of SAR and SARLags must be equal.

• SAR{j} is the coefficient of lag SARLags(j), for all j in SARLags.

• By default, SAR{j} = NaN for all j in SARLags.

• Otherwise, SAR is empty and the model does not contain a seasonal AR polynomial.

The coefficients in SAR correspond to coefficients in an underlying LagOp lag operator polynomial, and are subject to a near-zero tolerance exclusion test. If you set a coefficient to 1e–12 or below, arima excludes that coefficient and its corresponding lag in SARLags from the model.

Example: {0.2 0.1}

Example: {NaN 0 0 NaN}

Data Types: cell

Nonseasonal MA polynomial coefficients, specified as a cell vector. Cells contain numeric scalars or NaN values. A fully specified nonseasonal MA polynomial must be invertible.

• If you use the shorthand syntax to specify q > 0, MA{j} has value the NaN and it is the coefficient of lag j, j = 1,…,q.

• If you set the 'MALags' name-value pair argument to MALags, the following conditions apply.

• The lengths of MA and MALags must be equal.

• MA{j} is the coefficient of lag MALags(j), for all j in MALags.

• By default, MA{j} = NaN for all j in MALags.

• Otherwise, MA is empty and the model does not contain a nonseasonal MA polynomial.

The coefficients in MA correspond to coefficients in an underlying LagOp lag operator polynomial, and are subject to a near-zero tolerance exclusion test. If you set a coefficient to 1e–12 or below, arima excludes that coefficient and its corresponding lag in MALags from the model.

Example: 0.8

Example: {NaN –0.1}

Data Types: cell

Seasonal MA polynomial coefficients, specified as a cell vector. Cells contain numeric scalars or NaN values. A fully specified seasonal MA polynomial must be invertible.

• If you set the 'SMALags' name-value pair argument to SMALags, the following conditions apply.

• The lengths of SMA and SMALags must be equal.

• SMA{j} is the coefficient of lag SMALags(j), for all j in SMALags.

• By default, SMA{j} = NaN for all j in SMALags.

• Otherwise, SMA is empty and the model does not contain a seasonal MA polynomial.

The coefficients in SMA correspond to coefficients in an underlying LagOp lag operator polynomial, and are subject to a near-zero tolerance exclusion test. If you set a coefficient to 1e–12 or below, arima excludes that coefficient and its corresponding lag in SMALags from the model.

Example: {0.2 0.1}

Example: {NaN 0 0 NaN}

Data Types: cell

Degree of nonseasonal integration, or the degree of the nonseasonal differencing polynomial, specified as a nonnegative integer.

Example: 1

Data Types: double

Degree of the seasonal differencing polynomial s, specified as a nonnegative integer.

Example: 12 specifies monthly periodicity.

Data Types: double

Regression component coefficients of the conditional mean, specified as a numeric vector.

If you plan to estimate all elements of Beta, you do not need to specify it. During estimation, estimate infers the size of Beta from the number of columns of the specified exogenous data X.

Example: [0.5 NaN 3]

Data Types: double

Model innovations variance, specified as a positive scalar or a supported conditional variance model object (for example, garch). For all supported conditional variance models, see Conditional Variance Models.

A positive scalar or NaN specifies a homoscedastic model. A conditional variance model object specifies a composite conditional mean and variance model. estimate fits all unknown, estimable parameters in the composition.

Example: 1

Example: garch(1,0)

Data Types: double

## Object Functions

 estimate Fit autoregressive integrated moving average (ARIMA) model to data summarize Display ARIMA model estimation results infer Infer ARIMA or ARIMAX model residuals or conditional variances filter Filter disturbances using ARIMA or ARIMAX model impulse Impulse response function simulate Monte Carlo simulation of ARIMA or ARIMAX models forecast Forecast ARIMA or ARIMAX model responses or conditional variances

## Examples

collapse all

Create a default ARIMA model by using arima.

Mdl = arima
Mdl =
arima with properties:

Description: "ARIMA(0,0,0) Model (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 0
D: 0
Q: 0
Constant: NaN
AR: {}
SAR: {}
MA: {}
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: NaN

Mdl is an arima object. Properties of the model appear at the command line.

The default model is

${y}_{t}=c+{\epsilon }_{t}$,

where $\mathit{c}$ is an unknown constant and ${\epsilon }_{\mathit{t}}\text{\hspace{0.17em}}$ is a series of iid Gaussian random variables with mean 0 and variance ${\sigma }^{2}$.

Mdl is a model template for estimation. You can modify property values by using dot notation or fit the model to data by using estimate, but you cannot pass Mdl to any other object function.

Create the ARIMA(2,1,1) model represented by this equation:

$\left(1+0.5{L}^{2}\right)\left(1-L\right){y}_{t}=3.1+\left(1-0.2L\right){\epsilon }_{t},$

where ${\epsilon }_{\mathit{t}}$ is a series of iid Gaussian random variables. Use the longhand syntax to specify parameter values in the equation written in difference-equation notation:

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

Mdl = arima('ARLags',2,'AR',-0.5,'D',1,'MA',-0.2,...
'Constant',3.1)
Mdl =
arima with properties:

Description: "ARIMA(2,1,1) Model (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 3
D: 1
Q: 1
Constant: 3.1
AR: {-0.5} at lag [2]
SAR: {}
MA: {-0.2} at lag [1]
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: NaN

Mdl is a fully specified arima object because all its parameters are known. You can pass Mdl to any arima object function except estimate. For example, plot the impulse response function of the model for 24 periods by using impulse.

impulse(Mdl,24)

Create the AR(1) model represented by this equation:

${y}_{t}=1+\varphi {y}_{t-1}+{\epsilon }_{t},$

where ${\epsilon }_{\mathit{t}}$ is a series of iid Gaussian random variables with mean 0 and variance 0.5. Use the shorthand syntax to specify an AR(1) model template, then use dot notation to set the Constant and Variance properties.

Mdl = arima(1,0,0);
Mdl.Constant = 1;
Mdl.Variance = 0.5;
Mdl
Mdl =
arima with properties:

Description: "ARIMA(1,0,0) Model (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 1
D: 0
Q: 0
Constant: 1
AR: {NaN} at lag [1]
SAR: {}
MA: {}
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: 0.5

Mdl is a partially specified arima object. You can modify property values by using dot notation or fit the unknown coefficient $\varphi$ to data by using estimate, but you cannot pass Mdl to any other object function.

Create the ARIMA(3,1,2) model represented by this equation:

$\left(1-{\varphi }_{1}L-{\varphi }_{2}{L}^{2}-{\varphi }_{3}{L}^{3}\right)\left(1-L\right){y}_{t}=\left(1+{\theta }_{1}L+{\theta }_{2}{L}^{2}\right){\epsilon }_{t}$,

where ${\epsilon }_{\mathit{t}}$ is a series of iid Gaussian random variables with mean 0 and variance ${\sigma }^{2}$.

Because the model contains only nonseasonal polynomials, use the shorthand syntax.

Mdl = arima(3,1,2)
Mdl =
arima with properties:

Description: "ARIMA(3,1,2) Model (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 4
D: 1
Q: 2
Constant: NaN
AR: {NaN NaN NaN} at lags [1 2 3]
SAR: {}
MA: {NaN NaN} at lags [1 2]
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: NaN

The property P is equal to $p$ + $D$ = 4. NaN-valued elements indicate estimable parameters.

To include additive seasonal lags, specify the lags matching the appropriate periodicity. For example, create the additive monthly MA(12) model represented in this equation:

${y}_{t}={\epsilon }_{t}+{\theta }_{1}{\epsilon }_{t-1}+{\theta }_{12}{\epsilon }_{t-12},$

where ${\epsilon }_{\mathit{t}}$ is a series of iid Gaussian random variables with mean 0 and variance ${\sigma }^{2}$.

Mdl = arima('Constant',0,'MALags',[1 12])
Mdl =
arima with properties:

Description: "ARIMA(0,0,12) Model (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 0
D: 0
Q: 12
Constant: 0
AR: {}
SAR: {}
MA: {NaN NaN} at lags [1 12]
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: NaN

Create the SARIMA$\left(0,1,1\right)×{\left(0,1,1\right)}_{12}$ model (multiplicative, monthly MA model template with one degree of seasonal and nonseasonal integration) represented by this equation:

$\left(1-L\right)\left(1-{L}^{12}\right){y}_{t}=\left(1+{\theta }_{1}L\right)\left(1+{\theta }_{12}{L}^{12}\right){\epsilon }_{t},$

where ${\epsilon }_{\mathit{t}}$ is a series of iid Gaussian random variables with mean 0 and variance ${\sigma }^{2}$.

Mdl = arima('Constant',0,'D',1,'Seasonality',12,...
'MALags',1,'SMALags',12)
Mdl =
arima with properties:

Description: "ARIMA(0,1,1) Model Seasonally Integrated with Seasonal MA(12) (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 13
D: 1
Q: 13
Constant: 0
AR: {}
SAR: {}
MA: {NaN} at lag [1]
SMA: {NaN} at lag [12]
Seasonality: 12
Beta: [1×0]
Variance: NaN

Create the AR(3) model represented by this equation:

${y}_{t}=0.05+0.6{y}_{t-1}+0.2{y}_{t-2}-0.1{y}_{t-3}+{\epsilon }_{t},$

where ${\epsilon }_{t}$ is a series of iid Gaussian random variables with mean 0 and variance 0.01.

Mdl = arima('Constant',0.05,'AR',{0.6,0.2,-0.1},'Variance',0.01)
Mdl =
arima with properties:

Description: "ARIMA(3,0,0) Model (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 3
D: 0
Q: 0
Constant: 0.05
AR: {0.6 0.2 -0.1} at lags [1 2 3]
SAR: {}
MA: {}
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: 0.01

Add a nonseasonal MA term at lag 2 with coefficient 0.2. Then, display the MA property.

Mdl.MA = {0 0.2}
Mdl =
arima with properties:

Description: "ARIMA(3,0,2) Model (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 3
D: 0
Q: 2
Constant: 0.05
AR: {0.6 0.2 -0.1} at lags [1 2 3]
SAR: {}
MA: {0.2} at lag [2]
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: 0.01
Mdl.MA
ans=1×2 cell array
{[0]}    {[0.2000]}

In the model display, lags indicates the lags to which the corresponding coefficients are associated. Although MATLAB® removes zero-valued coefficients from the display, the properties storing coefficients preserve them.

Change the model constant to 1.

Mdl.Constant = 1
Mdl =
arima with properties:

Description: "ARIMA(3,0,2) Model (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 3
D: 0
Q: 2
Constant: 1
AR: {0.6 0.2 -0.1} at lags [1 2 3]
SAR: {}
MA: {0.2} at lag [2]
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: 0.01

Create an AR(1) model template and specify iid $\mathit{t}$-distributed innovations with unknown degrees of freedom. Use the longhand syntax.

Mdl = arima('ARLags',1,'Distribution',"t")
Mdl =
arima with properties:

Description: "ARIMA(1,0,0) Model (t Distribution)"
Distribution: Name = "t", DoF = NaN
P: 1
D: 0
Q: 0
Constant: NaN
AR: {NaN} at lag [1]
SAR: {}
MA: {}
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: NaN

The degrees of freedom DoF is NaN, which indicates that the degrees of freedom is estimable.

Create the fully specified AR(1) model represented by this equation:

${y}_{t}=0.6{y}_{t-1}+{\epsilon }_{t},$

where ${\epsilon }_{\mathit{t}}$ is an iid series of $\mathit{t}$-distributed random variables with 10 degrees of freedom. Use the longhand syntax.

innovdist = struct('Name',"t",'DoF',10);
Mdl = arima('Constant',0,'AR',{0.6},...
'Distribution',innovdist)
Mdl =
arima with properties:

Description: "ARIMA(1,0,0) Model (t Distribution)"
Distribution: Name = "t", DoF = 10
P: 1
D: 0
Q: 0
Constant: 0
AR: {0.6} at lag [1]
SAR: {}
MA: {}
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: NaN

Create the ARMA(1,1) conditional mean model containing an ARCH(1) conditional variance model represented by these equations:

$\begin{array}{l}{y}_{t}=c+\varphi {y}_{t-1}+{\epsilon }_{t}+\theta {\epsilon }_{t-1}.\\ {\epsilon }_{t}={\sigma }_{t}{z}_{t}.\\ {\sigma }_{t}^{2}=\kappa +\gamma {\sigma }_{t-1}^{2}.\\ {z}_{t}\sim N\left(0,1\right).\end{array}$

Create the ARMA(1,1) conditional mean model template by using the shorthand syntax.

Mdl = arima(1,0,1)
Mdl =
arima with properties:

Description: "ARIMA(1,0,1) Model (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 1
D: 0
Q: 1
Constant: NaN
AR: {NaN} at lag [1]
SAR: {}
MA: {NaN} at lag [1]
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: NaN

The Variance property of Mdl is NaN, which means that the model variance is an unknown constant.

Create the ARCH(1) conditional variance model template by using the shorthand syntax of garch.

CondVarMdl = garch(0,1)
CondVarMdl =
garch with properties:

Description: "GARCH(0,1) Conditional Variance Model (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 0
Q: 1
Constant: NaN
GARCH: {}
ARCH: {NaN} at lag [1]
Offset: 0

Create the composite conditional mean and variance model template by setting the Variance property of Mdl to CondVarMdl using dot notation.

Mdl.Variance = CondVarMdl
Mdl =
arima with properties:

Description: "ARIMA(1,0,1) Model (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 1
D: 0
Q: 1
Constant: NaN
AR: {NaN} at lag [1]
SAR: {}
MA: {NaN} at lag [1]
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: [GARCH(0,1) Model]

All NaN-valued properties of the conditional mean and variance models are estimable.

Create an ARMAX(1,2) model for predicting changes in the US personal consumption expenditure based on changes in paid compensation of employees.

Load the US macroeconomic data set.

DataTable is a MATLAB® timetable containing quarterly macroeconomic measurements from 1947:Q1 through 2009:Q1. PCEC is the personal consumption expenditure series, and COE is the paid compensation of employees series. Both variables are in levels. For more details on the data, enter Description at the command line.

The series are nonstationary. To avoid spurious regression, stabilize the variables by converting the levels to returns using price2ret. Compute the sample size.

pcecret = price2ret(DataTable.PCEC);
coeret = price2ret(DataTable.COE);
T = numel(pcecret);

Because conversion from levels to returns involves applying the first difference, the transformation reduces the total sample size by one observation.

Create an ARMA(1,2) model template using the shorthand syntax.

Mdl = arima(1,0,2);

The exogenous component enters the model during estimation. Therefore, you do not need to set the Beta property of Mdl to a NaN so that estimate fits the model to the data with the other parameters.

ARMA(1,2) process initialization requires Mdl.P = 1 observation. Therefore, the presample period is the first time point in the data (first row) and the estimation sample is the rest of the data. Specify variables identifying the presample and estimation periods.

idxpre = Mdl.P;
idxest = (Mdl.P + 1):T;

Fit the model to the data. Specify the presample by using the 'Y0' name-value pair argument, and specify the exogenous data by using the 'X' name-value pair argument.

EstMdl = estimate(Mdl,pcecret(idxest),'Y0',pcecret(idxpre),...
'X',coeret(idxest));

ARIMAX(1,0,2) Model (Gaussian Distribution):

Value      StandardError    TStatistic      PValue
_________    _____________    __________    __________

Constant    0.0091866       0.001269         7.239      4.5203e-13
AR{1}        -0.13506       0.081986       -1.6474        0.099478
MA{1}       -0.090445       0.082052       -1.1023         0.27034
MA{2}         0.29671       0.064589        4.5939      4.3505e-06
Beta(1)        0.5831       0.048884        11.928      8.4532e-33
Variance    5.305e-05     3.1387e-06        16.902       4.358e-64

All estimates, except the lag 1 MA coefficient, are significant at 0.1 level.

Display EstMdl.

EstMdl
EstMdl =
arima with properties:

Description: "ARIMAX(1,0,2) Model (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 1
D: 0
Q: 2
Constant: 0.00918662
AR: {-0.135063} at lag [1]
SAR: {}
MA: {-0.0904452 0.296714} at lags [1 2]
SMA: {}
Seasonality: 0
Beta: [0.583095]
Variance: 5.30503e-05

Like Mdl, EstMdl is an arima model object representing an ARMA(1,2) process. Unlike Mdl, EstMdl is fully specified because it is fit to the data, and EstMdl contains an exogenous component, so it is an ARMAX(1,2) model.

Create an arima model object for the random walk represented in this equation:

${y}_{t}={y}_{t-1}+{\epsilon }_{t},$

where ${\epsilon }_{\mathit{t}}$ is a series of iid Gaussian random variables with mean 0 and variance 1.

Mdl = arima(0,1,0);
Mdl.Constant = 0;
Mdl.Variance = 1;
Mdl
Mdl =
arima with properties:

Description: "ARIMA(0,1,0) Model (Gaussian Distribution)"
Distribution: Name = "Gaussian"
P: 1
D: 1
Q: 0
Constant: 0
AR: {}
SAR: {}
MA: {}
SMA: {}
Seasonality: 0
Beta: [1×0]
Variance: 1

Mdl is a fully specified arima model object.

Simulate and plot 1000 paths of length 100 from the random walk.

rng(1) % For reproducibility
Y = simulate(Mdl,100,'NumPaths',1000);
plot(Y)
title('Simulated Paths from Random Walk Process')

Forecast NASDAQ daily closing prices over a 500-day horizon.

Load the US equity indices data set.

The data set contains daily NASDAQ closing prices from 1990 through 2001. For more details, enter Description at the command line.

Assume that an ARIMA(1,1,1) model is appropriate for describing the first 1500 NASDAQ closing prices. Create an ARIMA(1,1,1) model template.

Mdl = arima(1,1,1);

estimate requires a presample of size Mdl.P = 2.

Fit the model to the data. Specify the first two observations as a presample.

idxpre = 1:Mdl.P;
idxest = (Mdl.P + 1):1500;
EstMdl = estimate(Mdl,DataTable.NASDAQ(idxest),...
'Y0',DataTable.NASDAQ(idxpre));

ARIMA(1,1,1) Model (Gaussian Distribution):

Value      StandardError    TStatistic      PValue
_________    _____________    __________    __________

Constant      0.43291       0.18607          2.3265       0.019989
AR{1}       -0.076322      0.082045        -0.93025        0.35224
MA{1}         0.31312      0.077284          4.0516     5.0879e-05
Variance        27.86       0.63785          43.678              0

Forecast the closing values into a 500-day horizon by passing the estimated model to forecast. To initialize the model for forecasting, specify the last two observations in the estimation data as a presample.

yf0 = DataTable.NASDAQ(idxest(end - 1:end));
yf = forecast(EstMdl,500,yf0);

Plot the first 2000 observations and the forecasts.

dates = datetime(dates,'ConvertFrom',"datenum",...
'Format',"yyyy-MM-dd");

figure
h1 = plot(dates(1:2000),DataTable.NASDAQ(1:2000));
hold on
h2 = plot(dates(1501:2000),yf,'r');
legend([h1 h2],"Observed","Forecasted",...
'Location',"NorthWest")
title("NASDAQ Composite Index: 1990-01-02 – 1997-11-25")
xlabel("Time (days)")
ylabel("Closing Price")
hold off

After the start of 1995, the model forecasts almost always underestimate the true closing prices.

expand all

## References

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

Introduced in R2012a