Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Minje Jeon
dynare
Commits
1c54eb21
Verified
Commit
1c54eb21
authored
Aug 16, 2021
by
Stéphane Adjemian
Browse files
Cosmetic change (remove trailing spaces).
parent
a5995aec
Changes
4
Hide whitespace changes
Inline
Side-by-side
matlab/method_of_moments/method_of_moments.m
View file @
1c54eb21
...
...
@@ -416,7 +416,7 @@ for jm=1:size(M_.matched_moments,1)
% sort such that t=0 variable comes first
[
M_
.
matched_moments
{
jm
,
2
},
idx_sort
]
=
sort
(
M_
.
matched_moments
{
jm
,
2
},
'descend'
);
M_
.
matched_moments
{
jm
,
1
}
=
M_
.
matched_moments
{
jm
,
1
}(
idx_sort
);
M_
.
matched_moments
{
jm
,
3
}
=
M_
.
matched_moments
{
jm
,
3
}(
idx_sort
);
M_
.
matched_moments
{
jm
,
3
}
=
M_
.
matched_moments
{
jm
,
3
}(
idx_sort
);
end
% find duplicate rows in cell array by making groups according to powers as we can then use cell2mat for the unique function
...
...
@@ -430,14 +430,14 @@ end
% remove duplicate elements
DuplicateMoms
=
setdiff
(
1
:
size
(
M_
.
matched_moments_orig
,
1
),
UniqueMomIdx
);
if
~
isempty
(
DuplicateMoms
)
if
~
isempty
(
DuplicateMoms
)
fprintf
(
'Found and removed duplicate declared moments in
''
matched_moments
''
block in rows:\n %s.\n'
,
num2str
(
DuplicateMoms
))
fprintf
(
'Dynare will continue with remaining moment conditions\n'
);
end
if
strcmp
(
options_mom_
.
mom
.
mom_method
,
'SMM'
)
% for SMM we can keep the original structure but get rid of duplicate moments
M_
.
matched_moments
=
M_
.
matched_moments_orig
(
sort
(
UniqueMomIdx
),:);
M_
.
matched_moments
=
M_
.
matched_moments_orig
(
sort
(
UniqueMomIdx
),:);
elseif
strcmp
(
options_mom_
.
mom
.
mom_method
,
'GMM'
)
% for GMM we use the transformed matched_moments structure
M_
.
matched_moments
=
M_
.
matched_moments
(
sort
(
UniqueMomIdx
),:);
...
...
@@ -447,7 +447,7 @@ end
first_moment_indicator
=
find
(
cellfun
(
@
(
x
)
sum
(
abs
(
x
))
==
1
,
M_
.
matched_moments
(:,
3
)))
'
;
if
options_mom_
.
prefilter
&&
~
isempty
(
first_moment_indicator
)
fprintf
(
'Centered moments requested (prefilter option is set); therefore, ignore declared first moments in
''
matched_moments
''
block.\n'
);
M_
.
matched_moments
(
first_moment_indicator
,:)
=
[];
%remove first moments entries
M_
.
matched_moments
(
first_moment_indicator
,:)
=
[];
%remove first moments entries
end
options_mom_
.
mom
.
mom_nbr
=
size
(
M_
.
matched_moments
,
1
);
...
...
@@ -987,7 +987,7 @@ for jm = 1:size(M_.matched_moments,1)
end
data_mat
=
[
oo_
.
mom
.
data_moments
oo_
.
mom
.
model_moments
];
dyntable
(
options_mom_
,
title
,
headers
,
labels
,
data_mat
,
cellofchararraymaxlength
(
labels
)
+
2
,
10
,
7
);
if
options_mom_
.
TeX
if
options_mom_
.
TeX
dyn_latex_table
(
M_
,
options_mom_
,
title
,
[
'comparison_moments_'
,
options_mom_
.
mom
.
mom_method
],
headers
,
labels_TeX
,
data_mat
,
cellofchararraymaxlength
(
labels
)
+
2
,
10
,
7
);
end
...
...
matlab/method_of_moments/method_of_moments_objective_function.m
View file @
1c54eb21
...
...
@@ -184,7 +184,7 @@ if strcmp(options_mom_.mom.mom_method,'GMM')
oo_
.
mom
.
model_moments_params_derivs
(
jm
,
jp
)
=
pruned_state_space
.
dVar_y
(
idx1
,
idx2
,
jp
)
+
pruned_state_space
.
dE_y
(
idx1
,
jp
)
*
pruned_state_space
.
E_y
(
idx2
)
' + pruned_state_space.E_y(idx1)*pruned_state_space.dE_y(idx2,jp)'
;
end
end
end
end
else
% Autocovariance
lag
=
-
M_
.
matched_moments
{
jm
,
2
}(
2
);
%note that leads/lags in matched_moments are transformed such that first entry is always 0 and the second is a lag
...
...
@@ -200,12 +200,12 @@ if strcmp(options_mom_.mom.mom_method,'GMM')
oo_
.
mom
.
model_moments_params_derivs
(
jm
,
jp
)
=
vec
(
pruned_state_space
.
dVar_yi
(
idx1
,
idx2
,
lag
,
jp
)
+
pruned_state_space
.
dE_y
(
idx1
,
jp
)
*
pruned_state_space
.
E_y
(
idx2
)
' + pruned_state_space.E_y(idx1)*pruned_state_space.dE_y(idx2,jp)'
);
end
end
end
end
end
end
end
end
elseif
strcmp
(
options_mom_
.
mom
.
mom_method
,
'SMM'
)
%------------------------------------------------------------------------------
% 3. Compute Moments of the model solution for normal innovations
...
...
tests/estimation/method_of_moments/AnScho/AnScho_MoM_common.inc
View file @
1c54eb21
...
...
@@ -253,7 +253,7 @@ method_of_moments(
,
'MaxFunEvals'
,
1
D6
%
maximum
number
of
function
evaluations
allowed
,
a
positive
integer
%
,
'UseParallel'
,
1
%
when
true
(
and
supported
by
optimizer
)
solver
estimates
gradients
in
parallel
(
using
Matlab
/
Octave
's parallel toolbox)
% ,'
Jacobian
' , '
off
' % when '
off
' gradient-based solvers approximate Jacobian using finite differences; for GMM we can also pass the analytical Jacobian to gradient-based solvers by setting this '
on
'
)
)
%
,
silent_optimizer
%
run
minimization
of
moments
distance
silently
without
displaying
results
or
saving
files
in
between
%
Numerical
algorithms
options
...
...
tests/estimation/method_of_moments/AnScho/AnScho_matched_moments.mod
View file @
1c54eb21
...
...
@@ -17,7 +17,7 @@ iINT = strmatch('INT', M_.endo_names,'exact');
% - third entry: power
matched_moments_orig = {
%first-order product moments
[iYGR ] [0 ], [1];
[iYGR ] [-1], [1];
...
...
@@ -27,7 +27,7 @@ matched_moments_orig = {
[iINFL ] [2 ], [1];
[iINT ] [-2], [1];
[iINT ] [2 ], [1];
%second-order contemporenous product moments
[iYGR ] [0 ], [2 ];
[iYGR ] [-1 ], [2 ];
...
...
@@ -54,7 +54,7 @@ matched_moments_orig = {
[iYGR iINFL] [5 -3], [1 1];
[iYGR iINFL] [5 -3], [1 1];
[iINT iINFL] [2 3], [1 1];
[iYGR ] [0 ], [3 ];
[iYGR iYGR ] [-3 -3 ], [1 2 ];
[iYGR iYGR ] [-3 -3 ], [1 2 ];
...
...
@@ -64,12 +64,12 @@ matched_moments_orig = {
[iINFL iINT ] [1 0 ], [4 2 ];
[iYGR iINFL iINT] [0 -3 5], [2 4 6];
[iINFL iYGR iINT] [-3 0 5], [4 2 6];
[iINFL iYGR iINT] [-3 0 5], [4 2 6];
[iINFL iYGR iINT] [-3 0 5], [4 2 6];
};
% Removed duplicate moment conditions
matched_moments_no_duplicate= {
%first-order product moments
[iYGR ] [0 ], [1];
% [iYGR ] [-1], [1];
...
...
@@ -79,7 +79,7 @@ matched_moments_no_duplicate= {
[iINFL ] [2 ], [1];
[iINT ] [-2], [1];
% [iINT ] [2 ], [1];
%second-order contemporenous product moments
[iYGR ] [0 ], [2 ];
% [iYGR ] [-1 ], [2 ];
...
...
@@ -106,7 +106,7 @@ matched_moments_no_duplicate= {
[iYGR iINFL] [5 -3], [1 1];
% [iYGR iINFL] [5 -3], [1 1];
[iINT iINFL] [2 3], [1 1];
[iYGR ] [0 ], [3 ];
% [iYGR iYGR ] [-3 -3 ], [1 2 ];
% [iYGR iYGR ] [-3 -3 ], [1 2 ];
...
...
@@ -116,7 +116,7 @@ matched_moments_no_duplicate= {
% [iINFL iINT ] [1 0 ], [4 2 ];
[iYGR iINFL iINT] [0 -3 5], [2 4 6];
% [iINFL iYGR iINT] [-3 0 5], [4 2 6];
% [iINFL iYGR iINT] [-3 0 5], [4 2 6];
% [iINFL iYGR iINT] [-3 0 5], [4 2 6];
};
...
...
@@ -131,4 +131,4 @@ if ~isequal(M_.matched_moments,matched_moments_no_duplicate)
error('Removal of duplicate moment conditions failed!')
else
fprintf('Removal of duplicate moment conditions was successful!\n\n')
end
\ No newline at end of file
end
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment