Create univariate autoregressive integrated moving average (ARIMA) model
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 y_{t}.
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)⨉(p_{s},D_{s},q_{s})_{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 innovationdistribution 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:
Create and work with arima
model objects interactively by using Econometric Modeler.
Model serial correlation in a disturbance series of a regression model by creating a regression model with ARIMA errors. For more details, see regARIMA
and Alternative ARIMA Model Representations.
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.Mdl
= arima
creates an ARIMA(Mdl
= arima(p
,D
,q
)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.
sets properties and polynomial lags using namevalue pair arguments. Enclose each name in quotes. For example, Mdl
= arima(Name,Value
)'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.
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);
p
— Nonseasonal autoregressive polynomial degreeNonseasonal autoregressive polynomial degree, specified as a nonnegative integer.
Data Types: double
D
— Degree of nonseasonal integrationDegree of nonseasonal integration (the degree of the nonseasonal differencing polynomial), specified as a nonnegative integer. D
sets the property D.
Data Types: double
q
— Nonseasonal moving average polynomial degreeNonseasonal moving average polynomial degree, specified as a nonnegative integer.
Data Types: double
Specify optional
commaseparated 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.
'ARLags',[1 4],'AR',{0.5 –0.1}
specifies the nonseasonal AR polynomial $$10.5{L}^{1}+0.1{L}^{4}$$.ARLags
— Lags associated with nonseasonal AR polynomial coefficients1:numel(AR)
(default)  numeric vector of unique positive integersLags associated with the nonseasonal AR polynomial coefficients, specified as the commaseparated pair consisting of 'ARLags'
and a numeric vector of unique positive integers. The maximum lag is p.
AR{
is the coefficient of lag j
}ARLags(
.j
)
Example: 'ARLags',[1 4]
specifies the nonseasonal AR polynomial $$1{\varphi}_{1}{L}^{1}{\varphi}_{4}{L}^{4}.$$
Data Types: double
MALags
— Lags associated with nonseasonal MA polynomial coefficients1:numel(MA)
(default)  numeric vector of unique positive integersLags associated with the nonseasonal MA polynomial coefficients, specified as the commaseparated pair consisting of 'MALags'
and a numeric vector of unique positive integers. The maximum lag is q.
MA{
is the coefficient of lag j
}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
SARLags
— Lags associated with seasonal AR polynomial coefficients1:numel(SAR)
(default)  numeric vector of unique positive integersLags associated with the seasonal AR polynomial coefficients, specified as the commaseparated pair consisting of 'SARLags'
and a numeric vector of unique positive integers. The maximum lag is p_{s}.
SAR{
is the coefficient of lag j
}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
SMALags
— Lags associated with seasonal MA polynomial coefficients1:numel(SMA)
(default)  numeric vector of unique positive integersLags associated with the seasonal MA polynomial coefficients, specified as the commaseparated pair consisting of 'SMALags'
and a numeric vector of unique positive integers. The maximum lag is q_{s}.
SMA{
is the coefficient of lag j
}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.
You can set writable property values when you create the model object by using namevalue 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.
P
— Compound AR polynomial degreeThis property is readonly.
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 + p_{s} + 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
Q
— Compound MA polynomial degreeThis property is readonly.
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 + q_{s}. 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
Description
— Model descriptionModel 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
Distribution
— Conditional probability distribution of innovation process"Gaussian"
(default)  "t"
 structure arrayConditional probability distribution of the innovation process, specified as a string or structure array. arima
stores the value as a structure array.
Distribution  String  Structure 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)
Constant
— Model constantNaN
(default)  numeric scalarModel constant, specified as a numeric scalar.
Example: 1
Data Types: double
AR
— Nonseasonal AR polynomial coefficientsNonseasonal 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 differenceequation notation. For example, for the nonseasonal AR polynomial $$\varphi \left(L\right)=10.5L+0.1{L}^{2},$$ specify 'AR',{0.5 –0.1}
.
If you use the shorthand syntax to specify p
> 0, AR{
has the value j
}NaN
and it is the coefficient of lag
, j
= 1,…,j
p
.
If you set the 'ARLags'
namevalue pair argument to ARLags
, the following conditions apply.
The lengths of AR
and ARLags
must be equal.
AR{
is the coefficient of lag j
}ARLags(
, for all j
)
in j
ARLags
.
By default, AR{
= j
}NaN
for all
in j
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 nearzero 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
SAR
— Seasonal AR polynomial coefficientsSeasonal 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 differenceequation notation. For example, for the seasonal AR polynomial $$\Phi \left(L\right)=10.5{L}^{4}+0.1{L}^{8},$$ specify 'SAR',{0.5 –0.1}
.
If you set the 'SARLags'
namevalue pair argument to SARLags
, the following conditions apply.
The lengths of SAR
and SARLags
must be equal.
SAR{
is the coefficient of lag j
}SARLags(
, for all j
)
in j
SARLags
.
By default, SAR{
= j
}NaN
for all
in j
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 nearzero 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
MA
— Nonseasonal MA polynomial coefficientsNonseasonal 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{
has value the j
}NaN
and it is the coefficient of lag
, j
= 1,…,j
q
.
If you set the 'MALags'
namevalue pair argument to MALags
, the following conditions apply.
The lengths of MA
and MALags
must be equal.
MA{
is the coefficient of lag j
}MALags(
, for all j
)
in j
MALags
.
By default, MA{
= j
}NaN
for all
in j
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 nearzero 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
SMA
— Seasonal MA polynomial coefficientsSeasonal 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'
namevalue pair argument to SMALags
, the following conditions apply.
The lengths of SMA
and SMALags
must be equal.
SMA{
is the coefficient of lag j
}SMALags(
, for all j
)
in j
SMALags
.
By default, SMA{
= j
}NaN
for all
in j
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 nearzero 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
D
— Degree of nonseasonal integration0
(default)  nonnegative integerDegree of nonseasonal integration, or the degree of the nonseasonal differencing polynomial, specified as a nonnegative integer.
Example: 1
Data Types: double
Seasonality
— Degree of seasonal differencing polynomial0
(default)  nonnegative integerDegree of the seasonal differencing polynomial s, specified as a nonnegative integer.
Example: 12
specifies monthly periodicity.
Data Types: double
Beta
— Regression component coefficientsRegression 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
Variance
— Model innovations varianceNaN
(default)  positive scalar  supported conditional variance model objectModel 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
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  Generate univariate autoregressive integrated moving average (ARIMA) model impulse response function (IRF) 
simulate  Monte Carlo simulation of ARIMA or ARIMAX models 
forecast  Forecast univariate autoregressive integrated moving average (ARIMA) model responses or conditional variances 
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:
$$(1+0.5{L}^{2})(1L){y}_{t}=3.1+(10.2L){\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 differenceequation notation:
$$\Delta {y}_{t}=3.10.5\Delta {y}_{t2}+{\epsilon}_{t}0.2{\epsilon}_{t1}.$$
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}_{t1}+{\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:
$$(1{\varphi}_{1}L{\varphi}_{2}{L}^{2}{\varphi}_{3}{L}^{3})(1L){y}_{t}=(1+{\theta}_{1}L+{\theta}_{2}{L}^{2}){\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}_{t1}+{\theta}_{12}{\epsilon}_{t12},$$
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)\times {\left(0,1,1\right)}_{12}$ model (multiplicative, monthly MA model template with one degree of seasonal and nonseasonal integration) represented by this equation:
$$(1L)(1{L}^{12}){y}_{t}=(1+{\theta}_{1}L)(1+{\theta}_{12}{L}^{12}){\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}_{t1}+0.2{y}_{t2}0.1{y}_{t3}+{\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 zerovalued 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}_{t1}+{\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}_{t1}+{\epsilon}_{t}+\theta {\epsilon}_{t1}.\\ {\epsilon}_{t}={\sigma}_{t}{z}_{t}.\\ {\sigma}_{t}^{2}=\kappa +\gamma {\sigma}_{t1}^{2}.\\ {z}_{t}\sim N(0,1).\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.
load Data_USEconModel
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'
namevalue pair argument, and specify the exogenous data by using the 'X'
namevalue 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.5203e13 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.3505e06 Beta(1) 0.5831 0.048884 11.928 8.4532e33 Variance 5.305e05 3.1387e06 16.902 4.3581e64
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.0904451 0.296714} at lags [1 2] SMA: {} Seasonality: 0 Beta: [0.583095] Variance: 5.30503e05
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}_{t1}+{\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 500day horizon.
Load the US equity indices data set.
load Data_EquityIdx
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.0879e05 Variance 27.86 0.63785 43.678 0
Forecast the closing values into a 500day 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',"yyyyMMdd"); 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: 19900102 – 19971125") xlabel("Time (days)") ylabel("Closing Price") hold off
After the start of 1995, the model forecasts almost always underestimate the true closing prices.
The lag operator L is defined as $${L}^{i}{y}_{t}={y}_{ti}.$$ Lag operators condense polynomial notation.
A linear time series model for response process y_{t} and random innovations ε_{t} is a stochastic process in which the current response is a linear function of previous responses, the current and previous innovations, and exogenous covariates x_{t}. In differenceequation notation, the general form of a linear time series model is:
$${y}_{t}=c+{x}_{t}\beta +{a}_{1}{y}_{t1}+\dots +{a}_{w}{y}_{tw}+{\epsilon}_{t}+{b}_{1}{\epsilon}_{t1}+\dots +{b}_{v}{\epsilon}_{tv}.$$
Given w and v, all coefficients are estimable.
Expressed in lag operator notation, the general model form is:
$$a(L){y}_{t}=c+{x}_{t}\beta +b(L){\epsilon}_{t}.$$
The lag operator polynomials in the model are often expressed as products of polynomials for nonseasonal and multiplicative seasonal effects and integration:
$$\varphi (L){(1L)}^{D}\Phi (L){(1{L}^{s})}^{{D}_{s}}{y}_{t}=c+{x}_{t}\beta +\theta (L)\Theta (L){\epsilon}_{t}.$$
Model Component  Description  arima Property 

$$\varphi (L)$$  $$\varphi (L)=1\varphi L{\varphi}_{2}{L}^{2}\mathrm{...}{\varphi}_{p}{L}^{p},$$ a pdegree stable nonseasonal AR polynomial. 

D  Degree of nonseasonal integration  D 
$$\Phi (L)$$  $$\Phi (L)=1{\Phi}_{{p}_{1}}{L}^{{p}_{1}}{\Phi}_{{p}_{2}}{L}^{{p}_{2}}\mathrm{...}{\Phi}_{{p}_{s}}{L}^{{p}_{s}},$$ a p_{s}degree stable, multiplicative seasonal AR polynomial. 

s  Seasonality, or the degree of the seasonal differencing polynomial 

D_{s}  Degree of seasonal integration  No corresponding property, but:

c  Model constant  Constant 
β  Regression coefficient of exogenous covariates  Beta 
$$\theta (L)$$  $$\theta (L)=1+\theta L+{\theta}_{2}{L}^{2}+\mathrm{...}+{\theta}_{q}{L}^{q},$$ a qdegree invertible nonseasonal MA polynomial.  MA stores the coefficients; indices correspond to lag exponents. 
$$\Theta (L)$$  $$\Theta (L)=1+{\Theta}_{{q}_{1}}{L}^{{q}_{1}}+{\Theta}_{{q}_{2}}{L}^{{q}_{2}}+\mathrm{...}+{\Theta}_{{q}_{s}}{L}^{{q}_{s}},$$ a q_{s}degree invertible, multiplicative seasonal MA polynomial.  SMA stores the coefficients; indices correspond to lag exponents. 
ε_{t}  Series of random iid innovations  Distribution stores the distribution name and any parameters. 
The model property P
is equal to p + D + p_{s} + s.
The model property Q
is equal to q + q_{s}.
Note
The degrees of the lag operators in the seasonal polynomials Φ(L) and Θ(L) do not conform to the degrees defined by Box and Jenkins [1]. In other words, Econometrics Toolbox™ does not treat p_{1} = s, p_{2} = 2s,...,p_{s} = r_{p}s and q_{1} = s, q_{2} = 2s,...,q_{s} = r_{q}s where r_{p} and r_{q} are positive integers. The software is flexible, letting you specify the lag operator degrees. See Multiplicative ARIMA Model Specifications.
A stochastic process y_{t} is stationary if its expected value, variance, and covariance between elements of the series are independent of time.
For example, the MA(q) model, with c = 0, is stationary for any $$q<\infty $$ because each of the following are free of t for all time points [1].
$$E({y}_{t})=\theta (L)0=0.$$
$$Var({y}_{t})={\sigma}^{2}{\displaystyle \sum _{i=1}^{q}{\theta}_{i}^{2}}.$$
$$Cov({y}_{t},{y}_{ts})=\{\begin{array}{l}{\sigma}^{2}({\theta}_{s}+{\theta}_{1}{\theta}_{s1}+{\theta}_{2}{\theta}_{s2}+\mathrm{...}+{\theta}_{q}{\theta}_{sq})\text{if}s\ge q\\ 0\text{otherwise}.\end{array}$$
The time series $$\{{y}_{t};t=1,\mathrm{...},T\}$$ is a unit root process if its expected value, variance, or covariance grows with time. Consequently, the time series is nonstationary.
[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.
You have a modified version of this example. Do you want to open this example with your edits?
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.
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: .
Select web siteYou can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.