TVP-VAR model

64 次查看(过去 30 天)
f x
f x 2016-7-8
评论: Luyao Yang 2022-12-25
i use Nakajima‘s code to do the 3 variable TVP-VAR model。Now I want to do a 4-variable TVP-VAR model but i have no idea how to revise the original code.The code is as follows and i put the entile code in the attachment.Thanks for your help!
clear all; close all;
load tvpvar_ex; % data (.mat)
asvar = {'index'; 'v'; 'm2'; }; % variable names nlag = 2; % lags
setvar('data', my, asvar, nlag); % set data
setvar('fastimp', 1); % fast computing of response
mcmc(10000); % MCMC
drawimp([4 8 12], 1); % draw impulse reponse(1) % : 4-,8-,12-period ahead
drawimp([30 60 90], 0); % draw impulse response(2) % : response at t=30,60,90
  2 个评论
Savas Gayaker
Savas Gayaker 2019-8-11
Thank you for your answer. can this code be extended to five or more variables
Luyao Yang
Luyao Yang 2022-12-25
Hi, do you know how to draw a 3D-irf in Matlab?it should be tvp-var model

请先登录,再进行评论。

回答(3 个)

Savas Gayaker
Savas Gayaker 2019-6-25
I am looking for the same thing. Since 2016 no one has any answer I guess. Did you find anything ? İf you found, could you share it with me ?
  1 个评论
Ameer Fahmi
Ameer Fahmi 2019-11-2
编辑:Ameer Fahmi 2019-11-2
The code can work with four variables, you just neet to introduce your fourth variable in the 'asvar' function as follows
asvar = {'y1'; 'y2'; 'y3'; 'y4' }; % variable names
And that's it

请先登录,再进行评论。


zhen lu
zhen lu 2019-8-11
if you want do a 4-variable TVP-VAR model, firstly you should put the data of the fourth series data into tvpvar_ex file, and add the name of it into "asvar = {'index'; 'v'; 'm2'; }, like {'index'; 'v'; 'm2','X'; } . Here X means the name of variable you want to add. And maybe the format of code is wrong, you may take the following code.
clear all;
close all;
load tvpvar_ex; % data (.mat)
asvar = {'index'; 'v'; 'm0'; }; % variable names
nlag = 2; % lags
setvar('data', my, asvar, nlag); % set data
setvar('fastimp', 1); % fast computing of response
mcmc(10000); % MCMC
drawimp([4 8 12], 1); % draw impulse reponse(1)
% : 4-,8-,12-period ahead
drawimp([30 60 90], 0); % draw impulse response(2)
% : response at t=30,60,90
  1 个评论
yuanxin
yuanxin 2022-2-9
请问后面的代码该怎么改?它的图还是三个变量的图

请先登录,再进行评论。


song song
song song 2019-10-27
How to draw the 3D impulse response figure ?
  3 个评论
song song
song song 2019-11-2
Thank you for your answer.
But my excel filt named "tvpvar_imp.xls" is different with yours. I have three variables, so My form has nine columns. Just like this.Is our code different?
QQ截图20191102211504.png
Ameer Fahmi
Ameer Fahmi 2019-11-3
编辑:Ameer Fahmi 2019-11-3
This is weird, the horizons, the impulse variable and the response variable must be there, otherwise the program will not be able to draw the figure of cumulative impulse responses at different horizons as well as the responses at different time points. The graphs are based on these outputs
I think there's a problem with your results, the values of the response are zero which indicate for singular matrix, meaning that the variables have no impact on each other. Are you using randomly selected variables? or maybe there is a mistake in your settings of the variables and lags
You should also look to the other reported graphs, like the figure of MCMC draws, stochastic volatility figure and simultaeous relations. The MCMC draws must be uncorrelated, follow a stable line and normally distributed. If it doesn't then your estimations are not correct. In addition, you should notice fluctuations in the figure of the stochastic volatility, if it is constant and unchanged then there is no time variations in the parameters of your variables.
I could help you more if you post pictures for the rest of the figures.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Conditional Mean Models 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by