Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
757a9067
Commit
757a9067
authored
Feb 04, 2011
by
Sébastien Villemot
Browse files
Global reindentation of MATLAB files
parent
2b8b32a2
Changes
79
Expand all
Hide whitespace changes
Inline
Side-by-side
matlab/DsgeLikelihood_hh.m
View file @
757a9067
This diff is collapsed.
Click to expand it.
matlab/DsgeSmoother.m
View file @
757a9067
...
...
@@ -166,7 +166,7 @@ if kalman_algo == 1 || kalman_algo == 3
end
end
end
if
kalman_algo
==
2
||
kalman_algo
==
4
if
estim_params_
.
ncn
ST
=
[
zeros
(
nobs
,
nobs
)
Z
;
zeros
(
np
,
nobs
)
T
];
...
...
@@ -180,7 +180,7 @@ if kalman_algo == 2 || kalman_algo == 4
end
[
alphahat
,
epsilonhat
,
etahat
,
ahat
,
P
,
aK
,
PK
,
d
,
decomp
]
=
missing_DiffuseKalmanSmootherH3_Z
(
ST
,
...
Z
,
R1
,
Q
,
diag
(
H
),
Pinf
,
Pstar
,
data1
,
nobs
,
np
,
smpl
,
data_index
);
Z
,
R1
,
Q
,
diag
(
H
),
Pinf
,
Pstar
,
data1
,
nobs
,
np
,
smpl
,
data_index
);
end
if
kalman_algo
==
3
||
kalman_algo
==
4
...
...
@@ -218,7 +218,7 @@ if estim_params_.ncn && (kalman_algo == 2 || kalman_algo == 4)
P
=
P
(
k
,
k
,:);
end
end
% $$$ if any(any(H ~= 0)) % should be replaced by a flag
% $$$ if kalman_algo == 1
% $$$ [alphahat,epsilonhat,etahat,ahat,P,aK,PK,decomp] = ...
...
...
matlab/McMCDiagnostics.m
View file @
757a9067
...
...
@@ -110,7 +110,7 @@ if isnumeric(options_.parallel),
fout
=
McMCDiagnostics_core
(
localVars
,
1
,
npar
,
0
);
UDIAG
=
fout
.
UDIAG
;
clear
fout
% Parallel execution!
% Parallel execution!
else
ModelName
=
M_
.
fname
;
if
~
isempty
(
M_
.
bvar
)
...
...
matlab/McMCDiagnostics_core.m
View file @
757a9067
...
...
@@ -85,17 +85,17 @@ for j=fpar:npar,
for
n
=
1
:
NumberOfMcFilesPerBlock
%load([MhDirectoryName '/' mcfiles(n,1,b).name],'x2');
load
([
MhDirectoryName
'/'
M_
.
fname
'_mh'
,
int2str
(
n
),
'_blck'
int2str
(
b
)
...
'.mat'
],
'x2'
);
'.mat'
],
'x2'
);
nx2
=
size
(
x2
,
1
);
tmp
((
b
-
1
)
*
NumberOfDraws
+
startline
+
(
1
:
nx2
),
1
)
=
x2
(:,
j
);
% clear x2;
startline
=
startline
+
nx2
;
end
% $$$ %load([MhDirectoryName '/' mcfiles(NumberOfMcFilesPerBlock,1,b).name],'x2');
% $$$ load([MhDirectoryName '/' M_.fname '_mh',int2str(NumberOfMcFilesPerBlock),'_blck' int2str(b) '.mat'],'x2');
% $$$ tmp((b-1)*NumberOfDraws+startline+1:(b-1)*NumberOfDraws+MAX_nruns*(LastFileNumber-1)+LastLineNumber,1) = x2(:,j);
% $$$ clear x2;
% $$$ startline = startline + LastLineNumber;
% $$$ %load([MhDirectoryName '/' mcfiles(NumberOfMcFilesPerBlock,1,b).name],'x2');
% $$$ load([MhDirectoryName '/' M_.fname '_mh',int2str(NumberOfMcFilesPerBlock),'_blck' int2str(b) '.mat'],'x2');
% $$$ tmp((b-1)*NumberOfDraws+startline+1:(b-1)*NumberOfDraws+MAX_nruns*(LastFileNumber-1)+LastLineNumber,1) = x2(:,j);
% $$$ clear x2;
% $$$ startline = startline + LastLineNumber;
end
tmp
(:,
2
)
=
kron
(
transpose
(
1
:
nblck
),
ones
(
NumberOfDraws
,
1
));
tmp
(:,
3
)
=
kron
(
ones
(
nblck
,
1
),
time
'
);
...
...
matlab/PosteriorIRF.m
View file @
757a9067
...
...
@@ -100,7 +100,7 @@ else% type = 'prior'
NumberOfDraws
=
500
;
end
if
~
strcmpi
(
type
,
'gsa'
)
B
=
min
([
round
(
.
5
*
NumberOfDraws
),
500
]);
options_
.
B
=
B
;
B
=
min
([
round
(
.
5
*
NumberOfDraws
),
500
]);
options_
.
B
=
B
;
end
try
delete
([
MhDirectoryName
filesep
M_
.
fname
'_irf_dsge*.mat'
])
...
...
@@ -198,7 +198,7 @@ localVars.ifil2=ifil2;
if
isnumeric
(
options_
.
parallel
),
[
fout
]
=
PosteriorIRF_core1
(
localVars
,
1
,
B
,
0
);
else
% Parallel execution!
% Parallel execution!
[
nCPU
,
totCPU
,
nBlockPerCPU
]
=
distributeJobs
(
options_
.
parallel
,
1
,
B
);
for
j
=
1
:
totCPU
-
1
,
nfiles
=
ceil
(
nBlockPerCPU
(
j
)/
MAX_nirfs_dsge
);
...
...
@@ -217,10 +217,10 @@ else
localVars
.
ifil2
=
ifil2
;
globalVars
=
struct
(
'M_'
,
M_
,
...
'options_'
,
options_
,
...
'bayestopt_'
,
bayestopt_
,
...
'estim_params_'
,
estim_params_
,
...
'oo_'
,
oo_
);
'options_'
,
options_
,
...
'bayestopt_'
,
bayestopt_
,
...
'estim_params_'
,
estim_params_
,
...
'oo_'
,
oo_
);
% which files have to be copied to run remotely
NamFileInput
(
1
,:)
=
{
''
,[
M_
.
fname
'_static.m'
]};
...
...
@@ -228,14 +228,14 @@ else
if
options_
.
steadystate_flag
,
NamFileInput
(
length
(
NamFileInput
)
+
1
,:)
=
{
''
,[
M_
.
fname
'_steadystate.m'
]};
end
[
fout
]
=
masterParallel
(
options_
.
parallel
,
1
,
B
,
NamFileInput
,
'PosteriorIRF_core1'
,
localVars
,
globalVars
,
options_
.
parallel_info
);
[
fout
]
=
masterParallel
(
options_
.
parallel
,
1
,
B
,
NamFileInput
,
'PosteriorIRF_core1'
,
localVars
,
globalVars
,
options_
.
parallel_info
);
end
% END first parallel section!
if
nosaddle
disp
([
'PosteriorIRF :: Percentage of discarded posterior draws = '
num2str
(
nosaddle
/(
B
+
nosaddle
))])
disp
([
'PosteriorIRF :: Percentage of discarded posterior draws = '
num2str
(
nosaddle
/(
B
+
nosaddle
))])
end
ReshapeMatFiles
(
'irf_dsge'
)
...
...
@@ -244,7 +244,7 @@ if MAX_nirfs_dsgevar
end
if
strcmpi
(
type
,
'gsa'
)
return
return
end
IRF_DSGEs
=
dir
([
MhDirectoryName
filesep
M_
.
fname
'_IRF_DSGEs*.mat'
]);
...
...
@@ -260,13 +260,13 @@ DistribIRF = zeros(options_.irf,9,nvar,M_.exo_nbr);
HPDIRF
=
zeros
(
options_
.
irf
,
2
,
nvar
,
M_
.
exo_nbr
);
if
options_
.
TeX
for
i
=
1
:
nvar
if
i
==
1
varlist_TeX
=
M_
.
endo_names_tex
(
IndxVariables
(
i
),:);
else
varlist_TeX
=
char
(
varlist_TeX
,
M_
.
endo_names_tex
(
IndxVariables
(
i
),:));
end
end
for
i
=
1
:
nvar
if
i
==
1
varlist_TeX
=
M_
.
endo_names_tex
(
IndxVariables
(
i
),:);
else
varlist_TeX
=
char
(
varlist_TeX
,
M_
.
endo_names_tex
(
IndxVariables
(
i
),:));
end
end
end
fprintf
(
'MH: Posterior (dsge) IRFs...\n'
);
...
...
@@ -274,32 +274,32 @@ tit(M_.exo_names_orig_ord,:) = M_.exo_names;
kdx
=
0
;
for
file
=
1
:
NumberOfIRFfiles_dsge
load
([
MhDirectoryName
filesep
M_
.
fname
'_IRF_DSGEs'
int2str
(
file
)
'.mat'
]);
for
i
=
1
:
M_
.
exo_nbr
for
j
=
1
:
nvar
for
k
=
1
:
size
(
STOCK_IRF_DSGE
,
1
)
kk
=
k
+
kdx
;
[
MeanIRF
(
kk
,
j
,
i
),
MedianIRF
(
kk
,
j
,
i
),
VarIRF
(
kk
,
j
,
i
),
HPDIRF
(
kk
,:,
j
,
i
),
...
DistribIRF
(
kk
,:,
j
,
i
)]
=
posterior_moments
(
squeeze
(
STOCK_IRF_DSGE
(
k
,
j
,
i
,:)),
0
,
options_
.
mh_conf_sig
);
load
([
MhDirectoryName
filesep
M_
.
fname
'_IRF_DSGEs'
int2str
(
file
)
'.mat'
]);
for
i
=
1
:
M_
.
exo_nbr
for
j
=
1
:
nvar
for
k
=
1
:
size
(
STOCK_IRF_DSGE
,
1
)
kk
=
k
+
kdx
;
[
MeanIRF
(
kk
,
j
,
i
),
MedianIRF
(
kk
,
j
,
i
),
VarIRF
(
kk
,
j
,
i
),
HPDIRF
(
kk
,:,
j
,
i
),
...
DistribIRF
(
kk
,:,
j
,
i
)]
=
posterior_moments
(
squeeze
(
STOCK_IRF_DSGE
(
k
,
j
,
i
,:)),
0
,
options_
.
mh_conf_sig
);
end
end
end
end
kdx
=
kdx
+
size
(
STOCK_IRF_DSGE
,
1
);
kdx
=
kdx
+
size
(
STOCK_IRF_DSGE
,
1
);
end
clear
STOCK_IRF_DSGE
;
for
i
=
1
:
M_
.
exo_nbr
for
j
=
1
:
nvar
name
=
[
deblank
(
M_
.
endo_names
(
IndxVariables
(
j
),:))
'_'
deblank
(
tit
(
i
,:))];
eval
([
'oo_.PosteriorIRF.dsge.Mean.'
name
' = MeanIRF(:,j,i);'
]);
eval
([
'oo_.PosteriorIRF.dsge.Median.'
name
' = MedianIRF(:,j,i);'
]);
eval
([
'oo_.PosteriorIRF.dsge.Var.'
name
' = VarIRF(:,j,i);'
]);
eval
([
'oo_.PosteriorIRF.dsge.Distribution.'
name
' = DistribIRF(:,:,j,i);'
]);
eval
([
'oo_.PosteriorIRF.dsge.HPDinf.'
name
' = HPDIRF(:,1,j,i);'
]);
eval
([
'oo_.PosteriorIRF.dsge.HPDsup.'
name
' = HPDIRF(:,2,j,i);'
]);
end
for
j
=
1
:
nvar
name
=
[
deblank
(
M_
.
endo_names
(
IndxVariables
(
j
),:))
'_'
deblank
(
tit
(
i
,:))];
eval
([
'oo_.PosteriorIRF.dsge.Mean.'
name
' = MeanIRF(:,j,i);'
]);
eval
([
'oo_.PosteriorIRF.dsge.Median.'
name
' = MedianIRF(:,j,i);'
]);
eval
([
'oo_.PosteriorIRF.dsge.Var.'
name
' = VarIRF(:,j,i);'
]);
eval
([
'oo_.PosteriorIRF.dsge.Distribution.'
name
' = DistribIRF(:,:,j,i);'
]);
eval
([
'oo_.PosteriorIRF.dsge.HPDinf.'
name
' = HPDIRF(:,1,j,i);'
]);
eval
([
'oo_.PosteriorIRF.dsge.HPDsup.'
name
' = HPDIRF(:,2,j,i);'
]);
end
end
...
...
@@ -340,7 +340,7 @@ if MAX_nirfs_dsgevar
end
end
%%
%%
Finally I build the plots.
%%
Finally I build the plots.
%%
...
...
@@ -352,11 +352,11 @@ end
% Save the local variables.
localVars
=
[];
Check
=
options_
.
TeX
;
if
(
Check
)
localVars
.
varlist_TeX
=
varlist_TeX
;
end
Check
=
options_
.
TeX
;
if
(
Check
)
localVars
.
varlist_TeX
=
varlist_TeX
;
end
localVars
.
nvar
=
nvar
;
localVars
.
MeanIRF
=
MeanIRF
;
...
...
@@ -374,57 +374,57 @@ end
%%% The files .TeX are genereted in sequential way always!
if
options_
.
TeX
fidTeX
=
fopen
([
DirectoryName
filesep
M_
.
fname
'_BayesianIRF.TeX'
],
'w'
);
fprintf
(
fidTeX
,
'%% TeX eps-loader file generated by PosteriorIRF.m (Dynare).\n'
);
fprintf
(
fidTeX
,[
'%% '
datestr
(
now
,
0
)
'\n'
]);
fprintf
(
fidTeX
,
' \n'
);
titTeX
(
M_
.
exo_names_orig_ord
,:)
=
M_
.
exo_names_tex
;
for
i
=
1
:
M_
.
exo_nbr
fidTeX
=
fopen
([
DirectoryName
filesep
M_
.
fname
'_BayesianIRF.TeX'
],
'w'
);
fprintf
(
fidTeX
,
'%% TeX eps-loader file generated by PosteriorIRF.m (Dynare).\n'
);
fprintf
(
fidTeX
,[
'%% '
datestr
(
now
,
0
)
'\n'
]);
fprintf
(
fidTeX
,
' \n'
);
titTeX
(
M_
.
exo_names_orig_ord
,:)
=
M_
.
exo_names_tex
;
for
i
=
1
:
M_
.
exo_nbr
NAMES
=
[];
TEXNAMES
=
[];
for
j
=
1
:
nvar
if
max
(
abs
(
MeanIRF
(:,
j
,
i
)))
>
10
^
(
-
6
)
name
=
deblank
(
varlist
(
j
,:));
texname
=
deblank
(
varlist_TeX
(
j
,:));
if
j
==
1
NAMES
=
name
;
TEXNAMES
=
[
'$'
texname
'$'
];
else
NAMES
=
char
(
NAMES
,
name
);
TEXNAMES
=
char
(
TEXNAMES
,[
'$'
texname
'$'
]);
end
end
end
fprintf
(
fidTeX
,
'\\begin{figure}[H]\n'
);
for
jj
=
1
:
size
(
TEXNAMES
,
1
)
fprintf
(
fidTeX
,[
'\\psfrag{%s}[1][][0.5][0]{%s}\n'
],
deblank
(
NAMES
(
jj
,:)),
deblank
(
TEXNAMES
(
jj
,:)));
end
fprintf
(
fidTeX
,
'\\centering \n'
);
fprintf
(
fidTeX
,
'\\includegraphics[scale=0.5]{%s_Bayesian_IRF_%s}\n'
,
M_
.
fname
,
deblank
(
tit
(
i
,:)));
if
options_
.
relative_irf
fprintf
(
fidTeX
,[
'\\caption{Bayesian relative IRF.}'
]);
else
fprintf
(
fidTeX
,
'\\caption{Bayesian IRF.}'
);
if
max
(
abs
(
MeanIRF
(:,
j
,
i
)))
>
10
^
(
-
6
)
name
=
deblank
(
varlist
(
j
,:));
texname
=
deblank
(
varlist_TeX
(
j
,:));
if
j
==
1
NAMES
=
name
;
TEXNAMES
=
[
'$'
texname
'$'
];
else
NAMES
=
char
(
NAMES
,
name
);
TEXNAMES
=
char
(
TEXNAMES
,[
'$'
texname
'$'
]);
end
end
fprintf
(
fidTeX
,
'\\label{Fig:BayesianIRF:%s}\n'
,
deblank
(
tit
(
i
,:)));
fprintf
(
fidTeX
,
'\\end{figure}\n'
);
fprintf
(
fidTeX
,
' \n'
);
end
fprintf
(
fidTeX
,
'%% End of TeX file.\n'
);
fclose
(
fidTeX
);
end
fprintf
(
fidTeX
,
'\\begin{figure}[H]\n'
);
for
jj
=
1
:
size
(
TEXNAMES
,
1
)
fprintf
(
fidTeX
,[
'\\psfrag{%s}[1][][0.5][0]{%s}\n'
],
deblank
(
NAMES
(
jj
,:)),
deblank
(
TEXNAMES
(
jj
,:)));
end
fprintf
(
fidTeX
,
'\\centering \n'
);
fprintf
(
fidTeX
,
'\\includegraphics[scale=0.5]{%s_Bayesian_IRF_%s}\n'
,
M_
.
fname
,
deblank
(
tit
(
i
,:)));
if
options_
.
relative_irf
fprintf
(
fidTeX
,[
'\\caption{Bayesian relative IRF.}'
]);
else
fprintf
(
fidTeX
,
'\\caption{Bayesian IRF.}'
);
end
fprintf
(
fidTeX
,
'\\label{Fig:BayesianIRF:%s}\n'
,
deblank
(
tit
(
i
,:)));
fprintf
(
fidTeX
,
'\\end{figure}\n'
);
fprintf
(
fidTeX
,
' \n'
);
end
fprintf
(
fidTeX
,
'%% End of TeX file.\n'
);
fclose
(
fidTeX
);
end
% The others file format are generated in parallel by PosteriorIRF_core2!
% Comment for testing!
% Comment for testing!
if
~
exist
(
'OCTAVE_VERSION'
)
if
isnumeric
(
options_
.
parallel
)
||
(
M_
.
exo_nbr
*
ceil
(
size
(
varlist
,
1
)/
MaxNumberOfPlotPerFigure
))
<
8
,
[
fout
]
=
PosteriorIRF_core2
(
localVars
,
1
,
M_
.
exo_nbr
,
0
);
...
...
matlab/PosteriorIRF_core1.m
View file @
757a9067
...
...
@@ -184,10 +184,10 @@ while fpar<npar
while
explosive_var
% draw from the marginal posterior of SIGMA
SIGMAu_draw
=
rand_inverse_wishart
(
nvobs
,
DSGE_PRIOR_WEIGHT
-
NumberOfParametersPerEquation
,
...
SIGMA_inv_upper_chol
);
SIGMA_inv_upper_chol
);
% draw from the conditional posterior of PHI
PHI_draw
=
rand_matrix_normal
(
NumberOfParametersPerEquation
,
nvobs
,
PHI
,
...
chol
(
SIGMAu_draw
)
', chol(iXX)'
);
chol
(
SIGMAu_draw
)
', chol(iXX)'
);
Companion_matrix
(
1
:
nvobs
,:)
=
transpose
(
PHI_draw
(
1
:
NumberOfLagsTimesNvobs
,:));
% Check for stationarity
explosive_var
=
any
(
abs
(
eig
(
Companion_matrix
))
>
1.000000001
);
...
...
@@ -222,7 +222,7 @@ while fpar<npar
else
stock_irf_bvardsge
(:,:,:,
IRUN
)
=
reshape
(
tmp_dsgevar
,
options_
.
irf
,
nvobs
,
M_
.
exo_nbr
);
instr
=
[
MhDirectoryName
'/'
M_
.
fname
'_irf_bvardsge'
...
int2str
(
NumberOfIRFfiles_dsgevar
)
'.mat stock_irf_bvardsge;'
];,
int2str
(
NumberOfIRFfiles_dsgevar
)
'.mat stock_irf_bvardsge;'
];,
eval
([
'save '
instr
]);
if
RemoteFlag
==
1
,
OutputFileName_bvardsge
=
[
OutputFileName_bvardsge
;
{[
MhDirectoryName
filesep
],
[
M_
.
fname
'_irf_bvardsge'
int2str
(
NumberOfIRFfiles_dsgevar
)
'.mat'
]}];
...
...
@@ -238,7 +238,7 @@ while fpar<npar
if
MAX_nirfs_dsgevar
&
(
fpar
==
npar
|
IRUN
==
npar
)
stock_irf_bvardsge
=
stock_irf_bvardsge
(:,:,:,
1
:
IRUN
);
instr
=
[
MhDirectoryName
'/'
M_
.
fname
'_irf_bvardsge'
...
int2str
(
NumberOfIRFfiles_dsgevar
)
'.mat stock_irf_bvardsge;'
];,
int2str
(
NumberOfIRFfiles_dsgevar
)
'.mat stock_irf_bvardsge;'
];,
eval
([
'save '
instr
]);
NumberOfIRFfiles_dsgevar
=
NumberOfIRFfiles_dsgevar
+
1
;
if
RemoteFlag
==
1
,
...
...
@@ -299,8 +299,8 @@ end
% directory on call machine that contain the model).
myoutput
.
OutputFileName
=
[
OutputFileName_dsge
;
OutputFileName_param
;
OutputFileName_bvardsge
];
OutputFileName_param
;
OutputFileName_bvardsge
];
...
...
matlab/PosteriorIRF_core2.m
View file @
757a9067
...
...
@@ -44,10 +44,10 @@ end
% In order to avoid confusion in the name space, the instruction struct2local(myinputs) is replaced by:
Check
=
options_
.
TeX
;
if
(
Check
)
varlist_TeX
=
myinputs
.
varlist_TeX
;
end
if
(
Check
)
varlist_TeX
=
myinputs
.
varlist_TeX
;
end
nvar
=
myinputs
.
nvar
;
MeanIRF
=
myinputs
.
MeanIRF
;
tit
=
myinputs
.
tit
;
...
...
@@ -64,7 +64,7 @@ MaxNumberOfPlotPerFigure=myinputs.MaxNumberOfPlotPerFigure;
% Necessary only for remote computing!
if
whoiam
Parallel
=
myinputs
.
Parallel
;
Parallel
=
myinputs
.
Parallel
;
end
% To save the figures where the function is computed!
...
...
@@ -87,85 +87,85 @@ OutputFileName={};
subplotnum
=
0
;
for
i
=
fpar
:
npar
,
figunumber
=
0
;
for
j
=
1
:
nvar
if
max
(
abs
(
MeanIRF
(:,
j
,
i
)))
>
10
^
(
-
6
)
subplotnum
=
subplotnum
+
1
;
if
options_
.
nograph
if
subplotnum
==
1
&
options_
.
relative_irf
hh
=
figure
(
'Name'
,[
'Relative response to orthogonalized shock to '
tit
(
i
,:)],
'Visible'
,
'off'
);
elseif
subplotnum
==
1
&
~
options_
.
relative_irf
hh
=
figure
(
'Name'
,[
'Orthogonalized shock to '
tit
(
i
,:)],
'Visible'
,
'off'
);
figunumber
=
0
;
for
j
=
1
:
nvar
if
max
(
abs
(
MeanIRF
(:,
j
,
i
)))
>
10
^
(
-
6
)
subplotnum
=
subplotnum
+
1
;
if
options_
.
nograph
if
subplotnum
==
1
&
options_
.
relative_irf
hh
=
figure
(
'Name'
,[
'Relative response to orthogonalized shock to '
tit
(
i
,:)],
'Visible'
,
'off'
);
elseif
subplotnum
==
1
&
~
options_
.
relative_irf
hh
=
figure
(
'Name'
,[
'Orthogonalized shock to '
tit
(
i
,:)],
'Visible'
,
'off'
);
end
else
if
subplotnum
==
1
&
options_
.
relative_irf
hh
=
figure
(
'Name'
,[
'Relative response to orthogonalized shock to '
tit
(
i
,:)]);
elseif
subplotnum
==
1
&
~
options_
.
relative_irf
hh
=
figure
(
'Name'
,[
'Orthogonalized shock to '
tit
(
i
,:)]);
end
end
set
(
0
,
'CurrentFigure'
,
hh
)
subplot
(
nn
,
nn
,
subplotnum
);
if
~
MAX_nirfs_dsgevar
h1
=
area
(
1
:
options_
.
irf
,
HPDIRF
(:,
2
,
j
,
i
));
set
(
h1
,
'FaceColor'
,[
.
9
.
9
.
9
]);
set
(
h1
,
'BaseValue'
,
min
(
HPDIRF
(:,
1
,
j
,
i
)));
hold
on
h2
=
area
(
1
:
options_
.
irf
,
HPDIRF
(:,
1
,
j
,
i
),
'FaceColor'
,[
1
1
1
],
'BaseValue'
,
min
(
HPDIRF
(:,
1
,
j
,
i
)));
set
(
h2
,
'FaceColor'
,[
1
1
1
]);
set
(
h2
,
'BaseValue'
,
min
(
HPDIRF
(:,
1
,
j
,
i
)));
plot
(
1
:
options_
.
irf
,
MeanIRF
(:,
j
,
i
),
'-k'
,
'linewidth'
,
3
)
% plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
box
on
axis
tight
xlim
([
1
options_
.
irf
]);
hold
off
else
h1
=
area
(
1
:
options_
.
irf
,
HPDIRF
(:,
2
,
j
,
i
));
set
(
h1
,
'FaceColor'
,[
.
9
.
9
.
9
]);
set
(
h1
,
'BaseValue'
,
min
([
min
(
HPDIRF
(:,
1
,
j
,
i
)),
min
(
HPDIRFdsgevar
(:,
1
,
j
,
i
))]));
hold
on
;
h2
=
area
(
1
:
options_
.
irf
,
HPDIRF
(:,
1
,
j
,
i
));
set
(
h2
,
'FaceColor'
,[
1
1
1
]);
set
(
h2
,
'BaseValue'
,
min
([
min
(
HPDIRF
(:,
1
,
j
,
i
)),
min
(
HPDIRFdsgevar
(:,
1
,
j
,
i
))]));
plot
(
1
:
options_
.
irf
,
MeanIRF
(:,
j
,
i
),
'-k'
,
'linewidth'
,
3
)
% plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
plot
(
1
:
options_
.
irf
,
MeanIRFdsgevar
(:,
j
,
i
),
'--k'
,
'linewidth'
,
2
)
plot
(
1
:
options_
.
irf
,
HPDIRFdsgevar
(:,
1
,
j
,
i
),
'--k'
,
'linewidth'
,
1
)
plot
(
1
:
options_
.
irf
,
HPDIRFdsgevar
(:,
2
,
j
,
i
),
'--k'
,
'linewidth'
,
1
)
box
on
axis
tight
xlim
([
1
options_
.
irf
]);
hold
off
end
name
=
deblank
(
varlist
(
j
,:));
title
(
name
,
'Interpreter'
,
'none'
)
end
else
if
subplotnum
==
1
&
options_
.
relative_irf
hh
=
figure
(
'Name'
,[
'Relative response to orthogonalized shock to '
tit
(
i
,:)]);
elseif
subplotnum
==
1
&
~
options_
.
relative_irf
hh
=
figure
(
'Name'
,[
'Orthogonalized shock to '
tit
(
i
,:)]);
if
subplotnum
==
MaxNumberOfPlotPerFigure
|
(
j
==
nvar
&
subplotnum
>
0
)
figunumber
=
figunumber
+
1
;
set
(
hh
,
'visible'
,
'on'
)
eval
([
'print -depsc2 '
DirectoryName
'/'
M_
.
fname
'_Bayesian_IRF_'
deblank
(
tit
(
i
,:))
'_'
int2str
(
figunumber
)
'.eps'
]);
if
~
exist
(
'OCTAVE_VERSION'
)
eval
([
'print -dpdf '
DirectoryName
'/'
M_
.
fname
'_Bayesian_IRF_'
deblank
(
tit
(
i
,:))
'_'
int2str
(
figunumber
)]);
saveas
(
hh
,[
DirectoryName
'/'
M_
.
fname
'_Bayesian_IRF_'
deblank
(
tit
(
i
,:))
'_'
int2str
(
figunumber
)
'.fig'
]);
end
if
RemoteFlag
==
1
,
OutputFileName
=
[
OutputFileName
;
{[
DirectoryName
,
filesep
],
[
M_
.
fname
'_Bayesian_IRF_'
deblank
(
tit
(
i
,:))
'_'
int2str
(
figunumber
)
'.*'
]}];
end
set
(
hh
,
'visible'
,
'off'
)
if
options_
.
nograph
,
close
(
hh
),
end
subplotnum
=
0
;
end
end
set
(
0
,
'CurrentFigure'
,
hh
)
subplot
(
nn
,
nn
,
subplotnum
);
if
~
MAX_nirfs_dsgevar
h1
=
area
(
1
:
options_
.
irf
,
HPDIRF
(:,
2
,
j
,
i
));
set
(
h1
,
'FaceColor'
,[
.
9
.
9
.
9
]);
set
(
h1
,
'BaseValue'
,
min
(
HPDIRF
(:,
1
,
j
,
i
)));
hold
on
h2
=
area
(
1
:
options_
.
irf
,
HPDIRF
(:,
1
,
j
,
i
),
'FaceColor'
,[
1
1
1
],
'BaseValue'
,
min
(
HPDIRF
(:,
1
,
j
,
i
)));
set
(
h2
,
'FaceColor'
,[
1
1
1
]);
set
(
h2
,
'BaseValue'
,
min
(
HPDIRF
(:,
1
,
j
,
i
)));
plot
(
1
:
options_
.
irf
,
MeanIRF
(:,
j
,
i
),
'-k'
,
'linewidth'
,
3
)
% plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
box
on
axis
tight
xlim
([
1
options_
.
irf
]);
hold
off
else
h1
=
area
(
1
:
options_
.
irf
,
HPDIRF
(:,
2
,
j
,
i
));
set
(
h1
,
'FaceColor'
,[
.
9
.
9
.
9
]);
set
(
h1
,
'BaseValue'
,
min
([
min
(
HPDIRF
(:,
1
,
j
,
i
)),
min
(
HPDIRFdsgevar
(:,
1
,
j
,
i
))]));
hold
on
;
h2
=
area
(
1
:
options_
.
irf
,
HPDIRF
(:,
1
,
j
,
i
));
set
(
h2
,
'FaceColor'
,[
1
1
1
]);
set
(
h2
,
'BaseValue'
,
min
([
min
(
HPDIRF
(:,
1
,
j
,
i
)),
min
(
HPDIRFdsgevar
(:,
1
,
j
,
i
))]));
plot
(
1
:
options_
.
irf
,
MeanIRF
(:,
j
,
i
),
'-k'
,
'linewidth'
,
3
)
% plot([1 options_.irf],[0 0],'-r','linewidth',0.5);
plot
(
1
:
options_
.
irf
,
MeanIRFdsgevar
(:,
j
,
i
),
'--k'
,
'linewidth'
,
2
)
plot
(
1
:
options_
.
irf
,
HPDIRFdsgevar
(:,
1
,
j
,
i
),
'--k'
,
'linewidth'
,
1
)
plot
(
1
:
options_
.
irf
,
HPDIRFdsgevar
(:,
2
,
j
,
i
),
'--k'
,
'linewidth'
,
1
)
box
on
axis
tight
xlim
([
1
options_
.
irf
]);
hold
off
end
name
=
deblank
(
varlist
(
j
,:));
title
(
name
,
'Interpreter'
,
'none'
)
end
if
subplotnum
==
MaxNumberOfPlotPerFigure
|
(
j
==
nvar
&
subplotnum
>
0
)
figunumber
=
figunumber
+
1
;
set
(
hh
,
'visible'
,
'on'
)
eval
([
'print -depsc2 '
DirectoryName
'/'
M_
.
fname
'_Bayesian_IRF_'
deblank
(
tit
(
i
,:))
'_'
int2str
(
figunumber
)
'.eps'
]);
if
~
exist
(
'OCTAVE_VERSION'
)
eval
([
'print -dpdf '
DirectoryName
'/'
M_
.
fname
'_Bayesian_IRF_'
deblank
(
tit
(
i
,:))
'_'
int2str
(
figunumber
)]);
saveas
(
hh
,[
DirectoryName
'/'
M_
.
fname
'_Bayesian_IRF_'
deblank
(
tit
(
i
,:))
'_'
int2str
(
figunumber
)
'.fig'
]);
end
if
RemoteFlag
==
1
,
OutputFileName
=
[
OutputFileName
;
{[
DirectoryName
,
filesep
],
[
M_
.
fname
'_Bayesian_IRF_'
deblank
(
tit
(
i
,:))
'_'
int2str
(
figunumber
)
'.*'
]}];
end
set
(
hh
,
'visible'
,
'off'
)
if
options_
.
nograph
,
close
(
hh
),
end
subplotnum
=
0
;
end
end
% loop over selected endo_var
end
% loop over selected endo_var
if
whoiam
,
fprintf
(
'Done! \n'
);
waitbarString
=
[
'Exog. shocks '
int2str
(
i
)
'/'
int2str
(
npar
)
' done.'
];
fMessageStatus
((
i
-
fpar
+
1
)/(
npar
-
fpar
+
1
),
whoiam
,
waitbarString
,
waitbarTitle
,
Parallel
(
ThisMatlab
));
fprintf
(
'Done! \n'
);
waitbarString
=
[
'Exog. shocks '
int2str
(
i
)
'/'
int2str
(
npar
)
' done.'
];
fMessageStatus
((
i
-
fpar
+
1
)/(
npar
-
fpar
+
1
),
whoiam
,
waitbarString
,
waitbarTitle
,
Parallel
(
ThisMatlab
));
end
end
% loop over exo_var
myoutput
.
OutputFileName
=
OutputFileName
;
...
...
matlab/add_auxiliary_variables_to_steadystate.m
View file @
757a9067
...
...
@@ -34,8 +34,8 @@ end
for
i
=
1
:
aux_lead_nbr
+
1
;
if
byte_code
[
info
,
res
]
=
bytecode
(
'static'
,
'evaluate'
,
ys1
,
...
[
exo_steady_state
;
...
exo_det_steady_state
],
params
);
[
exo_steady_state
;
...
exo_det_steady_state
],
params
);
else
res
=
feval
([
fname
'_static'
],
ys1
,
...
[
exo_steady_state
;
...
...
...
matlab/convertAimCodeToInfo.m
View file @
757a9067
...
...
@@ -35,24 +35,24 @@ function [info] = convertAimCodeToInfo(aimCode)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
switch
aimCode
case
1
info
=
0
;
% no problem encountered
case
2
info
=
102
;
case
3
info
=
103
;
case
35
info
=
135
;
case
4
info
=
104
;
case
45
info
=
145
;
case
5
info
=
105
;
case
61
info
=
161
;
case
62
info
=
162
;
otherwise
info
=
1
;
case
1
info
=
0
;
% no problem encountered
case
2
info
=
102
;
case
3
info
=
103
;
case
35
info
=
135
;
case
4
info
=
104
;
case
45
info
=
145
;
case
5
info
=
105
;
case
61
info
=
16