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
749fff9d
Commit
749fff9d
authored
Apr 29, 2013
by
Johannes Pfeifer
Browse files
Make traceplot and mh_autocorrelation save graphs; add legend
parent
c0f12968
Changes
2
Hide whitespace changes
Inline
Side-by-side
matlab/mh_autocorrelation_function.m
View file @
749fff9d
...
...
@@ -97,7 +97,17 @@ if options_.mh_nblck>1
FigureName
=
[
FigureName
,
' (block number'
int2str
(
blck
)
').'
];
end
hh
=
dyn_figure
(
options_
,
'Name'
,
FigureName
);
figure
(
'Name'
,
FigureName
)
bar
(
0
:
options_
.
mh_autocorrelation_function_size
,
autocor
,
'k'
);
axis
tight
\ No newline at end of file
axis
tight
% create subdirectory <fname>/graphs if it doesn't exist
if
~
exist
(
M_
.
fname
,
'dir'
)
mkdir
(
'.'
,
M_
.
fname
);
end
if
~
exist
([
M_
.
fname
filesep
'graphs'
])
mkdir
(
M_
.
fname
,
'graphs'
);
end
plot_name
=
get_the_name
(
column
,
0
,
M_
,
estim_params_
,
options_
);
dyn_saveas
(
hh
,[
M_
.
fname
,
filesep
,
'graphs'
,
filesep
,
'MH_Autocorrelation_'
plot_name
],
options_
)
matlab/trace_plot.m
View file @
749fff9d
...
...
@@ -17,7 +17,7 @@ function trace_plot(options_,M_,estim_params_,type,blck,name1,name2)
%
% SPECIAL REQUIREMENTS
% Copyright (C) 2003-201
1
Dynare Team
% Copyright (C) 2003-201
3
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -50,8 +50,8 @@ DirectoryName = CheckPath('metropolis',M_.dname);
try
load
([
DirectoryName
'/'
M_
.
fname
'_mh_history.mat'
]);
catch
disp
([
'
t
race_plot:: I can
''
t find '
M_
.
fname
'_results.mat !'
])
disp
([
'
t
race_plot:: Did you run a metropolis?'
])
disp
([
'
T
race_plot:: I can
''
t find '
M_
.
fname
'_results.mat !'
])
disp
([
'
T
race_plot:: Did you run a metropolis?'
])
return
end
...
...
@@ -84,18 +84,17 @@ elseif strcmpi(type,'MeasurementError')
end
if
nargin
<
7
FigureName
=
[
'
t
race plot for '
TYPE
name1
];
FigureName
=
[
'
T
race plot for '
TYPE
name1
];
else
FigureName
=
[
'
t
race plot for '
TYPE
name1
' and '
name2
];
FigureName
=
[
'
T
race plot for '
TYPE
name1
' and '
name2
];
end
if
options_
.
mh_nblck
>
1
FigureName
=
[
FigureName
,
' (block number'
int2str
(
blck
)
').'
];
FigureName
=
[
FigureName
,
' (block number
'
int2str
(
blck
)
').'
];
end
figure
(
'Name'
,
FigureName
)
plot
(
1
:
TotalNumberOfMhDraws
,
PosteriorDraws
,
'Color'
,[
.
8
.
8
.
8
]);
hh
=
dyn_figure
(
options_
,
'Name'
,
FigureName
);
plot
(
1
:
TotalNumberOfMhDraws
,
PosteriorDraws
,
'Color'
,[
.
7
.
7
.
7
]);
% Compute the moving average of the posterior draws:
...
...
@@ -112,4 +111,15 @@ end
hold
on
plot
(
1
:
TotalNumberOfMhDraws
,
MovingAverage
,
'-k'
,
'linewidth'
,
2
)
hold
off
axis
tight
\ No newline at end of file
axis
tight
legend
({
'MCMC draw'
;[
num2str
(
N
)
' period moving average'
]},
'Location'
,
'NorthWest'
)
% create subdirectory <fname>/graphs if it doesn't exist
if
~
exist
(
M_
.
fname
,
'dir'
)
mkdir
(
'.'
,
M_
.
fname
);
end
if
~
exist
([
M_
.
fname
filesep
'graphs'
])
mkdir
(
M_
.
fname
,
'graphs'
);
end
plot_name
=
get_the_name
(
column
,
0
,
M_
,
estim_params_
,
options_
);
dyn_saveas
(
hh
,[
M_
.
fname
,
filesep
,
'graphs'
,
filesep
,
'TracePlot_'
plot_name
],
options_
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment