Main Content

filter

通过矢量误差(VEC)模型的滤波器干扰

Description

example

Y= filter(Mdl,Z)returns the multivariate response seriesY, which results from filtering the underlying multivariate disturbance seriesZ。TheZseries are associated with the model innovations process through the fully specified VEC(p– 1) modelMdl

example

Y= filter(Mdl,Z,姓名,Value)uses additional options specified by one or more name-value arguments.For example,'X',X,'Scale',falsespecifiesX作为回归成分的外源预测数据,并避免了模型创新协方差矩阵的下三角cholesky因子缩放干扰。

example

[Y,E] = filter(___)returns the multivariate model innovations seriesE使用任何the input arguments in the previous syntaxes.

Examples

collapse all

考虑以下七个宏观经济系列的VEC模型。然后,通过拟合模型将模型安装到数据中,并过滤器干扰。

  • Gross domestic product (GDP)

  • GDP implicit price deflator

  • Paid compensation of employees

  • Nonfarm business sector hours of all persons

  • Effective federal funds rate

  • Personal consumption expenditures

  • Gross private domestic investment

假设协整等级为4和一个短期项是合适的,即考虑一个VEC(1)模型。

Load theData_USEconVECModeldata set.

loadData_USEconVECModel

有关数据集和变量的更多信息,请输入Descriptionat the command line.

Determine whether the data needs to be preprocessed by plotting the series on separate plots.

数字;subplot(2,2,1) plot(FRED.Time,FRED.GDP); title('Gross Domestic Product');ylabel('Index');Xlabel('Date');subplot(2,2,2) plot(FRED.Time,FRED.GDPDEF); title('GDP Deflator');ylabel('Index');Xlabel('Date');subplot(2,2,3) plot(FRED.Time,FRED.COE); title('Paid Compensation of Employees');ylabel(“数十亿美元”);Xlabel('Date');subplot(2,2,4) plot(FRED.Time,FRED.HOANBS); title('Nonfarm Business Sector Hours');ylabel('Index');Xlabel('Date');

图包含4个轴对象。轴对象1带有标题的国内产品包含类型线的对象。带有标题GDP开发器的Axes Object 2包含一个类型行的对象。轴对象3具有付费雇员的付费薪酬的对象包含类型线的对象。轴对象4带有标题非农业业务部门小时包含类型线的对象。

数字;subplot(2,2,1) plot(FRED.Time,FRED.FEDFUNDS); title('Federal Funds Rate');ylabel('Percent');Xlabel('Date');subplot(2,2,2) plot(FRED.Time,FRED.PCEC); title('Consumption Expenditures');ylabel(“数十亿美元”);Xlabel('Date');subplot(2,2,3) plot(FRED.Time,FRED.GPDI); title('Gross Private Domestic Investment');ylabel(“数十亿美元”);Xlabel('Date');

图包含3个轴对象。Axes object 1 with title Federal Funds Rate contains an object of type line. Axes object 2 with title Consumption Expenditures contains an object of type line. Axes object 3 with title Gross Private Domestic Investment contains an object of type line.

通过应用对数转换,稳定除联邦资金利率外的所有系列。将最终的系列缩放为100,以使所有系列均处于相同的尺度上。

fred.gdp = 100*log(fred.gdp);fred.gdpdef = 100*log(fred.gdpdef);fred.coe = 100*log(fred.coe);fred.hoanbs = 100*log(fred.hoanbs);fred.pcec = 100*log(fred.pcec);fred.gpdi = 100*log(fred.gpdi);

Create a VEC(1) model using the shorthand syntax. Specify the variable names.

Mdl = vecm(7,4,1); Mdl.SeriesNames = FRED.Properties.VariableNames
Mdl = vecm with properties: Description: "7-Dimensional Rank = 4 VEC(1) Model with Linear Time Trend" SeriesNames: "GDP" "GDPDEF" "COE" ... and 4 more NumSeries: 7 Rank: 4 P: 2 Constant: [7×1 vector of NaNs] Adjustment: [7×4 matrix of NaNs] Cointegration: [7×4 matrix of NaNs] Impact: [7×7 matrix of NaNs] CointegrationConstant: [4×1 vector of NaNs] CointegrationTrend: [4×1 vector of NaNs] ShortRun: {7×7 matrix of NaNs} at lag [1] Trend: [7×1 vector of NaNs] Beta: [7×0 matrix] Covariance: [7×7 matrix of NaNs]

Mdl是一个vecm模型对象。All properties containingNaN值对应于要估计给定数据的参数。

Estimate the model using the entire data set and the default options. By default,估计uses the firstp= 2 observations as presample data.

estmdl= estimate(Mdl,FRED.Variables)
EstMdl =结果属性:描述:“7-Dimensional Rank = 4 VEC(1) Model" SeriesNames: "GDP" "GDPDEF" "COE" ... and 4 more NumSeries: 7 Rank: 4 P: 2 Constant: [14.1329 8.77841 -7.20359 ... and 4 more]' Adjustment: [7×4 matrix] Cointegration: [7×4 matrix] Impact: [7×7 matrix] CointegrationConstant: [-28.6082 109.555 -77.0912 ... and 1 more]' CointegrationTrend: [4×1 vector of zeros] ShortRun: {7×7 matrix} at lag [1] Trend: [7×1 vector of zeros] Beta: [7×0 matrix] Covariance: [7×7 matrix]

estmdl是一个n estimatedvecm模型对象。它是完全指定的,因为所有参数均具有已知值。默认情况下,估计imposes the constraints of the H1 Johansen VEC model form by removing the cointegrating trend and linear trend terms from the model. Parameter exclusion from estimation is equivalent to imposing equality constraints to zero.

Generate anumobs- by-7系列随机高斯分布式值,其中numobs是数据减去的观察数p

numobs = size(FRED,1) - Mdl.P; rng(1)% For reproducibilityZ = randn(numobs,Mdl.NumSeries);

To simulate responses, filter the disturbances through the estimated model. Specify the firstp= 2 observations as presample data.

Y = filter(EstMdl,Z,'y0',FRED{1:2,:});

Y是一个238-by-7 matrix of simulated responses. Columns correspond to the variable names inestmdl。SeriesNames

Plot the simulated and true responses.

数字;subplot(2,2,1) plot(FRED.Time(3:end),[FRED.GDP(3:end) Y(:,1)]); title('Gross Domestic Product');ylabel(“索引(缩放)”);Xlabel('Date');legend('Simulation','True','Location','Best') subplot(2,2,2) plot(FRED.Time(3:end),[FRED.GDPDEF(3:end) Y(:,2)]); title('GDP Deflator');ylabel(“索引(缩放)”);Xlabel('Date');legend('Simulation','True','Location','Best') subplot(2,2,3) plot(FRED.Time(3:end),[FRED.COE(3:end) Y(:,3)]); title('Paid Compensation of Employees');ylabel('Billions of $ (scaled)');Xlabel('Date');legend('Simulation','True','Location','Best') subplot(2,2,4) plot(FRED.Time(3:end),[FRED.HOANBS(3:end) Y(:,4)]); title('Nonfarm Business Sector Hours');ylabel(“索引(缩放)”);Xlabel('Date');legend('Simulation','True','Location','Best')

图包含4个轴对象。Axes object 1 with title Gross Domestic Product contains 2 objects of type line. These objects represent Simulation, True. Axes object 2 with title GDP Deflator contains 2 objects of type line. These objects represent Simulation, True. Axes object 3 with title Paid Compensation of Employees contains 2 objects of type line. These objects represent Simulation, True. Axes object 4 with title Nonfarm Business Sector Hours contains 2 objects of type line. These objects represent Simulation, True.

数字;子图(2,2,1)图(Fred.Time(3:End),[Fred.FedFunds(3:end)y(::,5)]);标题('Federal Funds Rate');ylabel('Percent');Xlabel('Date');子图(2,2,2)图(Fred.Time(3:End),[Fred.pcec(3:end)y(::,6)]);标题('Consumption Expenditures');ylabel('Billions of $ (scaled)');Xlabel('Date');子图(2,2,3)图(Fred.Time(3:End),[Fred.gpdi(3:end)y(::,7)]);标题('Gross Private Domestic Investment');ylabel('Billions of $ (scaled)');Xlabel('Date');

图包含3个轴对象。Axes object 1 with title Federal Funds Rate contains 2 objects of type line. Axes object 2 with title Consumption Expenditures contains 2 objects of type line. Axes object 3 with title Gross Private Domestic Investment contains 2 objects of type line.

考虑三个假设响应序列的该VEC(1)模型。

Δ y t = c + A B y t - 1 + Φ 1 Δ y t - 1 + ε t = = [ - 1 - 3 - 3 0 ] + [ - 0 3 0 3 - 0 2 0 1 - 1 0 ] [ 0 1 - 0 2 0 2 - 0 7 0 5 0 2 ] y t - 1 + [ 0 0 1 0 2 0 2 - 0 2 0 0 7 - 0 2 0 3 ] Δ y t - 1 + ε t

The innovations are multivariate Gaussian with a mean of 0 and the covariance matrix

Σ = [ 1 3 0 4 1 6 0 4 0 6 0 7 1 6 0 7 5 ]

Create variables for the parameter values.

Adjustment = [-0.3 0.3; -0.2 0.1; -1 0]; Cointegration = [0.1 -0.7; -0.2 0.5; 0.2 0.2]; ShortRun = {[0. 0.1 0.2; 0.2 -0.2 0; 0.7 -0.2 0.3]}; Constant = [-1; -3; -30]; Trend = [0; 0; 0]; Covariance = [1.3 0.4 1.6; 0.4 0.6 0.7; 1.6 0.7 5];

Create avecmmodel object representing the VEC(1) model using the appropriate name-value pair arguments.

Mdl = vecm('Adjustment',Adjustment,'Cointegration',Cointegration,...'Constant',Constant,'ShortRun',ShortRun,'Trend',Trend,...'Covariance',Covariance)
Mdl = vecm with properties: Description: "3-Dimensional Rank = 2 VEC(1) Model" SeriesNames: "Y1" "Y2" "Y3" NumSeries: 3 Rank: 2 P: 2 Constant: [-1 -3 -30]' Adjustment: [3×2 matrix] Cointegration: [3×2 matrix] Impact: [3×3 matrix] CointegrationConstant: [2×1 vector of NaNs] CointegrationTrend: [2×1 vector of NaNs] ShortRun: {3×3 matrix} at lag [1] Trend: [3×1 vector of zeros] Beta: [3×0 matrix] Covariance: [3×3 matrix]

Mdlis, effectively, a fully specifiedvecm模型对象。也就是说,协整常数and linear trend are unknown. However, they are not needed for simulating observations or forecasting, given that the overall constant and trend parameters are known.

Generate 1000 paths of 100 observations from a 3-D Gaussian distribution.numobsis the number of observations in the data without any missing values.

numobs = 100;numpaths = 1000;RNG(1);z = randn(numobs,mdl.numseries,numpaths);

Filter the disturbances through the estimated model. Return the innovations (scaled disturbances).

[y,e] =过滤器(MDL,Z);

YandEare 100-by-3-by-1000 matrices of filtered responses and scaled disturbances, respectively.

对于每个时间点,计算所有路径之间过滤响应的平均值向量。

平均值=平均值(y,3);

卑鄙的风格是一个100-by-3 matrix containing the average of the filtered responses at each time point.

绘制过滤后的响应及其平均值。

数字;forj = 1:mdl.numseries子图(2,2,j)图(squeeze(y(:,j,:)),,'Color',[0.8,0.8,0.8])标题(mdl.seriesnames {j});抓住on剧情(Meanfilt(:,j));Xlabel('Time index') holdoffend

图包含3个轴对象。带标题Y1的轴对象1包含1001个类型行的对象。带标题Y2的轴对象2包含1001个类型线的对象。带标题Y3的轴对象3包含1001个类型线的对象。

Input Arguments

collapse all

VEC模型,指定为vecm创建的模型对象vecmor估计Mdlmust be fully specified.

Underlying multivariate disturbance series associated with the model innovations process, specified as anumobs-by-数字numeric matrix or anumobs-by-数字-by-numpaths数字阵列。

numobsis the sample size.数字是干扰系列(的数量Mdl.NumSeries).numpathsis the number of disturbance paths.

Rows correspond to sampling times, and the last row contains the latest set of disturbances.

Columns correspond to individual disturbance series for response variables.

Pages correspond to separate, independent paths. For a numeric matrix,Z是一个single数字- 干扰序列的维路径。对于3-D阵列,每页Zrepresents a separate数字-dimensional path. Among all pages, disturbances in corresponding rows occur at the same time.

The'Scale'名称值对参数指定是否缩放之前的扰动filterfilters them throughMdl。For more details, seeScale

数据类型:double

姓名-Value Arguments

Specify optional pairs of arguments asname1 = value1,...,namen = valuen, where姓名is the argument name andValueis the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

在R2021a之前,请使用逗号分隔每个名称和值,并附上姓名用引号。

Example:'Scale',false,'X',Xdoes not scaleZby the lower triangular Cholesky factor of the model covariance matrix before filtering, and uses the matrixX作为回归组件中的预测数据。

Presample responses that provide initial values for the modelMdl, specified as the comma-separated pair consisting of'y0'and anumpreobs-by-数字numeric matrix or anumpreobs-by-数字-by-numprepaths数字阵列。

numpreobsis the number of presample observations.numprepathsis the number of presample response paths.

Rows correspond to presample observations, and the last row contains the latest presample observation.Y0must have at leastmdl.prows. If you supply more rows than necessary,filteruses the latestmdl.pobservations only.

Columns must correspond to the response series inY

Pages correspond to separate, independent paths.

  • IfY0是一个matrix, thenfilterapplies it to each path (page) inY。Therefore, all paths inYderive from common initial conditions.

  • 除此以外,filterappliesY0(:,:,j)Y(:,:,j)Y0must have at leastnumpathspages, andfilteruses only the firstnumpathspages.

Among all pages, observations in a particular row occur at the same time.

默认情况下,filtersets any necessary presample observations.

  • For stationary VAR processes without regression components,filteruses the unconditional mean μ = Φ 1 ( L ) c

  • For nonstationary processes or models containing a regression component,filter将预先观察设置为由零组成的阵列。

数据类型:double

模型中回归分量的预测数据,指定为逗号分隔对'X'and a numeric matrix containing数字columns.

数字is the number of predictor variables (尺寸(mdl.beta,2)).

Rows correspond to observations, and the last row contains the latest observation.Xmust have at least as many observations asZ。If you supply more rows than necessary,filteruses only the latest observations.filterdoes not use the regression component in the presample period.

Columns correspond to individual predictor variables. All predictor variables are present in the regression component of each response equation.

filterappliesX到each path (page) inZ; that is,Xrepresents one path of observed predictors.

默认情况下,filterexcludes the regression component, regardless of its presence inMdl

数据类型:double

Flag indicating whether to scale disturbances by the lower triangular Cholesky factor of the model covariance matrix, specified as the comma-separated pair consisting of'Scale'andtrueorfalse

对于每个页面j= 1,...,,,numpaths,filterfilters thenumobs-by-数字matrix of innovationsE(:,:,j)through the VAR(p) modelMdl,根据这些条件。

  • IfScaleistrue, thenE(:,:,j)=L*Z(:,:,j)andL=chol(mdl.covariance,“下')

  • IfScaleisfalse, thenE(:,:,j)=Z(:,:,j)

Example:'Scale',false

数据类型:logical

Note

NaNZ,Y0, andXindicate missing values.filterremoves missing values from the data by list-wise deletion.

  1. IfZ是一个3-D阵列,然后filterhorizontally concatenates the pages ofZ到form anumobs-by-numpaths*numseries矩阵。

  2. 如果存在回归分量,则filterhorizontally concatenatesXZ到form anumobs-by-(numpaths*numseries + numpreds)矩阵。filter假设每个系列的最后一行同时出现。

  3. filterremoves any row that contains at least oneNaNfrom the concatenated data.

  4. filterapplies steps 1 and 3 to the presample paths inY0

该过程确保了每个路径的过滤响应和创新是相同的大小,并且基于相同的观察时间。如果没有观察,则从多个路径获得的结果Zcan differ from the results obtained from each path individually.

This type of data reduction reduces the effective sample size.

输出参数

collapse all

过滤后的多元响应系列,返回numobs-by-数字numeric matrix or anumobs-by-数字-by-numpaths数字阵列。Yrepresents the continuation of the presample responses inY0

多元模型创新系列,返回numobs-by-数字numeric matrix or anumobs-by-数字-by-numpaths数字阵列。For details on the value ofE, seeScale

Algorithms

  • filtercomputesYandEusing this process for each pagejinZ

    1. IfScaleistrue, thenE(:,:,j)=L*Z(:,:,j), whereL=chol(mdl.covariance,“下')。除此以外,E(:,:,j)=Z(:,:,j)。Setet=E(:,:,j)

    2. Y(:,:,j)isytin this system of equations.

      Δ y t = Φ ^ 1 ( L ) ( c ^ + d ^ t + A ^ B ^ y t 1 + β ^ x t + e t )

      For variable definitions, seeVector Error-Correction Model

  • filter概括simulate。Both functions filter a disturbance series through a model to produce responses and innovations. However, whereassimulategenerates a series of mean-zero, unit-variance, independent Gaussian disturbancesZ到form innovationsE=L*Z,filterenables you to supply disturbances from any distribution.

  • filteruses this process to determine the time origint0of models that include linear time trends.

    • If you do not specifyY0, thent0= 0.

    • 除此以外,filtersetst0size(Y0,1)mdl.p。Therefore, the times in the trend component aret=t0+ 1,t0+ 2,...,t0+numobs, wherenumobsis the effective sample size (size(Y,1)afterfilterremoves missing values). This convention is consistent with the default behavior of model estimation in which估计removes the firstmdl.p响应,减少有效样本量。虽然filter明确使用第一个mdl.ppresample responses inY0到initialize the model, the total number of observations inY0andY(excluding missing values) determinest0

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。柏林:施普林格,2005年。

Version History

Introduced in R2017b

See Also

Objects

Functions