# filter

Filter disturbances through vector autoregression (VAR) model

## Syntax

## Description

returns the numeric array `Y`

= filter(`Mdl`

,`Z`

)`Y`

containing the multivariate
response series, which results from filtering the underlying input numeric array
`Z`

containing the multivariate disturbance series. The
series in `Z`

are associated with the model innovations
process through the fully specified VAR(*p*) model
`Mdl`

.

returns the table or timetable `Tbl2`

= filter(`Mdl`

,`Tbl1`

,Presample=`Presample`

)`Tbl2`

containing the multivariate response series, which results from filtering the underlying multivariate disturbance series in the input table or timetable `Tbl1`

. `filter`

initializes the response series using the required table or timetable of presample data in `Presample`

. Variables in `Tbl1`

are associated with the model innovations process through `Mdl`

.* (since R2022b)*

`filter`

selects the variables in `Mdl.SeriesNames`

or all variables in `Tbl1`

. To select different disturbance variables in `Tbl1`

to filter through the model, use the `DisturbanceVariables`

name-value argument. `filter`

selects the same variables for `Presample`

by default, but you can select different variables by using the `PresampleResponseVariables`

name-value argument.

`[___] = filter(___,`

specifies options using one or more name-value arguments in
addition to any of the input argument combinations in previous syntaxes.
`Name=Value`

)`filter`

returns the output argument combination for the
corresponding input arguments. For example, `filter(Mdl,Z,Y0=PS,X=Exo)`

filters
the numeric array of disturbances `Z`

through the
VAR(*p*) model `Mdl`

, and specifies the
numeric array of presample response data `PS`

and the numeric
matrix of exogenous predictor data `Exo`

for the model
regression component.

## Examples

## Input Arguments

## Output Arguments

## Algorithms

`filter`

computes filtered responses`Y`

and innovations`E`

using this process for each pagein`j`

`Z`

.If

`Scale`

is`true`

, then`E(:,:,`

=)`j`

`L*Z(:,:,`

, where)`j`

`L`

=`chol(Mdl.Covariance,'lower')`

. Otherwise,`E(:,:,`

=)`j`

`Z(:,:,`

. Set)`j`

*e*=_{t}`E(:,:,`

.)`j`

`Y(:,:,`

is)`j`

*y*in this system of equations._{t}$${y}_{t}={\widehat{\Phi}}^{-1}(L)\left(\widehat{c}+\widehat{\delta}t+{e}_{t}\right).$$

For variable definitions, see More About.

`filter`

generalizes`simulate`

. Both functions filter a disturbance series through a model to produce responses and innovations. However, whereas`simulate`

generates a series of mean-zero, unit-variance, independent Gaussian disturbances`Z`

to form innovations`E`

=`L*Z`

,`filter`

enables you to supply disturbances from any distribution.`filter`

uses this process to determine the time origin*t*_{0}of models that include linear time trends:If you specify

`Z`

and you do not specify a presample by using the`Y0`

name-value argument,*t*_{0}= 0.Otherwise, if you specify

`Tbl1`

or you supply a presample,`filter`

sets*t*_{0}to`size(`

–,1)`Y0`

`Mdl.P`

, where

contains presample data, the value of`Y0`

`Y0`

or`Presample`

. Therefore, the times in the trend component are*t*=*t*_{0}+ 1,*t*_{0}+ 2,...,*t*_{0}+`numobs`

, where`numobs`

is the effective sample size (`size(Z,1)`

, after`filter`

removes missing values, or`height(Tbl1)`

). This convention is consistent with the default behavior of model estimation, in which`estimate`

removes the first`Mdl.P`

responses, reducing the effective sample size. Although`filter`

explicitly uses the first`Mdl.P`

presample responses in

to initialize the model, the total number of observations in`Y0`

and the input data (`Y0`

`Z`

, excluding missing values, or`Tbl1`

) determines*t*_{0}.

## References

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

[2]
Johansen, S. *Likelihood-Based Inference in Cointegrated Vector Autoregressive Models*. Oxford: Oxford University Press, 1995.

[3]
Juselius, K. *The Cointegrated VAR Model*. Oxford: Oxford University Press, 2006.

[4] Lütkepohl, H. *New Introduction to Multiple
Time Series Analysis*. Berlin: Springer, 2005.

## Version History

**Introduced in R2017a**