Main Content

Create prior Bayesian vector autoregression (VAR) model object

creates the Bayesian VAR(`PriorMdl`

= bayesvarm(`numseries`

,`numlags`

)*p*) model object `PriorMdl`

, which specifies dimensionalities and prior assumptions for all model coefficients $$\Lambda ={\left[\begin{array}{ccccccc}{\Phi}_{1}& {\Phi}_{2}& \cdots & {\Phi}_{p}& c& \delta & {\rm B}\end{array}\right]}^{\prime}$$ and the innovations covariance Σ, where:

`numseries`

is the number of response time series variables.*p*=`numlags`

is the AR polynomial order.The joint prior distribution of (Λ,Σ) is diffuse.

specifies the joint prior distribution `PriorMdl`

= bayesvarm(`numseries`

,`numlags`

,'`ModelType`

',modelType)`modelType`

for Λ and Σ. For this syntax, `modelType`

can be `'conjugate'`

, `'semiconjugate'`

, `'diffuse'`

, or `'normal'`

. For example, `'ModelType','semiconjugate'`

specifies semiconjugate priors for the multivariate normal likelihood—specifically, vec(Λ)|Σ is multivariate normal, Σ is inverse Wishart, and Λ and Σ are independent.

uses additional
options specified by one or more name-value pair arguments. For example, for non-diffuse models, you can specify Minnesota prior regularization options to regularize the coefficients using the Minnesota prior parameter structure.`PriorMdl`

= bayesvarm(`numseries`

,`numlags`

,'`ModelType`

',modelType,`Name,Value`

)

Consider the 3-D VAR(4) model for the US inflation (`INFL`

), unemployment (`UNRATE`

), and federal funds (`FEDFUNDS`

) rates.

$$\left[\begin{array}{l}{\text{INFL}}_{t}\\ {\text{UNRATE}}_{t}\\ {\text{FEDFUNDS}}_{t}\end{array}\right]=c+\sum _{j=1}^{4}{\Phi}_{j}\left[\begin{array}{l}{\text{INFL}}_{t-j}\\ {\text{UNRATE}}_{t-j}\\ {\text{FEDFUNDS}}_{t-j}\end{array}\right]+\left[\begin{array}{c}{\epsilon}_{1,t}\\ {\epsilon}_{2,t}\\ {\epsilon}_{3,t}\end{array}\right].$$

For all $$t$$, $${\epsilon}_{t}$$ is a series of independent 3-D normal innovations with a mean of 0 and variance $\Sigma $.

Suppose that the AR coefficient matrices ${\Phi}_{1},...,{\Phi}_{4}$, model constant $\mathit{c}$, and innovations covariance matrix $$\Sigma $$ are random variables, and their prior distributions are unknown. In this case, use the noninformative diffuse prior: the joint prior distribution $\left({\Phi}_{1},...,{\Phi}_{4},\mathit{c},\Sigma \right)$is proportional to $${\left|\Sigma \right|}^{-2}$$.

Create a diffuse prior model for the 3-D VAR(4) model parameters, which is the default prior model type.

numseries = 3; numlags = 4; PriorMdl = bayesvarm(numseries,numlags)

PriorMdl = diffusebvarm with properties: Description: "3-Dimensional VAR(4) Model" NumSeries: 3 P: 4 SeriesNames: ["Y1" "Y2" "Y3"] IncludeConstant: 1 IncludeTrend: 0 NumPredictors: 0 AR: {[3x3 double] [3x3 double] [3x3 double] [3x3 double]} Constant: [3x1 double] Trend: [3x0 double] Beta: [3x0 double] Covariance: [3x3 double]

`PriorMdl`

is a `diffusevarm`

Bayesian VAR model object representing the prior distribution of the AR coefficient matrices, model constant vector, and innovations covariance matrix. `bayesvarm`

displays a summary of the prior distributions at the command line.

`AR`

— Prior means of the AR coefficient matrices.`Constant`

— Prior means of the model constant vector.`Trend`

and`Beta`

— Prior means of the linear time trend vector and exogenous regression coefficient matrix, respectively. Because the values are empty arrays, the corresponding parameters are not in the model.`Covariance`

— Prior mean of the innovations covariance matrix.

If you have data, then you can estimate characteristics of the posterior distribution by passing `PriorMdl`

and the data to `estimate`

.

Consider the 3-D VAR(4) model in Default Diffuse Prior Model. Assume the following:

$$[{\Phi}_{1},...,{\Phi}_{4},c{]}^{\prime}|\Sigma \sim {N}_{13\times 3}(M,V,\Sigma )$$. $$M$$ is a 13-by-3 matrix of prior coefficient means ($$M(1:3,1:3)$$ is the prior mean matrix of $${\Phi}_{1}^{\prime}$$, $$M(4:6,1:3)$$ is the prior mean matrix of $${\Phi}_{2}^{\prime}$$,..., and $$M(13,1:3)$$ is the prior mean vector of $$c$$). $$V$$ is a 13-by-13 matrix representing the among-coefficient prior covariance matrix within an equation. $$\Sigma $$ is the 3-by-3 random innovations covariance matrix.

$$\Sigma \sim Inverse\phantom{\rule{0.2777777777777778em}{0ex}}Wishart(\Omega ,\nu )$$. $$\Omega $$ is the 3-by-3 scale matrix, and $$\nu $$ is the degrees of freedom of the inverse Wishart distribution.

The coefficients and the innovations covariance matrix are dependent.

Prior coefficient variances among the equations are proportional.

These assumptions and the data likelihood imply a matrix-normal-inverse-Wishart conjugate model.

Create a matrix-normal-inverse-Wishart conjugate prior model for the VAR model parameters.

numseries = 3; numlags = 4; PriorMdl = bayesvarm(numseries,numlags,'ModelType','conjugate')

PriorMdl = conjugatebvarm with properties: Description: "3-Dimensional VAR(4) Model" NumSeries: 3 P: 4 SeriesNames: ["Y1" "Y2" "Y3"] IncludeConstant: 1 IncludeTrend: 0 NumPredictors: 0 Mu: [39x1 double] V: [13x13 double] Omega: [3x3 double] DoF: 13 AR: {[3x3 double] [3x3 double] [3x3 double] [3x3 double]} Constant: [3x1 double] Trend: [3x0 double] Beta: [3x0 double] Covariance: [3x3 double]

`PriorMdl`

is a `conjugatebvarm`

Bayesian VAR model object representing the prior distribution of the coefficients and innovations covariance matrix. `bayesvarm`

displays a summary of the prior distributions at the command line; it returns the prior mean matrix in vectorized form.

The model contains many estimable parameters. To achieve a parsimonious model, `bayesvarm`

applies the Minnesota prior regularization method to the AR coefficients, by default. Inspect the default prior means (centers of shrinkage) of the AR coefficient matrices.

AR1 = PriorMdl.AR{1}

`AR1 = `*3×3*
0.5000 0 0
0 0.5000 0
0 0 0.5000

AR2 = PriorMdl.AR{2}

`AR2 = `*3×3*
0 0 0
0 0 0
0 0 0

AR3 = PriorMdl.AR{3}

`AR3 = `*3×3*
0 0 0
0 0 0
0 0 0

AR4 = PriorMdl.AR{4}

`AR4 = `*3×3*
0 0 0
0 0 0
0 0 0

Each series is an AR(1) model with AR coefficient `0.5`

, *a priori*.

The tightness on shrinkage of the coefficients is proportional among the equations. Inspect the default tightness values by displaying a heatmap chart of the property `V`

of `PriorMdl`

, which contains a matrix of the scaled tightness on shrinkage of the coefficients for one equation (the unscaled shrinkage is $$\Sigma \otimes V$$ = `kron(PriorMdl.Covariance,PriorMdl.V)`

). Omit the final row and column, which correspond to the model constant.

% Create labels for the chart. numARCoeffMats = PriorMdl.NumSeries*PriorMdl.P; arcoeffnames = strings(numARCoeffMats,1); for r = numlags:-1:1 arcoeffnames(((r-1)*numseries+1):(numseries*r)) = ["\phi_{11,"+r+"}" "\phi_{12,"+r+"}" "\phi_{13,"+r+"}"]; end heatmap(arcoeffnames,arcoeffnames,PriorMdl.V(1:end-1,1:end-1));

The tightness values decrease with lag, which suggests (*a priori*) that the means of the corresponding greater-lagged coefficients are more tightly locked around their center of 0.

Display the tightness of the model constant vector.

PriorMdl.V(end,end)

ans = 10000

The center of the model constant vector is 0 but has a large variance, which allows the estimation procedure to defer more to the data than the prior for the posterior mean of the constant vector.

You can specify alternative values after you create a model by using dot notation. For example, increase the tightness of all coefficients by a factor of `100`

.

PriorMdl.V = 100*PriorMdl.V;

Consider the 3-D VAR(4) model in Default Diffuse Prior Model. Assume these prior distributions, as presented in [1]:

$$vec({[{\Phi}_{1},...,{\Phi}_{4},c]}^{\prime})|\Sigma \sim {N}_{39}(\mu ,V)$$. $\mu $ is a 39-by-1 vector of prior coefficient means (the model has 39 individual coefficients), and $$V$$ is a 39-by-39 prior coefficient covariance matrix.

The innovations covariance $$\Sigma $$ is a fixed matrix.

Suppose econometric theory dictates that

$$\Sigma =\left[\begin{array}{ccc}{10}^{-5}& 0& {10}^{-4}\\ 0& 0.1& -0.2\\ {10}^{-4}& -0.2& 1.6\end{array}\right].$$

Create a normal conjugate prior model for the VAR model coefficients. Specify the value of $$\Sigma $$ by using the `'Sigma'`

name-value pair argument.

numseries = 3; numlags = 4; Sigma = [10e-5 0 10e-4; 0 0.1 -0.2; 10e-4 -0.2 1.6]; PriorMdl = bayesvarm(numseries,numlags,'ModelType','normal',... 'Sigma',Sigma)

PriorMdl = normalbvarm with properties: Description: "3-Dimensional VAR(4) Model" NumSeries: 3 P: 4 SeriesNames: ["Y1" "Y2" "Y3"] IncludeConstant: 1 IncludeTrend: 0 NumPredictors: 0 Mu: [39x1 double] V: [39x39 double] Sigma: [3x3 double] AR: {[3x3 double] [3x3 double] [3x3 double] [3x3 double]} Constant: [3x1 double] Trend: [3x0 double] Beta: [3x0 double] Covariance: [3x3 double]

`PriorMdl`

is a `normalbvarm`

Bayesian VAR model object representing the prior distribution of the coefficients. Because $$\Sigma $$ is fixed for `normalbvarm`

prior models, `PriorMdl.Sigma`

and `PriorMdl.Covariance`

are equal.

PriorMdl.Sigma

`ans = `*3×3*
0.0001 0 0.0010
0 0.1000 -0.2000
0.0010 -0.2000 1.6000

PriorMdl.Covariance

`ans = `*3×3*
0.0001 0 0.0010
0 0.1000 -0.2000
0.0010 -0.2000 1.6000

Consider the 3-D VAR(4) model in Default Diffuse Prior Model. Assume the following:

$$vec\left({\left[{\Phi}_{1},...,{\Phi}_{4},c\right]}^{\prime}\right)|\Sigma \sim {N}_{39}\left(\mu ,V\right)$$. $$\mu $$ is a 39-by-1 vector of prior coefficient means (the model has 39 individual coefficients), and $$V$$ is a 39-by-39 prior coefficient covariance matrix.

$$\Sigma \sim InverseWishart(\Omega ,\nu )$$. $$\Omega $$ is the 3-by-3 scale matrix, and $$\nu $$ is the degrees of freedom of the inverse Wishart distribution.

The coefficients and the innovations covariance matrix are independent.

These assumptions and the data likelihood imply a normal-inverse-Wishart semiconjugate model.

The model contains many estimable parameters. To achieve a parsimonious model, `bayesvarm`

enables you to regularize the coefficients by using the Minnesota prior regularization method, rather than specifying each prior mean and variance.

Create a normal-inverse-Wishart semiconjugate prior model for the VAR model parameters. Specify the following:

All series are AR(1) models,

*a priori*, with AR coefficient 0.9. Set the`'Center'`

name-value pair argument to a 3-by-1 vector composed of`0.9`

.The tightness around self lags in $${\Phi}_{1}$$ is

`1`

. Set the`'SelfLag'`

name-value pair argument to`1`

.The tightness around cross lags in $${\Phi}_{1}$$ is

`0.5`

. Set the`'CrossLag'`

name-value pair argument to`0.5`

.All tightness values decay by a factor of the lag degree squared. Set the

`'Decay'`

name-value pair argument to`2`

.

numseries = 3; numlags = 4; center = 0.9*ones(numseries,1); PriorMdl = bayesvarm(numseries,numlags,'ModelType','semiconjugate',... 'Center',center,'SelfLag',1,'CrossLag',0.5,'Decay',2)

PriorMdl = semiconjugatebvarm with properties: Description: "3-Dimensional VAR(4) Model" NumSeries: 3 P: 4 SeriesNames: ["Y1" "Y2" "Y3"] IncludeConstant: 1 IncludeTrend: 0 NumPredictors: 0 Mu: [39x1 double] V: [39x39 double] Omega: [3x3 double] DoF: 13 AR: {[3x3 double] [3x3 double] [3x3 double] [3x3 double]} Constant: [3x1 double] Trend: [3x0 double] Beta: [3x0 double] Covariance: [3x3 double]

`PriorMdl`

is a `semiconjugatebvarm`

Bayesian VAR model object representing the prior distribution of the coefficients and innovations covariance matrix. `bayesvarm`

displays a summary of the prior distributions at the command line; it returns the prior mean matrix in vectorized form.

Display the prior means of the AR coefficient matrices.

AR1 = PriorMdl.AR{1}

`AR1 = `*3×3*
0.9000 0 0
0 0.9000 0
0 0 0.9000

AR2 = PriorMdl.AR{2}

`AR2 = `*3×3*
0 0 0
0 0 0
0 0 0

AR3 = PriorMdl.AR{3}

`AR3 = `*3×3*
0 0 0
0 0 0
0 0 0

AR4 = PriorMdl.AR{4}

`AR4 = `*3×3*
0 0 0
0 0 0
0 0 0

Each series is an AR(1) model, *a priori*.

The property `V`

of `PriorMdl`

contains a matrix of the tightness on shrinkage of the coefficients. The rows and columns of `V`

correspond to the elements of the `Mu`

property of `PriorMdl`

.

Elements 1 through 3 correspond to the lag 1 AR coefficients in the first equation ordered by response variable, that is, $${\varphi}_{1,11}$$, $${\varphi}_{1,12}$$, and $${\varphi}_{1,13}$$.

Elements 4 through 6 correspond to the lag 2 AR coefficients in the first equation.

Elements 7 through 9 correspond to the lag 3 AR coefficients in the first equation.

Elements 10 through 12 correspond to the lag 4 AR coefficients in the first equation.

Element 13 is the model constant in the first equation.

MATLAB® repeats the pattern for each equation.

In this example, the tightness of shrinkage is the same for all equations. Display a heatmap chart of the property `V`

of `PriorMdl`

for the tightness values of the AR coefficients in the first equation.

% Create labels for the chart. numARCoeffMats = PriorMdl.NumSeries*PriorMdl.P; arcoeffnames = strings(numARCoeffMats,1); for r = numlags:-1:1 arcoeffnames(((r-1)*numseries+1):(numseries*r)) = ["\phi_{"+r+",11}" "\phi_{"+r+",12}" "\phi_{"+r+"13}"]; end heatmap(arcoeffnames,arcoeffnames,PriorMdl.V(1:numARCoeffMats,1:numARCoeffMats));

The tightness values decrease with lag, which suggests (*a priori*) that the means of the corresponding greater-lagged coefficients are more tightly locked around their center of 0. By default, AR coefficients are uncorrelated.

Display the tightness of the model constant vector.

PriorMdl.V(numARCoeffMats + 1,numARCoeffMats + 1)

ans = 10000

The center of the model constant vector is 0 but has a large variance, which allows the estimation procedure to defer more to the data than the prior for the posterior mean of the constant vector.

You can specify alternative values after you create a model by using dot notation. For example, increase the tightness of all coefficients by a factor of `100`

.

PriorMdl.V = 100*PriorMdl.V;

`numseries`

— Number of time series `1`

(default) | positive integerNumber of time series *m*, specified as a positive integer. `numseries`

specifies the dimensionality of the multivariate response variable *y _{t}* and innovation

**Data Types: **`double`

`numlags`

— Number of lagged responses `0`

(default) | nonnegative integerNumber of lagged responses *p* to include in the VAR model, specified as a nonnegative integer. `bayesvarm`

includes lags 1 through `numlags`

.

**Data Types: **`double`

Specify optional
comma-separated pairs of `Name,Value`

arguments. `Name`

is
the argument name and `Value`

is the corresponding value.
`Name`

must appear inside quotes. You can specify several name and value
pair arguments in any order as
`Name1,Value1,...,NameN,ValueN`

.

`'IncludeTrend',true,'NumPredictors',3`

specifies a linear trend term and a linear regression term for three exogenous variables in all response equations.`'ModelType'`

— Joint prior distribution of (Λ,Σ)`'diffuse'`

(default) | `'conjugate'`

| `'semiconjugate'`

| `'normal'`

Joint prior distribution of (Λ,Σ), specified as the comma-separated pair consisting of `'ModelType'`

and a value in the following table. In the table:

*λ*= vec(Λ).*d*=`IncludeConstant`

+`IncludeTrend`

+`NumPredictors`

.The inverse Wishart hyperparameters Ω and

*ν*correspond to the name-value pair arguments and output model properties`Omega`

and`DoF`

, respectively. You can adjust their values by specifying the name-value pair arguments or by using dot notation after`bayesvarm`

returns`PriorMdl`

.

Value | Description |
---|---|

`'conjugate'` | Matrix-normal-inverse-Wishart conjugate model. The priors are $$\begin{array}{c}\Lambda |\Sigma ~{N}_{\left(mp+d\right)\times m}\left({\rm M},V,\Sigma \right)\\ ~\text{}{N}_{m\left(mp+d\right)}\left(\mu ,\Sigma \otimes V\right)\\ \Sigma ~\text{Inverse}\text{\hspace{0.17em}}\text{Wishart}\left(\Omega ,\nu \right),\end{array}$$ where Λ and Σ are dependent. |

`'semiconjugate'` | Normal-inverse-Wishart semiconjugate model. The priors are $$\begin{array}{l}\lambda |\Sigma ~{N}_{m\left(mp+d\right)}\left(\mu ,V\right)\\ \Sigma ~\text{Inverse}\text{\hspace{0.17em}}\text{Wishart}\left(\Omega ,\nu \right),\end{array}$$ where Λ and Σ are independent. |

`'diffuse'` | Diffuse prior distributions. The joint prior pdf is $${f}_{\Lambda ,\Sigma}\left(\Lambda ,\Sigma \right)\propto {\left|\Sigma \right|}^{-\left(m+1\right)/2}.$$ Regularization options do not apply to diffuse priors. |

`'normal'` | Normal conjugate prior model. The prior is $$\lambda ~{\text{N}}_{m\left(mp+d\right)}\left(\mu ,V\right).$$ Σ is known and fixed, and it corresponds to the property |

**Note**

The multivariate normal hyperparameters

*μ*and*V*correspond to the`Mu`

and`V`

properties of`PriorMdl`

, respectively. The Minnesota prior regularization options [1] enable you to specify*μ*and*V*for coefficient shrinkage and tightness completely and easily. You can also display or adjust their values directly by using dot notation after`bayesvarm`

returns`PriorMdl`

.The prior model type that you choose depends on your assumptions about the joint distribution of the parameters. Your choice can affect posterior estimates and inferences. For more details, see Implement Bayesian Linear Regression.

**Example: **`'ModelType','conjugate'`

**Data Types: **`char`

| `string`

`'SeriesNames'`

— Response series namesstring vector | cell vector of character vectors

Response series names for display, specified as the comma-separated pair consisting of `'SeriesNames'`

and a length *m* string vector or cell vector of character vectors. The default is `["Y1" "Y2" ... "Y`

.* m*"]

**Example: **`'SeriesNames',["CPI" "Unemployment"]`

**Data Types: **`string`

| `char`

`'IncludeConstant'`

— Flag for including model constant `true`

(default) | `false`

Flag for including a model constant *c*, specified as the comma-separated pair consisting of `'IncludeConstant'`

and a value in this table.

Value | Description |
---|---|

`false` | Response equations do not include a model constant. |

`true` | All response equations contain a model constant. |

**Example: **`'IncludeConstant',false`

**Data Types: **`logical`

`'IncludeTrend'`

— Flag for including linear time trend term `false`

(default) | `true`

Flag for including a linear time trend term *δ*, specified as the comma-separated pair consisting of `'IncludeTrend'`

and a value in this table.

Value | Description |
---|---|

`false` | Response equations do not include a linear time trend term. |

`true` | All response equations contain a linear time trend term. |

**Example: **`'IncludeTrend',true`

**Data Types: **`logical`

`'NumPredictors'`

— Number of exogenous predictor variables in model regression component`0`

(default) | nonnegative integerNumber of exogenous predictor variables in the model regression component, specified as the comma-separated pair consisting of `'NumPredictors'`

and a nonnegative integer. `bayesvarm`

includes all predictor variables symmetrically in each response equation.

**Example: **`'NumPredictors',3`

`'Description'`

— Model descriptionstring scalar | character vector

Model description, specified as the comma-separated pair consisting of a string scalar or character vector. The default value describes the parametric form of the model, for example `"2-Dimensional VAR(3) Model"`

.

**Example: **`'Description',"Model 1"`

**Data Types: **`string`

| `char`

`'Center'`

— Center of shrinkage`0.5*ones(numseries,1)`

(default) | numeric vector Center of shrinkage for lag 1 self lags, or the prior expectation on the diagonal elements of Φ_{1}, specified as the comma-separated pair consisting of `'Center'`

and a `numseries`

-by-1 numeric vector. `Center(`

is the prior mean of $${\varphi}_{1,jj}$$.* j*)

Each element can be any real number, but typical values are in the interval [0,1]. This table describes the prior model of an individual response series for the specified value.

Value | Prior Model |
---|---|

`0` | White noise process |

In the interval (`0` ,`1` ) | Stationary AR(1) |

`1` | Random walk |

`bayesvarm`

sets the prior means of the following variables to `0`

:

Off-diagonal elements of Φ

_{1}All elements of Φ

_{q},*q*> 1Model constants

*c*Linear time trend coefficients

*δ*Exogenous predictor coefficients Β

For more details, see Minnesota Prior.

**Example: **`'Center',0.01*ones(3,1)`

**Data Types: **`double`

`'SelfLag'`

— Tightness of shrinkage on all self lags of Φ`0.05`

(default) | positive numeric scalarTightness of shrinkage on all self lags of Φ_{1}, specified as the comma-separated pair consisting of `'SelfLag'`

and a positive numeric scalar.

`SelfLag`

contributes to the prior variances of all self-lag coefficients in the model (property `V`

of the output model `PriorMdl`

).

**Tip**

Relatively small tightness values indicate strong belief in prior assumptions during estimation (that is, relatively small values tightly lock self lags around their prior mean). Relatively large values place more weight on information in the data during estimation.

For more details, see Minnesota Prior.

**Example: **`'SelfLag',0.5`

**Data Types: **`double`

`'CrossLag'`

— Tightness on all cross-variable lag coefficients of Φ`0.01`

(default) | positive numeric scalarTightness on all cross-variable lag coefficients of Φ_{1}, specified as the comma-separated pair consisting of `'CrossLag'`

and a positive numeric scalar. For conjugate prior models, `bayesvarm`

sets `'CrossLag'`

to the value of the `SelfLag`

name-value pair argument.

`CrossLag`

contributes to the prior variances of all cross-variable lag coefficients in the model (property `V`

of the output model `PriorMdl`

).

**Tip**

Relatively small tightness values indicate strong belief in prior assumptions during estimation (that is, relatively small values tightly lock cross lags around their prior mean). Relatively large values place more weight on information in the data during estimation.

For more details, see Minnesota Prior.

**Example: **`'CrossLag',0.05`

**Data Types: **`double`

`'Decay'`

— Speed of prior variance decay`1`

(default) | positive numeric scalarSpeed of the prior variance decay with increasing lag, specified as the comma-separated pair consisting of `'Decay'`

and a positive numeric scalar.

`Decay`

contributes to the prior variance of all lag coefficient matrices greater than lag 1 (property `V`

of the output model `PriorMdl`

).

**Tip**

Relatively large values cause lag coefficient variances to decay more quickly, which tightly locks higher-order lag coefficients to their prior means.

**Example: **`'Decay',2`

**Data Types: **`double`

`'Scale'`

— Response variable variances`ones(numseries,1)`

(default) | positive numeric vectorResponse variable variances for the cross-variable lag coefficient tightness `CrossLag`

, specified as the comma-separated pair consisting of `'Scale'`

and a `numseries`

-by-1 positive numeric vector. Elements correspond to the response variables. For conjugate prior models, `bayesvarm`

ignores `Scale`

.

`Scale`

contributes to the prior variances of all cross-variable lag coefficients in the model (property `V`

of the output model `PriorMdl`

), but does not directly contribute to the innovations covariance matrix stored in the property `Sigma`

.

**Tip**

Specify `'Scale'`

when response variable scales are unbalanced.

**Example: **`'Scale',[2 1]`

**Data Types: **`double`

`'VarianceX'`

— Prior variance of exogenous coefficients`1e4`

(default) | positive numeric scalarPrior variance of exogenous coefficients, specified as the comma-separated pair consisting of `'VarianceX'`

and a positive numeric scalar. `VarianceX`

sets the prior variances of all exogenous variables, including the model constant *c*, linear time trend term *δ*, and exogenous predictor coefficients Β.

`VarianceX`

contributes to the value of the prior coefficient variance (property `V`

of the output model `PriorMdl`

).

**Tip**

Relatively small tightness values indicate strong belief in prior assumptions during estimation (that is, relatively small values tightly lock coefficients of exogenous variables to their prior means). Relatively large values place more weight on information in the data during estimation.

**Example: **`'VarianceX',100`

**Data Types: **`double`

`'Sigma'`

— Fixed innovations covariance matrix for normal prior modelpositive definite numeric matrix

Fixed innovations covariance matrix for the normal prior model, specified as the comma-separated pair consisting of `'Sigma'`

and a `numseries`

-by-`numseries`

positive definite numeric matrix.

If you specify `'ModelType','normal'`

, you must specify `'Sigma'`

. For other prior models, Σ is a random variable, so `'Sigma'`

does not apply.

**Example: **`'Sigma',eye(2)`

**Data Types: **`double`

`'Omega'`

— Inverse Wishart scale matrix`diag(Scale)`

(default) | positive definite numeric matrixInverse Wishart scale matrix, specified as the comma-separated pair consisting of `'Omega'`

and a `numseries`

-by-`numseries`

positive definite numeric matrix.

**Example: **`'Omega',eye(numseries)`

**Data Types: **`double`

`'DoF'`

— Inverse Wishart degrees of freedom`numseries + 10`

(default) | positive numeric scalarInverse Wishart degrees of freedom, specified as the comma-separated pair consisting of `'DoF'`

and a positive numeric scalar.

For a proper distribution, specify a value that is greater than `numseries – 1`

. For a distribution with a finite mean, specify a value that is greater than `numseries + 1`

.

**Example: **`'DoF',8`

**Data Types: **`double`

`PriorMdl`

— Bayesian VAR model storing prior model assumptions`conjugatebvarm`

model object | `semiconjugatebvarm`

model object | `diffusebvarm`

model object | `normalbvarm`

model objectBayesian VAR model storing prior model assumptions, returned as one of the model objects listed in this table.

Value of `ModelType` | Returned Bayesian VAR Model Object |
---|---|

`'conjugate'` | `conjugatebvarm` |

`'semiconjugate'` | `semiconjugatebvarm` |

`'diffuse'` | `diffusebvarm` |

`'normal'` | `normalbvarm` |

`PriorMdl`

specifies the joint prior distribution and characteristics of the VAR model only. The model object is a template intended for further use. To incorporate data into the model for posterior distribution analysis, pass the model object and data to the appropriate object function, for example, `estimate`

or `simulate`

.

A *Bayesian VAR model* treats all coefficients and the innovations covariance matrix as random variables in the *m*-dimensional, stationary VARX(*p*) model. The model has one of the three forms described in this table.

Model | Equation |
---|---|

Reduced-form VAR(p) in difference-equation notation |
$${y}_{t}={\Phi}_{1}{y}_{t-1}+\mathrm{...}+{\Phi}_{p}{y}_{t-p}+c+\delta t+{\rm B}{x}_{t}+{\epsilon}_{t}.$$ |

Multivariate regression |
$${y}_{t}={Z}_{t}\lambda +{\epsilon}_{t}.$$ |

Matrix regression |
$${y}_{t}={\Lambda}^{\prime}{z}_{t}^{\prime}+{\epsilon}_{t}.$$ |

For each time *t* = 1,...,*T*:

*y*is the_{t}*m*-dimensional observed response vector, where*m*=`numseries`

.Φ

_{1},…,Φ_{p}are the*m*-by-*m*AR coefficient matrices of lags 1 through*p*, where*p*=`numlags`

.*c*is the*m*-by-1 vector of model constants if`IncludeConstant`

is`true`

.*δ*is the*m*-by-1 vector of linear time trend coefficients if`IncludeTrend`

is`true`

.Β is the

*m*-by-*r*matrix of regression coefficients of the*r*-by-1 vector of observed exogenous predictors*x*_{t}, where*r*=`NumPredictors`

. All predictor variables appear in each equation.$${z}_{t}=\left[\begin{array}{ccccccc}{y}_{t-1}^{\prime}& {y}_{t-2}^{\prime}& \cdots & {y}_{t-p}^{\prime}& 1& t& {x}_{t}^{\prime}\end{array}\right],$$ which is a 1-by-(

*mp*+*r*+ 2) vector, and*Z*_{t}is the*m*-by-*m*(*mp*+*r*+ 2) block diagonal matrix$$\left[\begin{array}{cccc}{z}_{t}& {0}_{z}& \cdots & {0}_{z}\\ {0}_{z}& {z}_{t}& \cdots & {0}_{z}\\ \vdots & \vdots & \ddots & \vdots \\ {0}_{z}& {0}_{z}& {0}_{z}& {z}_{t}\end{array}\right],$$

where 0

_{z}is a 1-by-(*mp*+*r*+ 2) vector of zeros.$$\Lambda ={\left[\begin{array}{ccccccc}{\Phi}_{1}& {\Phi}_{2}& \cdots & {\Phi}_{p}& c& \delta & {\rm B}\end{array}\right]}^{\prime}$$, which is an (

*mp*+*r*+ 2)-by-*m*random matrix of the coefficients, and the*m*(*mp*+*r*+ 2)-by-1 vector*λ*= vec(Λ).*ε*is an_{t}*m*-by-1 vector of random, serially uncorrelated, multivariate normal innovations with the zero vector for the mean and the*m*-by-*m*matrix Σ for the covariance. This assumption implies that the data likelihood is$$\ell \left(\Lambda ,\Sigma |y,x\right)={\displaystyle \prod _{t=1}^{T}f\left({y}_{t};\Lambda ,\Sigma ,{z}_{t}\right)},$$

where

*f*is the*m*-dimensional multivariate normal density with mean*z*_{t}Λ and covariance Σ, evaluated at*y*_{t}.

Before considering the data, you impose a *joint prior distribution* assumption on (Λ,Σ) (see the `ModelType`

name-value pair argument). `bayesvarm`

enables you to adjust hyperparameters by using the Minnesota prior assumptions and parameter structure [1]; the structure regularizes the coefficients. In a Bayesian analysis, the distribution of the parameters is updated with information about the parameters obtained from the data likelihood. The result is the *joint posterior distribution* of (Λ,Σ).

The Minnesota prior, introduced in [1], is a hyperparameter structure for the joint prior distribution of (Λ,Σ) used to obtain a parsimonious model by regularizing the endogenous coefficient matrices of a Bayesian VAR(*p*) model. Minnesota regularization considers a tuning parameter for the *center of shrinkage* and several tuning parameters for the *tightness of shrinkage*.

The center of shrinkage is specified by the prior mean of the coefficients (see the `'Center'`

name-value pair argument). The Minnesota regularization method sets the prior mean of all coefficients to 0 except the lag 1 self lags (diagonal elements of the AR coefficient matrix Φ_{1}). The prior mean of each lag 1 self lag is a real number, typically in the interval [0,1], where (*a priori*) response series *j* is one of the following:

White noise process if prior mean

*j*is 0AR(1) model if prior mean

*j*is in the interval (0,1)Random walk if prior mean

*j*is 1

For example, suppose `numseries`

is `2`

, `numlags`

is `2`

, `NumPredictors`

is `1`

, and all other model options have default values. If you specify `'Center',0.01*ones(2,1)`

, the vectorized prior mean of Λ|Σ is

$$\begin{array}{c}\mu =\text{vec}([\begin{array}{c}\\ \end{array}\stackrel{{\Phi}_{1}}{\overbrace{\begin{array}{cc}0.01& 0\\ 0& 0.01\end{array}}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\stackrel{{\Phi}_{2}}{\overbrace{\begin{array}{cc}0& 0\\ 0& 0\end{array}}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\stackrel{c}{\overbrace{\begin{array}{c}0\\ 0\end{array}}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\stackrel{{\rm B}}{\overbrace{\begin{array}{c}0\\ 0\end{array}}}{\begin{array}{c}\\ \end{array}]}^{\prime}\begin{array}{c}\text{}\text{}\text{}\\ \text{}\text{}\text{}\end{array})\\ ={[}^{\stackrel{{\varphi}_{1,1:}}{\overbrace{\begin{array}{cc}0.01& 0\end{array}}}},\end{array}$$

where *ϕ*_{q,j:} is row *j* of Φ_{q}. MATLAB^{®} stores *μ* in the `Mu`

property of `PriorMdl`

. You can adjust `Mu`

by using dot notation.

The tightness of shrinkage is specified by the prior variance of the coefficients *ϕ*_{r,jk}. For all prior models except conjugate,

$$\text{Var}\left({\varphi}_{q,jk}|\Sigma \right)=\{\begin{array}{cc}\frac{{v}_{0}}{{q}^{d}};& j=k\\ \frac{{v}_{\times}}{{q}^{d}}\frac{{\sigma}_{j}^{2}}{{\sigma}_{k}^{2}};& j\ne k\end{array},$$

where:

*v*_{0}is the tightness on the prior means of all self lags of Φ_{1}(`SelfLag`

).*d*is the speed of tightness decay (`Decay`

).$${\nu}_{\times}$$ is the tightness on the prior means of all cross-variable lag coefficients of Φ

_{1}(`CrossLag`

).$${\sigma}_{j}^{2}$$ is the prior response variance (element

*j*of`Scale`

).

For conjugate prior models,

$$\text{Var}\left({\varphi}_{q,jk}|\Sigma \right)=\frac{{v}_{0}}{{q}^{d}}\forall j,k.$$

Because MATLAB does not adjust input data for variable scales, a best practice is to adjust all series to have a similar magnitude. Consequently, the scales of the coefficients are similar.

By default,

`bayesvarm`

creates Bayesian VAR models by using the Minnesota prior assumptions and parameter structure [1]. After you create a model, you can inspect the effect of coefficient shrinkage by calling`summarize(PriorMdl)`

. You can change the prior mean and variance by setting`PriorMdl.Mu`

and`PriorMdl.V`

, respectively.

[1] Litterman, Robert B. "Forecasting with Bayesian Vector Autoregressions: Five Years of Experience." *Journal of Business and Economic Statistics* 4, no. 1 (January 1986): 25–38. https://doi.org/10.2307/1391384.

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.

- América Latina (Español)
- Canada (English)
- United States (English)

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)