Model Objects, Properties, and Methods

Model Objects

After you have a potential model for your data, you must specify the model to MATLAB® to proceed with your analysis. Econometrics Toolbox™ has model objects for storing specified econometric models. For univariate, discrete time series analysis, there are four available model objects:

  • arima

  • garch

  • egarch

  • gjr

To create a model object, specify the form of your model to one of the model functions (e.g., arima or garch). The function creates the model object of the corresponding type in the MATLAB workspace, as shown in the figure.

You can work with model objects as you would with any other variable in MATLAB. For example, you can assign the object variable a name, view it in the MATLAB Workspace, and display its value in the Command Window by typing its name.

This image shows a workspace containing an arima model named Mdl.

Model Properties

A model object holds all the information necessary to estimate, simulate, and forecast econometric models. This information includes the:

  • Parametric form of the model

  • Number of model parameters (e.g., the degree of the model)

  • Innovation distribution (Gaussian or Student's t)

  • Amount of presample data needed to initialize the model

Such pieces of information are properties of the model, which are stored as fields within the model object. In this way, a model object resembles a MATLAB data structure (struct array).

The four model types—arima, garch, egarch, and gjr—have properties according to the econometric models they support. Each property has a predefined name, which you cannot change.

For example, arima supports conditional mean models (multiplicative and additive AR, MA, ARMA, and ARIMA processes). Every arima model object has these properties, shown with their corresponding names.

Property NameProperty Description
ConstantModel constant
ARNonseasonal AR coefficients
MANonseasonal MA coefficients
SARSeasonal AR coefficients (in a multiplicative model)
SMASeasonal MA coefficients (in a multiplicative model)
DDegree of nonseasonal differencing
SeasonalityDegree of seasonal differencing
VarianceVariance of the innovation distribution
DistributionParametric family of the innovation distribution
PAmount of presample data needed to initialize the AR component of the model
QAmount of presample data needed to initialize the MA component of the model

When a model object exists in the workspace, double-click its name in the Workspace window to open the Variable Editor. The Variable Editor shows all model properties and their names.

Notice that in addition to a name, each property has a value.

Specify Models

Specify a model by assigning values to model properties. You do not need, nor are you able, to specify a value for every property. The constructor function assigns default values to any properties you do not, or cannot, specify.

    Tip   It is good practice to be aware of the default property values for any model you create.

In addition to having a predefined name, each model property has a predefined data type. When assigning or modifying a property's value, the assignment must be consistent with the property data type.

For example, the arima properties have these data types.

Property NameProperty Data Type
ConstantScalar
ARCell array
MACell array
SARCell array
SMACell array
DNonnegative integer
SeasonalityNonnegative integer
VariancePositive scalar
Distributionstruct array
PNonnegative integer (you cannot specify)
QNonnegative integer (you cannot specify)

Specify an AR(2) Model

To illustrate assigning property values, consider specifying the AR(2) model

$$y_t=0.8y_{t-1}-0.2y_{t-2}+\varepsilon_t,$$

where the innovations are independent and identically distributed normal random variables with mean 0 and variance 0.2. This is a conditional mean model, so use arima. Assign values to model properties using name-value pair arguments.

This model has two AR coefficients, 0.8 and -0.2. Assign these values to the property AR as a cell array, {0.8,-0.2}. Assign the value 0.2 to Variance, and 0 to Constant. You do not need to assign a value to Distribution because the default innovation distribution is 'Gaussian'. There are no MA terms, seasonal terms, or degrees of integration, so do not assign values to these properties. You cannot specify values for the properties P and Q.

In summary, specify the model as follows:

Mdl = arima('AR',{0.8,-0.2},'Variance',0.2,'Constant',0)
Mdl = 

    ARIMA(2,0,0) Model:
    --------------------
    Distribution: Name = 'Gaussian'
               P: 2
               D: 0
               Q: 0
        Constant: 0
              AR: {0.8 -0.2} at Lags [1 2]
             SAR: {}
              MA: {}
             SMA: {}
        Variance: 0.2

The output displays the value of the created model, Mdl. Notice that the property Seasonality is not in the output. Seasonality only displays for models with seasonal integration. The property is still present, however, as seen in the Variable Editor.

Mdl has values for every arima property, even though the specification included only three. arima assigns default values for the unspecified properties. The values of SAR, MA, and SMA are empty cell arrays because the model has no seasonal or MA terms. The values of D and Seasonality are 0 because there is no nonseasonal or seasonal differencing. arima sets:

  • P equal to 2, the number of presample observations needed to initialize an AR(2) model.

  • Q equal to 0 because there is no MA component to the model (i.e., no presample innovations are needed).

Specify a GARCH(1,1) Model

As another illustration, consider specifying the GARCH(1,1) model

$$y_t = \varepsilon_t,$$

where

$$\begin{array}{rcl} \varepsilon_t &=& \sigma_tz_t
\\ \sigma^2_t &=&
\kappa+\gamma_1\sigma^2_{t-1}+\alpha_1\varepsilon_{t-1}^2\end{array}$$

Assume $z_t$ follows a standard normal distribution.

This model has one GARCH coefficient (corresponding to the lagged variance term) and one ARCH coefficient (corresponding to the lagged squared innovation term), both with unknown values. To specify this model, enter:

Mdl = garch('GARCH',NaN,'ARCH',NaN)
Mdl = 

    GARCH(1,1) Conditional Variance Model:
    --------------------------------------  
    Distribution: Name = 'Gaussian'
               P: 1
               Q: 1
        Constant: NaN
           GARCH: {NaN} at Lags [1]
            ARCH: {NaN} at Lags [1]

The default value for the constant term is also NaN. Parameters with NaN values need to be estimated or otherwise specified before you can forecast or simulate the model. There is also a shorthand syntax to create a default GARCH(1,1) model:

Mdl = garch(1,1)
Mdl = 

    GARCH(1,1) Conditional Variance Model:
    --------------------------------------  
    Distribution: Name = 'Gaussian'
               P: 1
               Q: 1
        Constant: NaN
           GARCH: {NaN} at Lags [1]
            ARCH: {NaN} at Lags [1]

The shorthand syntax returns a GARCH model with one GARCH coefficient and one ARCH coefficient, with default NaN values.

Retrieve Model Properties

The property values in an existing model are retrievable. Working with models resembles working with struct arrays because you can access model properties using dot notation. That is, type the model name, then the property name, separated by '.' (a period).

For example, consider the arima model with this AR(2) specification:

Mdl = arima('AR',{0.8,-0.2},'Variance',0.2,'Constant',0);

To display the value of the property AR for the created model, enter:

arCoefficients = Mdl.AR
arCoefficients = 

    [0.8000]    [-0.2000]

AR is a cell array, so you must use cell-array syntax. The coefficient cell arrays are lag-indexed, so entering

secondARCoefficient = Mdl.AR{2}
secondARCoefficient =

   -0.2000

returns the coefficient at lag 2. You can also assign any property value to a new variable:

ar = Mdl.AR
ar = 

    [0.8000]    [-0.2000]

Modify Model Properties

You can also modify model properties using dot notation. For example, consider this AR(2) specification:

Mdl = arima('AR',{0.8,-0.2},'Variance',0.2,'Constant',0)
Mdl = 

    ARIMA(2,0,0) Model:
    --------------------
    Distribution: Name = 'Gaussian'
               P: 2
               D: 0
               Q: 0
        Constant: 0
              AR: {0.8 -0.2} at Lags [1 2]
             SAR: {}
              MA: {}
             SMA: {}
        Variance: 0.2

The created model has the default Gaussian innovation distribution. Change the innovation distribution to a Student's t distribution with eight degrees of freedom. The data type for Distribution is a struct array.

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

    ARIMA(2,0,0) Model:
    --------------------
    Distribution: Name = 't', DoF = 8
               P: 2
               D: 0
               Q: 0
        Constant: 0
              AR: {0.8 -0.2} at Lags [1 2]
             SAR: {}
              MA: {}
             SMA: {}
        Variance: 0.2

The variable Mdl is updated accordingly.

Methods

Methods are functions that accept models as inputs. In Econometrics Toolbox, these functions accept arima, garch, egarch, and gjr models:

  • estimate

  • infer

  • forecast

  • simulate

Methods can distinguish between model objects (e.g., an arima model vs. a garch model). That is, some methods accept different optional inputs and return different outputs depending on the type of model that is input.

Find method reference pages for a specific model by entering, for example, doc arima.estimate.

See Also

| | | |

Related Examples

More About

Was this topic helpful?