represent time series models using econometrics toolbox objects -凯发k8网页登录

main content

represent time series models using econometrics toolbox objects

model objects

econometrics toolbox™ includes a number of model objects used to represent a variety of discrete-time, time series models. the supported models are univariate or multivariate, linear or nonlinear, and standard or bayesian. model specification tests (see specification testing), economic theory, or your analysis goals can suggest a model, or set of models, for your data.

after preprocessing your data, running specification tests, and selecting a set of candidate models, create the objects that best represent the models in matlab® to proceed with your analysis. how you create an object depends on the object type. in general, you create a model object by calling the object using its name and providing values for the corresponding model parameters. models contain two main types of parameters: model infrastructure parameters, such as model dimensionality or number of lags, and estimable parameters, such as coefficients and an error variance. objects store the parameter values, and other information, in model properties. you operate on models by passing them and possibly other inputs, such as data, to object functions.

the following tables contain the objects available with econometrics toolbox.

univariate linear model objects

this table contains the available objects that represent univariate linear models. you can create some models by using the econometric modeler app.

modelobjecteconometric modeler support?
integrated, autoregressive, moving average (arima) model optionally containing exogenous predictor variables (arimax) or seasonal components (sarima)yes
regression model with arima errorsyes
generalized autoregressive conditional heteroscedasticity model (garch)yes
exponential garch modelyes
glosten-jagannathan-runkle modelyes

multivariate linear model objects

this table contains the available objects that represent multivariate linear models.

descriptionobjecteconometric modeler support?
vector autoregression model (var) optionally containing exogenous predictor variables (varx)yes
vector error-correction (vec), or cointegrated var, model optionally containing exogenous predictor variables (vecx)yes

nonlinear model objects

nonlinear models included with econometrics toolbox are nonlinear because at least one model parameter or coefficient is time-varying. regime-switching and time-varying state-space models have this characteristic. this table contains the available objects that represent multivariate nonlinear models.

descriptionobjectnoteseconometric modeler support?
discrete-state threshold-switching dynamic regression modela tsvar object is the composition of arima or varm objects, specifying the dynamic structure in each state, and a threshold object, specifying the switching mechanism ( see other models).no
discrete-state markov-switching dynamic regression modelan msvar object is the composition of arima or varm objects, specifying the dynamic structure in each state, and a dtmc object, specifying the switching mechanism ( see other models).no
standard, continuous state-space model optionally containing exogenous predictor variablesyou can specify coefficient matrices explicitly or implicitly by supplying a custom functionno
continuous state-space model with diffuse initial states optionally containing exogenous predictor variablesyou can specify coefficient matrices explicitly or implicitly by supplying a custom functionno

bayesian model objects

econometrics toolbox includes objects that represent a bayesian view of some of the available models. a bayesian model object specifies the parametric form of the model and the prior distributions on the parameters.

bayesian linear regression model objects.  bayesian linear regression model objects specify a linear regression model for a univariate response variable and the joint prior distribution of the regression coefficients and disturbance variance. in addition to standard bayesian linear regression, several objects implement bayesian predictor selection.

this table contains the available objects that represent bayesian linear regression models. to create a bayesian linear regression model object, you can call the object by name or use the function.

descriptionobjecteconometric modeler support?
normal-inverse-gamma conjugate prior model. the regression coefficients and disturbance variance are dependent random variables.no
normal-inverse-gamma semiconjugate prior model. the regression coefficients and disturbance variance are independent random variables.no
joint prior distribution is proportional to the inverse of the disturbance variance.no
joint prior distribution is specified by a random sample from the respective distributions.no
joint prior distribution is specified in a custom function that you write.no
bayesian lasso regressionno
stochastic search variable selection (ssvs). the regression coefficients and disturbance variance are dependent random variables (the prior and posterior distributions are conjugate).no
ssvs. the regression coefficients and disturbance variance are independent random variables (the prior and posterior distributions are semiconjugate).no

bayesian var model.  bayesian var model objects specify a var model for the multivariate response variable and the joint prior distribution of the linear coefficient matrices and innovations covariance matrix. this table contains the available objects that represent bayesian var models. to create a bayesian var model object, you can call the object by name or use the function.

descriptionobjecteconometric modeler support?
normal conjugate prior on the coefficients and fixed covarianceno
matrix-normal-inverse-wishart conjugate prior model. the var coefficients and innovations covariance are dependent random variables.no
matrix-normal-inverse-wishart semiconjugate prior model. the var coefficients and innovations covariance are independent random variables.no
joint prior distribution is proportional to the inverse of the determinant of the innovations covariance.no
joint prior distribution is specified by a random sample from the respective distributions.no

bayesian state-space model.  bayesian state-space model objects specify a linear gaussian state-space model the multivariate response variable and the joint prior distribution of the parameters. to create a bayesian state-space model object, call the function. custom functions you write determine the structure of the state-space model and the joint prior distribution of the parameters.

other models

econometrics toolbox includes several objects that you cannot directly fit to data, but are useful for experimenting, characterizing, and visualizing dynamic systems. this table contains the available objects.

descriptionobjectestimationeconometric modeler support?
threshold transitions characterized by transition mid-levels and a transition typeestimate threshold transitions of a threshold-switching dynamic regression model .no
discrete-time markov chain characterized by a transition matrixestimate the transition matrix of a markov-switching dynamic regression model .no
lag operator polynomialnot directly estimableno

model properties

a model object holds all the information necessary for characterizing the model and performing operations, such as estimation and forecasting. this information is model dependent, but it can include the following quantities:

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

all model objects have properties according to the econometric models they represent. each property has a predefined name, which you cannot change.

for example, arima supports conditional mean models (multiplicative and additive ar, ma, arma, arima, and arimax 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

create model object

create a model object by using its creation function and assigning values to model properties. objects require values for model infrastructure parameters, either specified directly or inferred by other inputs. estimable parameters can be specified or unspecified. the creation 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.

you can fully specify a model by specifying all parameter values, or partially specify a model by providing only values of the required, model infrastructure parameters and optionally some estimable parameters. in most cases, an estimable parameter is configured for estimation when its value is nan, which is the default value for estimable parameters for most models. some objects accept a custom function specifying the model form. most objects support parameter estimation.

for example, to create a model object representing a particular arima model, use the arima function and specify at least the autoregressive and moving average polynomial degrees and the degree of nonseasonal integration. the function creates the model object of the corresponding type (arima) in the matlab workspace, as shown in the figure.

workflow showing proposed model, to arima model, to arima variable in the matlab workspace.

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.

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. this image shows a workspace containing an arima model named mdl.

screen shot of the variable tab.

each property name is assigned a value. you can access or reassign writable properties by using dot notation, for example, mdl.constant = nan;

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

yt=0.8yt-1-0.2yt-2 εt,

where the innovations are independent and identically distributed normal random variables with mean 0 and variance 0.2. because the equation is a conditional mean model, use arima to create an object that represents the model. assign values to model properties by 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 with properties:
     description: "arima(2,0,0) model (gaussian distribution)"
    distribution: name = "gaussian"
               p: 2
               d: 0
               q: 0
        constant: 0
              ar: {0.8 -0.2} at lags [1 2]
             sar: {}
              ma: {}
             sma: {}
     seasonality: 0
            beta: [1×0]
        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.

screen shot of the variable tab.

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

yt=εt,

where

εt=σtztσt2=κ γ1σt-12 α1εt-12

assume zt 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 with properties:
     description: "garch(1,1) conditional variance model (gaussian distribution)"
      seriesname: "y"
    distribution: name = "gaussian"
               p: 1
               q: 1
        constant: nan
           garch: {nan} at lag [1]
            arch: {nan} at lag [1]
          offset: 0

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 with properties:
     description: "garch(1,1) conditional variance model (gaussian distribution)"
      seriesname: "y"
    distribution: name = "gaussian"
               p: 1
               q: 1
        constant: nan
           garch: {nan} at lag [1]
            arch: {nan} at lag [1]
          offset: 0

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=1×2 cell array
    {[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=1×2 cell array
    {[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 with properties:
     description: "arima(2,0,0) model (gaussian distribution)"
    distribution: name = "gaussian"
               p: 2
               d: 0
               q: 0
        constant: 0
              ar: {0.8 -0.2} at lags [1 2]
             sar: {}
              ma: {}
             sma: {}
     seasonality: 0
            beta: [1×0]
        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 with properties:
     description: "arima(2,0,0) model (t distribution)"
    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: {}
     seasonality: 0
            beta: [1×0]
        variance: 0.2

the variable mdl is updated accordingly.

object functions

object functions are functions that accept model objects as inputs and perform an operation on the model and other inputs. in econometrics toolbox, these functions, which represent steps in an econometrics analysis workflow, accept most objects included in the toolbox:

  • estimate

  • forecast

  • simulate

models that you can fit to data have these three methods in common, but the model objects in the toolbox can have other object functions.

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

find object function reference pages for a specific model by entering, for example, doc arima/estimate.

related topics

    网站地图