Dear @VBBV, thank you for the guidance. It solves my first problem. however, i can't generate an IRF.
I am running MS-DSGE model using RISE toolbox. here is my code.
% Load RISE. Run this only once.
rise_startup();
%% Housekeeping
clc
clear
close all
%% Choose number of simulations and grid size:
numb_simul = 2000; % 2000
grid_size = 10; % 40
grid_size_phi = grid_size + 1; %grid_size + 1
%% Solve model
label_1={1,'low_var'; 2,'high_var'};
label_2={1,'fixed_regime_M'; 2,'ms_regimes'; 3,'ms_endog_regimes'; 4,'fixed_regime_F'};
label_3={1,'non-distortionary'; 2,'distortionary'};
m0=rise('rsa_ms',...
'rise_flags',...
struct('varmodel',label_1{1,1},...
'msmodel', label_2{2,1},...
'taxdistortionary', label_3{1,1}));
m1=solve(m0,'solve_order',2,'solve_derivatives_type','automatic','solve_shock_horizon',0);
m1.print_solution
m1.print_solution({'log_y','C','pi_ann','B_nominal','B','sp','i_ann','r_real_ann','P'})
print_solution(m0)
myirfs=irf(m0,'irf_periods',24);
mygirfs=irf(m0,'irf_type','girf','irf_periods',24,'irf_regime_specific',false);
%% plot irfs
% REGIMES IRFs
myirfs1=irf(m1,'irf_periods',24,'irf_shock_sign',1);
save('myirfs1.mat','myirfs1')
%% Auxiliar Variables
load('myirfs1.mat'); % RS
shock_type = {'eps_G','eps_nu'}; % choose 1 or 2 below
%%
myirfs1 = struct()
myirfs1.eps_CP = struct();
myirfs1.eps_G = struct();
myirfs1.eps_T = struct();
myirfs1.eps_a = struct();
myirfs1.eps_nu = struct();
myirfs1.eps_z = struct();
var_aux = {'log_y','C','pi_ann','B_nominal','B','sp','i_ann','r_real_ann','P'};
var_aux2 = {'eps_nu_log_y','eps_nu_C','eps_nu_pi_ann','eps_nu_B_nominal','eps_nu_B','eps_nu_sp','eps_nu_i_ann','eps_nu_r_real_ann','eps_nu_P'};
var_aux3 = {'eps_G_log_y','eps_G_C','eps_G_pi_ann','eps_G_B_nominal','eps_G_B','eps_G_sp','eps_G_i_ann','eps_G_r_real_ann','eps_G_P'};
fieldnames(myirfs1)
myirfs1.eps_G.var = var_aux3 % assign the data array to the struct variable
myirfs1.eps_G.var
%Irfs of monetary and fiscal policy
irf_mon = struct();
irf_fisc = struct();
for i = 1:numel(var_aux)
irf_mon.var_aux{i} = [0,myirfs1.eps_G.var{i}]';
irf_fisc.var_aux{i} = [0,myirfs1.eps_G.var{i}]';
end
irf_mon.var_aux(1)
irf_mon
irf_fisc
% Initialize the irf_mon and irf_fisc structures dynamically
irf_mon = struct();
irf_fisc = struct();
%%
load('c.mat')
TMax=25; % Maximun period on the irf charts 25.
t=1:TMax; % Auxiliar vector to X axis
var_list={'log_y','C','pi_ann','B_nominal','B','sp','i_ann','r_real_ann','P'};
Title_list={'GDP (\%)','Consumption','Inflation (\% Ann.)','Nominal Debt','Real Debt','Surplus/GDP (\%)','Nominal Interest (\% Ann.)','Real Interest (\% Ann.)','Price Level'};
figure(1);
set(1,'Color','w')
for ii=1:numel(var_list)
subplot(3,3,ii)
v=var_list{ii};
plot(t,myirfs1.(shock_type{1}).(v).data(:,1)/10,'Color',c(10,:),'linewidth',0.7,'LineStyle','--');
hold on
plot(t,myirfs2.(shock_type{1}).(v).data(:,1)/10,'Color',c(10,:),'linewidth',1.5,'LineStyle',':');
title(Title_list{ii},'interpreter','latex')
hold on
plot(t,irf_mon.(v)/10,'Color',c(10,:),'linewidth',0.7,'LineStyle','-')
hold on
plot(t,irf_fisc.(v)/10,'Color',c(1,:),'linewidth',0.7,'LineStyle','-')
line([1 25], [0 0],'Color','k','LineStyle','-')
set(gca,'TickLabelInterpreter','latex') % check
if ii==1
legend({'Exogenous MS - Regime M',...
'Endogenous MS - Regime M',...
'Fixed Regime M',...
'Fixed Regime F'},'FontSize',8,'Location','northeast','interpreter','latex')
end
end
Unrecognized function or variable 'var_list'.
Unrecognized field name "log_y".
Error in tr5 (line 108)
plot(t,myirfs1.(shock_type{1}).(v).data(:,1)/10,'Color',c(10,:),'linewidth',0.7,'LineStyle','--');
I can't generate IRF. Can u suggest where to fix? Thanks