Main Content

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 Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

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 10.5L1+0.1L4.

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), where AR is the value of the property AR.

Example: ARLags=4 specifies the nonseasonal AR polynomial1ϕ4L4.

Example: ARLags=1:4 specifies the nonseasonal AR polynomial1ϕ1L1ϕ2L2ϕ3L3ϕ4L4.

Example: ARLags=[1 4] specifies the nonseasonal AR polynomial 1ϕ1L1ϕ4L4.

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), where MA is the value of the property MA.

Example: MALags=3 specifies the nonseasonal MA polynomial 1+θ3L3.

Example: MALags=1:3 specifies the nonseasonal MA polynomial 1+θ1L1+θ2L2+θ3L3.

Example: MALags=[1 3] specifies the nonseasonal MA polynomial 1+θ1L1+θ3L3.

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), where SAR is the value of the property SAR.

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Φ4L4Φ8L8.

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), where SMA is the value of the property SMA.

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+Θ4L4.

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 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.

This property is read-only.

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

This property is read-only.

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 εt, 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 the 'DoF' fields.

Example: Distribution=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 ϕ(L)=10.5L+0.1L2, specify 'AR',{0.5 –0.1}.

If you do not set the 'ARLags' name-value pair argument, AR{j} is the coefficient of lag j, j = 1,…,p, where p = numel(AR).

Otherwise, p = max(ARLags) and the following conditions apply:

  • The lengths of AR and ARLags must be equal.

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

  • arima stores AR as a length p cell vector. All cells that do not correspond to lags in ARLags contain 0.

The default value of AR depends on other specifications:

  • If you use the shorthand syntax to specify p > 0, AR is a length p cell vector, where each cell contains a NaN value.

  • If you specify ARLags, AR is a length p cell vector. AR{j} = NaN for each lag ARLags(j). All other cells contain 0.

  • Otherwise, AR is an empty cell vector {}, meaning 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 a coefficient is 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 Φ(L)=10.5L4+0.1L8, specify 'SAR',{0.5 –0.1}.

If you do not set the 'SARLags' name-value pair argument, SAR{j} is the coefficient of lag j, j = 1,…,ps, where ps = numel(SAR).

Otherwise, ps = max(SARLags) and the following conditions apply:

  • The lengths of SAR and SARLags must be equal.

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

  • arima stores SAR as a length ps cell vector. All cells that do not correspond to lags in SARLags contain 0.

The default value of SAR depends on the value SARLags:

  • If you specify SARLags, SAR is a length ps cell vector. SAR{j} = NaN for each lag SARLags(j). All other cells contain 0.

  • Otherwise, SAR is an empty cell vector {}, meaning 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 a coefficient is 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 do not set the 'MALags' name-value pair argument, MA{j} is the coefficient of lag j, j = 1,…,q, where q = numel(MA).

Otherwise, q = max(MALags) and the following conditions apply:

  • The lengths of MA and MALags must be equal.

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

  • arima stores MA as a length q cell vector. All cells that do not correspond to lags in MALags contain 0.

The default value of MA depends on other specifications:

  • If you use the shorthand syntax to specify q > 0, MA is a length q cell vector, where each cell contains a NaN value.

  • If you specify MALags, MA is a length q cell vector. MA{j} = NaN for each lag MALags(j). All other cells contain 0.

  • Otherwise, MA is an empty cell vector {}, meaning the model does not contain a nonseasonal 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 a coefficient is 1e–12 or below, arima excludes that coefficient and its corresponding lag in SMALags 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 do not set the 'SMALags' name-value pair argument, SMA{j} is the coefficient of lag j, j = 1,…,qs, where qs = numel(SMA).

Otherwise, qs = max(SMALags) and the following conditions apply:

  • The lengths of SMA and SMALags must be equal.

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

  • arima stores SMA as a length qs cell vector. All cells that do not correspond to lags in SMALags contain 0.

The default value of SMA depends on other specifications:

  • If you specify SMALags, SMA is a length qs cell vector. SMA{j} = NaN for each lag SMALags(j). All other cells contain 0.

  • Otherwise, SMA is an empty cell vector {}, meaning 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 a coefficient is 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

Since R2023b

Response series name, specified as a string scalar or character vector. arima stores the value as a string scalar.

Example: "StockReturn"

Data Types: string | char

Object Functions

estimateFit univariate ARIMA or ARIMAX model to data
summarizeDisplay univariate ARIMA or ARIMAX model estimation results
inferInfer univariate ARIMA or ARIMAX model residuals or conditional variances
filterFilter disturbances using univariate ARIMA or ARIMAX model
impulseGenerate univariate ARIMA model impulse response function (IRF)
simulateMonte Carlo simulation of univariate ARIMA or ARIMAX models
forecastForecast univariate ARIMA or ARIMAX model responses or conditional variances

Examples

collapse all

Create a default regression model with ARIMA errors by using regARIMA.

Mdl = regARIMA
Mdl = 
  regARIMA with properties:

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

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

The default model is

yt=c+utut=εt,

where c is an unknown constant and εt is a series of iid Gaussian random variables with mean 0 and variance σ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 a default ARIMA model by using arima.

Mdl = arima
Mdl = 
  arima with properties:

     Description: "ARIMA(0,0,0) Model (Gaussian Distribution)"
      SeriesName: "Y"
    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

yt=c+εt,

where c is an unknown constant and εt is a series of iid Gaussian random variables with mean 0 and variance σ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.5L2)(1-L)yt=3.1+(1-0.2L)εt,

where ε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:

Δyt=3.1-0.5Δyt-2+εt-0.2ε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)"
      SeriesName: "Y"
    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)

Figure contains an axes object. The axes object with title Impulse Response, xlabel Observation Time, ylabel Response contains an object of type stem.

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

yt=1+ϕyt-1+εt,

where ε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)"
      SeriesName: "Y"
    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 ϕ 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-ϕ1L-ϕ2L2-ϕ3L3)(1-L)yt=(1+θ1L+θ2L2)εt,

where εt is a series of iid Gaussian random variables with mean 0 and variance σ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)"
      SeriesName: "Y"
    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:

yt=εt+θ1εt-1+θ12εt-12,

where εt is a series of iid Gaussian random variables with mean 0 and variance σ2.

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

     Description: "ARIMA(0,0,12) Model (Gaussian Distribution)"
      SeriesName: "Y"
    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(0,1,1)×(0,1,1)12 model (multiplicative, monthly MA model template with one degree of seasonal and nonseasonal integration) represented by this equation:

(1-L)(1-L12)yt=(1+θ1L)(1+θ12L12)εt,

where εt is a series of iid Gaussian random variables with mean 0 and variance σ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)"
      SeriesName: "Y"
    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:

yt=0.05+0.6yt-1+0.2yt-2-0.1yt-3+εt,

where ε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)"
      SeriesName: "Y"
    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)"
      SeriesName: "Y"
    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)"
      SeriesName: "Y"
    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 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)"
      SeriesName: "Y"
    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:

yt=0.6yt-1+εt,

where εt is an iid series of 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)"
      SeriesName: "Y"
    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:

yt=c+ϕyt-1+εt+θεt-1.εt=σtzt.σt2=κ+γσt-12.ztN(0,1).

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)"
      SeriesName: "Y"
    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)"
      SeriesName: "Y"
    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)"
      SeriesName: "Y"
    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

DataTimeTable 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(DataTimeTable.PCEC);
coeret = price2ret(DataTimeTable.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)"
      SeriesName: "Y"
    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.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:

yt=yt-1+εt,

where ε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)"
      SeriesName: "Y"
    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')

Figure contains an axes object. The axes object with title Simulated Paths from Random Walk Process contains 1000 objects of type line.

Forecast NASDAQ daily closing prices over a 500-day 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.3266       0.019989
    AR{1}       -0.076323      0.082045        -0.93026        0.35223
    MA{1}         0.31312      0.077284          4.0516     5.0876e-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

Figure contains an axes object. The axes object with title NASDAQ Composite Index: 1990-01-02 – 1997-11-25, xlabel Time (days), ylabel Closing Price contains 2 objects of type line. These objects represent Observed, Forecasted.

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

More About

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.

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

Version History

Introduced in R2012a

expand all