Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dynare
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stéphane Adjemian
dynare
Commits
7c384a05
Commit
7c384a05
authored
9 years ago
by
Marco Ratto
Committed by
Houtan Bastani
9 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow sampler specific options via optim;
bug fixes on options logic
parent
52e29b1a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/check_posterior_sampler_options.m
+28
-7
28 additions, 7 deletions
matlab/check_posterior_sampler_options.m
with
28 additions
and
7 deletions
matlab/check_posterior_sampler_options.m
+
28
−
7
View file @
7c384a05
...
@@ -41,7 +41,7 @@ if ~strcmp(posterior_sampler_options.posterior_sampling_method,'slice')
...
@@ -41,7 +41,7 @@ if ~strcmp(posterior_sampler_options.posterior_sampling_method,'slice')
error
(
'I Cannot start the MCMC because the Hessian of the posterior kernel at the mode was not computed.'
)
error
(
'I Cannot start the MCMC because the Hessian of the posterior kernel at the mode was not computed.'
)
end
end
if
options_
.
load_mh_file
&&
options_
.
use_mh_covariance_matrix
,
if
options_
.
load_mh_file
&&
options_
.
use_mh_covariance_matrix
,
invhess
=
compute_mh_covariance_matrix
;
[
junk
,
invhess
]
=
compute_mh_covariance_matrix
;
posterior_sampler_options
.
invhess
=
invhess
;
posterior_sampler_options
.
invhess
=
invhess
;
end
end
posterior_sampler_options
.
parallel_bar_refresh_rate
=
50
;
posterior_sampler_options
.
parallel_bar_refresh_rate
=
50
;
...
@@ -61,7 +61,7 @@ if strcmp(options_.posterior_sampling_method,'slice')
...
@@ -61,7 +61,7 @@ if strcmp(options_.posterior_sampling_method,'slice')
posterior_sampler_options
.
save_tmp_file
=
1
;
posterior_sampler_options
.
save_tmp_file
=
1
;
posterior_sampler_options
=
set_default_option
(
posterior_sampler_options
,
'rotated'
,
0
);
posterior_sampler_options
=
set_default_option
(
posterior_sampler_options
,
'rotated'
,
0
);
posterior_sampler_options
=
set_default_option
(
posterior_sampler_options
,
'slice_initialize_with_mode'
,
0
);
posterior_sampler_options
=
set_default_option
(
posterior_sampler_options
,
'slice_initialize_with_mode'
,
0
);
posterior_sampler_options
=
set_default_option
(
posterior_sampler_options
,
'use_
slice
_covariance_matrix'
,
0
);
posterior_sampler_options
=
set_default_option
(
posterior_sampler_options
,
'use_
mh
_covariance_matrix'
,
0
);
posterior_sampler_options
=
set_default_option
(
posterior_sampler_options
,
'WR'
,[]);
posterior_sampler_options
=
set_default_option
(
posterior_sampler_options
,
'WR'
,[]);
if
~
isfield
(
posterior_sampler_options
,
'mode'
),
if
~
isfield
(
posterior_sampler_options
,
'mode'
),
posterior_sampler_options
.
mode
=
[];
posterior_sampler_options
.
mode
=
[];
...
@@ -71,6 +71,27 @@ if strcmp(options_.posterior_sampling_method,'slice')
...
@@ -71,6 +71,27 @@ if strcmp(options_.posterior_sampling_method,'slice')
posterior_sampler_options
=
set_default_option
(
posterior_sampler_options
,
'mode_files'
,[]);
posterior_sampler_options
=
set_default_option
(
posterior_sampler_options
,
'mode_files'
,[]);
posterior_sampler_options
=
set_default_option
(
posterior_sampler_options
,
'W1'
,
0.8
*
(
bounds
.
ub
-
bounds
.
lb
));
posterior_sampler_options
=
set_default_option
(
posterior_sampler_options
,
'W1'
,
0.8
*
(
bounds
.
ub
-
bounds
.
lb
));
if
~
isempty
(
options_
.
optim_opt
)
options_list
=
read_key_value_string
(
options_
.
optim_opt
);
for
i
=
1
:
rows
(
options_list
)
switch
options_list
{
i
,
1
}
case
'rotated'
posterior_sampler_options
.
rotated
=
options_list
{
i
,
2
};
case
'mode'
posterior_sampler_options
.
mode
=
options_list
{
i
,
2
};
case
'mode_files'
posterior_sampler_options
.
mode_files
=
options_list
{
i
,
2
};
case
'slice_initialize_with_mode'
posterior_sampler_options
.
slice_initialize_with_mode
=
options_list
{
i
,
2
};
case
'initial_step_size'
posterior_sampler_options
.
W1
=
options_list
{
i
,
2
}
*
(
bounds
.
ub
-
bounds
.
lb
);
case
'use_mh_covariance_matrix'
posterior_sampler_options
.
use_mh_covariance_matrix
=
options_list
{
i
,
2
};
otherwise
warning
([
'slice_sampler: Unknown option ('
options_list
{
i
,
1
}
')!'
])
end
end
end
if
options_
.
load_mh_file
,
if
options_
.
load_mh_file
,
posterior_sampler_options
.
slice_initialize_with_mode
=
0
;
posterior_sampler_options
.
slice_initialize_with_mode
=
0
;
else
else
...
@@ -80,9 +101,9 @@ if strcmp(options_.posterior_sampling_method,'slice')
...
@@ -80,9 +101,9 @@ if strcmp(options_.posterior_sampling_method,'slice')
end
end
if
posterior_sampler_options
.
rotated
,
if
posterior_sampler_options
.
rotated
,
if
isempty
(
posterior_sampler_options
.
mode_files
)
&&
~
is
field
(
posterior_sampler_options
,
'
mode
'
),
% rotated unimodal
if
isempty
(
posterior_sampler_options
.
mode_files
)
&&
is
empty
(
posterior_sampler_options
.
mode
),
% rotated unimodal
if
~
options_
.
cova_compute
&&
~
(
options_
.
load_mh_file
&&
options
_
.
use_mh_covariance_matrix
)
if
~
options_
.
cova_compute
&&
~
(
options_
.
load_mh_file
&&
posterior_sampler_
options
.
use_mh_covariance_matrix
)
skipline
()
skipline
()
disp
(
'I cannot start rotated slice sampler because'
)
disp
(
'I cannot start rotated slice sampler because'
)
disp
(
'there is no previous MCMC to load '
)
disp
(
'there is no previous MCMC to load '
)
...
@@ -92,8 +113,8 @@ if strcmp(options_.posterior_sampling_method,'slice')
...
@@ -92,8 +113,8 @@ if strcmp(options_.posterior_sampling_method,'slice')
if
isempty
(
invhess
)
if
isempty
(
invhess
)
error
(
'oops! This error should not occur, please contact developers.'
)
error
(
'oops! This error should not occur, please contact developers.'
)
end
end
if
options_
.
load_mh_file
&&
posterior_sampler_options
.
use_
slice
_covariance_matrix
,
if
options_
.
load_mh_file
&&
posterior_sampler_options
.
use_
mh
_covariance_matrix
,
invhess
=
compute_mh_covariance_matrix
;
[
junk
,
invhess
]
=
compute_mh_covariance_matrix
;
posterior_sampler_options
.
invhess
=
invhess
;
posterior_sampler_options
.
invhess
=
invhess
;
end
end
[
V1
D
]
=
eig
(
invhess
);
[
V1
D
]
=
eig
(
invhess
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment