diff --git a/tests/.gitignore b/tests/.gitignore index 501fbc71d03f0f5e8098101e43bfa26287473633..722a27d5d7d11d53c5cdc860106a4364cda2f7c0 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -50,6 +50,8 @@ wsOct !/ep/mean_preserving_spread.m !/ep/rbcii_steady_state.m !/estimation/fsdat_simul.m +!/estimation/method_of_moments/RBC_MoM_steady_helper.m +!/estimation/method_of_moments/RBC_Andreasen_Data_2.mat !/expectations/expectation_ss_old_steadystate.m !/external_function/extFunDeriv.m !/external_function/extFunNoDerivs.m diff --git a/tests/Makefile.am b/tests/Makefile.am index cfaf424ffe8e2acc239440b46790f9302484a767..88302799d47117c221df3fed009779808e20f563 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,8 +25,6 @@ MODFILES = \ measurement_errors/fs2000_corr_me_ml_mcmc/fs2000_corr_ME.mod \ TeX/fs2000_corr_ME.mod \ estimation/MH_recover/fs2000_recover_tarb.mod \ - estimation/method_of_moments/RBC_MoM.mod \ - estimation/method_of_moments/RBC_MoM_SMM_ME.mod \ estimation/fs2000.mod \ gsa/ls2003a.mod \ optimizers/fs2000_8.mod \ @@ -50,7 +48,9 @@ MODFILES = \ estimation/t_proposal/fs2000_student.mod \ estimation/tune_mh_jscale/fs2000.mod \ estimation/method_of_moments/AnScho_MoM.mod \ - estimation/method_of_moments/RBCmodel_MoM.mod \ + estimation/method_of_moments/RBC_MoM_Andreasen.mod \ + estimation/method_of_moments/RBC_MoM_SMM_ME.mod \ + estimation/method_of_moments/RBC_MoM_prefilter.mod \ moments/example1_var_decomp.mod \ moments/example1_bp_test.mod \ moments/test_AR1_spectral_density.mod \ diff --git a/tests/estimation/method_of_moments/AnScho_MoM.mod b/tests/estimation/method_of_moments/AnScho_MoM.mod index 7b482897c18f3b4b778676dbe818455f63506e27..674111120283a75c0f3ac4a07b12555248d32bca 100644 --- a/tests/estimation/method_of_moments/AnScho_MoM.mod +++ b/tests/estimation/method_of_moments/AnScho_MoM.mod @@ -194,7 +194,7 @@ matched_moments_ = { % , penalized_estimator % use penalized optimization , pruning % use pruned state space system at higher-order % , verbose % display and store intermediate estimation results - , weighting_matrix = OPTIMAL % weighting matrix in moments distance objective function; possible values: OPTIMAL|IDENTITY_MATRIX|DIAGONAL|filename + , weighting_matrix = ['optimal'] % weighting matrix in moments distance objective function; possible values: OPTIMAL|IDENTITY_MATRIX|DIAGONAL|filename , additional_optimizer_steps = [4] % vector of numbers for the iterations in the 2-step feasible method of moments % , prefilter=0 % demean each data series by its empirical mean and use centered moments % diff --git a/tests/estimation/method_of_moments/RBC_Andreasen_Data_2.mat b/tests/estimation/method_of_moments/RBC_Andreasen_Data_2.mat new file mode 100644 index 0000000000000000000000000000000000000000..0b2ba62defdaab77aa663f2907ae16801837f6b6 Binary files /dev/null and b/tests/estimation/method_of_moments/RBC_Andreasen_Data_2.mat differ diff --git a/tests/estimation/method_of_moments/RBC_MoM.mod b/tests/estimation/method_of_moments/RBC_MoM.mod deleted file mode 100644 index 7714ac5f2b9568c3432ff003d51c1d6d1751ca80..0000000000000000000000000000000000000000 --- a/tests/estimation/method_of_moments/RBC_MoM.mod +++ /dev/null @@ -1,194 +0,0 @@ -% Tests SMM and GMM routines -% -% Copyright (C) 2020 Dynare Team -% -% This file is part of Dynare. -% -% Dynare is free software: you can redistribute it and/or modify -% it under the terms of the GNU General Public License as published by -% the Free Software Foundation, either version 3 of the License, or -% (at your option) any later version. -% -% Dynare is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with Dynare. If not, see <http://www.gnu.org/licenses/>. -% ========================================================================= - -% Define testscenario -@#define orderApp = 1 -@#define estimParams = 1 - -% Note that we will set the numerical optimization tolerance levels very large to speed up the testsuite -@#define optimizer = 13 - - -@#include "RBC_MoM_common.inc" - -shocks; -var u_a; stderr 0.0072; -end; - -varobs n c iv; - - -@#if estimParams == 0 -estimated_params; - DELTA, 0.025; - BETTA, 0.98; - B, 0.45; - %ETAl, 1; - ETAc, 1.8; - ALFA, 0.65; - RHOA, 0.95; - stderr u_a, 0.01; - %THETA, 3.48; -end; -@#endif - -@#if estimParams == 1 -estimated_params; - DELTA, , 0, 1; - BETTA, , 0, 1; - B, , 0, 1; - %ETAl, 1, 0, 10; - ETAc, , 0, 10; - ALFA, , 0, 1; - RHOA, , 0, 1; - stderr u_a, , 0, 1; - %THETA, 3.48, 0, 10; -end; -@#endif - -@#if estimParams == 2 -estimated_params; - DELTA, 0.025, 0, 1, normal_pdf, 0.02, 0.5; - BETTA, 0.98, 0, 1, beta_pdf, 0.90, 0.25; - B, 0.45, 0, 1, normal_pdf, 0.40, 0.5; - %ETAl, 1, 0, 10, normal_pdf, 0.25, 0.0.1; - ETAc, 1.8, 0, 10, normal_pdf, 1.80, 0.5; - ALFA, 0.65, 0, 1, normal_pdf, 0.60, 0.5; - RHOA, 0.95, 0, 1, normal_pdf, 0.90, 0.5; - stderr u_a, 0.01, 0, 1, normal_pdf, 0.01, 0.5; - %THETA, 3.48, 0, 10, normal_pdf, 0.25, 0.0.1; -end; -@#endif - -% Simulate data -stoch_simul(order=@{orderApp},pruning,nodisplay,nomoments,periods=500); -save('RBC_MoM_data_@{orderApp}.mat', options_.varobs{:} ); -pause(1); - - -estimated_params_init(use_calibration); -end; - -%-------------------------------------------------------------------------- -% Method of Moments Estimation -%-------------------------------------------------------------------------- -% matched_moments blocks : We don't have an interface yet - -% get indices in declaration order -ic = strmatch('c', M_.endo_names,'exact'); -iiv = strmatch('iv', M_.endo_names,'exact'); -in = strmatch('n', M_.endo_names,'exact'); -% first entry: number of variable in declaration order -% second entry: lag -% third entry: power - -matched_moments_ = { - [ic ] [0 ], [1 ]; - [in ] [0 ], [1 ]; - [iiv ] [0 ], [1 ]; - [ic ic ] [0 0], [1 1]; - [ic iiv] [0 0], [1 1]; - [ic in ] [0 0], [1 1]; - [iiv ic ] [0 0], [1 1]; - [iiv iiv] [0 0], [1 1]; - [iiv in ] [0 0], [1 1]; -% [in ic ] [0 0], [1 1]; -% [in iiv] [0 0], [1 1]; - [in in ] [0 0], [1 1]; - [ic ic ] [0 -1], [1 1]; - [in in ] [0 -1], [1 1]; - [iiv iiv] [0 -1], [1 1]; -% [iiv iiv] [0 -1], [1 1]; -}; - - - -@#for mommethod in ["GMM", "SMM"] - method_of_moments( - % Necessery options - mom_method = @{mommethod} % method of moments method; possible values: GMM|SMM - , datafile = 'RBC_MoM_data_@{orderApp}.mat' % name of filename with data - - % Options for both GMM and SMM - % , bartlett_kernel_lag = 20 % bandwith in optimal weighting matrix - , order = @{orderApp} % order of Taylor approximation in perturbation - % , penalized_estimator % use penalized optimization - , pruning % use pruned state space system at higher-order - % , verbose % display and store intermediate estimation results - , weighting_matrix = ['optimal','optimal'] % weighting matrix in moments distance objective function; possible values: OPTIMAL|IDENTITY_MATRIX|DIAGONAL|filename - , weighting_matrix_scaling_factor=1 - %, additional_optimizer_steps = [4] % vector of additional mode-finders run after mode_compute - % , prefilter=0 % demean each data series by its empirical mean and use centered moments - % - % Options for SMM - % , bounded_shock_support % trim shocks in simulation to +- 2 stdev - % , drop = 500 % number of periods dropped at beginning of simulation - % , seed = 24051986 % seed used in simulations - % , simulation_multiple = 5 % multiple of the data length used for simulation - % - % General options - %, dirname = 'MM' % directory in which to store estimation output - % , graph_format = EPS % specify the file format(s) for graphs saved to disk - % , nodisplay % do not display the graphs, but still save them to disk - % , nograph % do not create graphs (which implies that they are not saved to the disk nor displayed) - % , noprint % do not print stuff to console - % , plot_priors = 1 % control plotting of priors - % , prior_trunc = 1e-10 % probability of extreme values of the prior density that is ignored when computing bounds for the parameters - % , TeX % print TeX tables and graphics - % - % Data and model options - %, first_obs = 501 % number of first observation - % , logdata % if loglinear is set, this option is necessary if the user provides data already in logs, otherwise the log transformation will be applied twice (this may result in complex data) - % , loglinear % computes a log-linear approximation of the model instead of a linear approximation - %, nobs = 500 % number of observations - % , xls_sheet = willi % name of sheet with data in Excel - % , xls_range = B2:D200 % range of data in Excel sheet - % - % Optimization options that can be set by the user in the mod file, otherwise default values are provided - % , analytic_derivation % uses analytic derivatives to compute standard errors for GMM - %, huge_number=1D10 % value for replacing the infinite bounds on parameters by finite numbers. Used by some optimizers for numerical reasons - , mode_compute = @{optimizer} % specifies the optimizer for minimization of moments distance, note that by default there is a new optimizer - %, optim = ('TolFun', 1e-3 - % ,'TolX', 1e-5 - % ) % a list of NAME and VALUE pairs to set options for the optimization routines. Available options depend on mode_compute - %, silent_optimizer % run minimization of moments distance silently without displaying results or saving files in between - % , tolf = 1e-5 % convergence criterion on function value for numerical differentiation - % , tolx = 1e-6 % convergence criterion on funciton input for numerical differentiation - % - % % Numerical algorithms options - % , aim_solver % Use AIM algorithm to compute perturbation approximation - % , dr=default % method used to compute the decision rule; possible values are DEFAULT, CYCLE_REDUCTION, LOGARITHMIC_REDUCTION - % , dr_cycle_reduction_tol = 1e-7 % convergence criterion used in the cycle reduction algorithm - % , dr_logarithmic_reduction_maxiter = 100 % maximum number of iterations used in the logarithmic reduction algorithm - % , dr_logarithmic_reduction_tol = 1e-12 % convergence criterion used in the cycle reduction algorithm - % , k_order_solver % use k_order_solver in higher order perturbation approximations - % , lyapunov = DEFAULT % algorithm used to solve lyapunov equations; possible values are DEFAULT, FIXED_POINT, DOUBLING, SQUARE_ROOT_SOLVER - % , lyapunov_complex_threshold = 1e-15 % complex block threshold for the upper triangular matrix in symmetric Lyapunov equation solver - % , lyapunov_fixed_point_tol = 1e-10 % convergence criterion used in the fixed point Lyapunov solver - % , lyapunov_doubling_tol = 1e-16 % convergence criterion used in the doubling algorithm - % , sylvester = default % algorithm to solve Sylvester equation; possible values are DEFAULT, FIXED_POINT - % , sylvester_fixed_point_tol = 1e-12 % convergence criterion used in the fixed point Sylvester solver - % , qz_criterium = 0.999999 % value used to split stable from unstable eigenvalues in reordering the Generalized Schur decomposition used for solving first order problems [IS THIS CORRET @wmutschl] - % , qz_zero_threshold = 1e-6 % value used to test if a generalized eigenvalue is 0/0 in the generalized Schur decomposition - ); -@#endfor - - - diff --git a/tests/estimation/method_of_moments/RBC_MoM_Andreasen.mod b/tests/estimation/method_of_moments/RBC_MoM_Andreasen.mod new file mode 100644 index 0000000000000000000000000000000000000000..feb47cb3a7db966a98538d123d5eaa782161c06b --- /dev/null +++ b/tests/estimation/method_of_moments/RBC_MoM_Andreasen.mod @@ -0,0 +1,202 @@ +% Tests SMM and GMM routines +% +% Copyright (C) 2020 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see <http://www.gnu.org/licenses/>. +% ========================================================================= + +% Define testscenario +@#define orderApp = 2 +@#define estimParams = 1 + +% Note that we will set the numerical optimization tolerance levels very large to speed up the testsuite +@#define optimizer = 13 + + +@#include "RBC_MoM_common.inc" + +shocks; +var u_a; stderr 0.0072; +end; + +varobs c iv n; + + +@#if estimParams == 0 +estimated_params; + DELTA, 0.025; + BETTA, 0.984; + B, 0.5; + ETAc, 2; + ALFA, 0.667; + RHOA, 0.979; + stderr u_a, 0.0072; +end; +@#endif + +@#if estimParams == 1 +estimated_params; + DELTA, , 0, 1; + BETTA, , 0, 1; + B, , 0, 1; + ETAc, , 0, 10; + ALFA, , 0, 1; + RHOA, , 0, 1; + stderr u_a, , 0, 1; +end; +@#endif + +@#if estimParams == 2 +estimated_params; + DELTA, 0.025, 0, 1, normal_pdf, 0.02, 0.5; + BETTA, 0.98, 0, 1, beta_pdf, 0.90, 0.25; + B, 0.45, 0, 1, normal_pdf, 0.40, 0.5; + %ETAl, 1, 0, 10, normal_pdf, 0.25, 0.0.1; + ETAc, 1.8, 0, 10, normal_pdf, 1.80, 0.5; + ALFA, 0.65, 0, 1, normal_pdf, 0.60, 0.5; + RHOA, 0.95, 0, 1, normal_pdf, 0.90, 0.5; + stderr u_a, 0.01, 0, 1, normal_pdf, 0.01, 0.5; + %THETA, 3.48, 0, 10, normal_pdf, 0.25, 0.0.1; +end; +@#endif + +% Simulate data +%stoch_simul(order=@{orderApp},pruning,nodisplay,nomoments,periods=500); +%save('RBC_MoM_data_@{orderApp}.mat', options_.varobs{:} ); +%pause(1); + + +estimated_params_init(use_calibration); +end; + +%-------------------------------------------------------------------------- +% Method of Moments Estimation +%-------------------------------------------------------------------------- +% matched_moments blocks : We don't have an interface yet + +% get indices in declaration order +ic = strmatch('c', M_.endo_names,'exact'); +iiv = strmatch('iv', M_.endo_names,'exact'); +in = strmatch('n', M_.endo_names,'exact'); +% first entry: number of variable in declaration order +% second entry: lag +% third entry: power + +matched_moments_ = { + [ic ] [0 ], [1 ]; + [in ] [0 ], [1 ]; + [iiv ] [0 ], [1 ]; + + [ic ic ] [0 0], [1 1]; + [ic iiv] [0 0], [1 1]; + %[ic in ] [0 0], [1 1]; + %[iiv ic ] [0 0], [1 1]; + [iiv in ] [0 0], [1 1]; + [iiv iiv] [0 0], [1 1]; + [in ic ] [0 0], [1 1]; + %[in iiv] [0 0], [1 1]; + [in in ] [0 0], [1 1]; + + [ic ic ] [0 -1], [1 1]; + [in in ] [0 -1], [1 1]; + [iiv iiv] [0 -1], [1 1]; + + [ic ic ] [0 -3], [1 1]; + [in in ] [0 -3], [1 1]; + [iiv iiv] [0 -3], [1 1]; + + [ic ic ] [0 -5], [1 1]; + [in in ] [0 -5], [1 1]; + [iiv iiv] [0 -5], [1 1]; + +}; + + + + method_of_moments( + % Necessery options + mom_method = GMM % method of moments method; possible values: GMM|SMM + , datafile = 'RBC_Andreasen_Data_2.mat' % name of filename with data + + % Options for both GMM and SMM + %, bartlett_kernel_lag = 20 % bandwith in optimal weighting matrix + , order = 2 % order of Taylor approximation in perturbation + %, penalized_estimator % use penalized optimization + %, pruning % use pruned state space system at higher-order + %, verbose % display and store intermediate estimation results + , weighting_matrix = ['DIAGONAL','OPTIMAL'] % weighting matrix in moments distance objective function; possible values: OPTIMAL|IDENTITY_MATRIX|DIAGONAL|filename + %, weighting_matrix_scaling_factor=1 + , additional_optimizer_steps = [13] % vector of additional mode-finders run after mode_compute + %, prefilter=0 % demean each data series by its empirical mean and use centered moments + % + % Options for SMM + %, bounded_shock_support % trim shocks in simulation to +- 2 stdev + %, drop = 500 % number of periods dropped at beginning of simulation + %, seed = 24051986 % seed used in simulations + %, simulation_multiple = 5 % multiple of the data length used for simulation + %, burnin = 200 + % + % General options + %, dirname = 'MM' % directory in which to store estimation output + %, graph_format = EPS % specify the file format(s) for graphs saved to disk + %, nodisplay % do not display the graphs, but still save them to disk + %, nograph % do not create graphs (which implies that they are not saved to the disk nor displayed) + %, noprint % do not print stuff to console + %, plot_priors = 1 % control plotting of priors + %, prior_trunc = 1e-10 % probability of extreme values of the prior density that is ignored when computing bounds for the parameters + , TeX % print TeX tables and graphics + % + % Data and model options + %, first_obs = 501 % number of first observation + %, logdata % if loglinear is set, this option is necessary if the user provides data already in logs, otherwise the log transformation will be applied twice (this may result in complex data) + %, loglinear % computes a log-linear approximation of the model instead of a linear approximation + %, nobs = 50 % number of observations + % , xls_sheet = willi % name of sheet with data in Excel + % , xls_range = B2:D200 % range of data in Excel sheet + % + % Optimization options that can be set by the user in the mod file, otherwise default values are provided + %, analytic_derivation % uses analytic derivatives to compute standard errors for GMM + %, huge_number=1D10 % value for replacing the infinite bounds on parameters by finite numbers. Used by some optimizers for numerical reasons + , mode_compute = 13 % specifies the optimizer for minimization of moments distance, note that by default there is a new optimizer + , optim = ('TolFun', 1D-6 + ,'TolX', 1D-6 + ) % a list of NAME and VALUE pairs to set options for the optimization routines. Available options depend on mode_compute + %, silent_optimizer % run minimization of moments distance silently without displaying results or saving files in between + , se_tolx = 1e-6 % convergence criterion on funciton input for numerical differentiation + % + % % Numerical algorithms options + %, aim_solver % Use AIM algorithm to compute perturbation approximation + %, dr=DEFAULT % method used to compute the decision rule; possible values are DEFAULT, CYCLE_REDUCTION, LOGARITHMIC_REDUCTION + %, dr_cycle_reduction_tol = 1e-7 % convergence criterion used in the cycle reduction algorithm + %, dr_logarithmic_reduction_maxiter = 100 % maximum number of iterations used in the logarithmic reduction algorithm + %, dr_logarithmic_reduction_tol = 1e-12 % convergence criterion used in the cycle reduction algorithm + %, k_order_solver % use k_order_solver in higher order perturbation approximations + %, lyapunov = DEFAULT % algorithm used to solve lyapunov equations; possible values are DEFAULT, FIXED_POINT, DOUBLING, SQUARE_ROOT_SOLVER + %, lyapunov_complex_threshold = 1e-15 % complex block threshold for the upper triangular matrix in symmetric Lyapunov equation solver + %, lyapunov_fixed_point_tol = 1e-10 % convergence criterion used in the fixed point Lyapunov solver + %, lyapunov_doubling_tol = 1e-16 % convergence criterion used in the doubling algorithm + %, sylvester = default % algorithm to solve Sylvester equation; possible values are DEFAULT, FIXED_POINT + %, sylvester_fixed_point_tol = 1e-12 % convergence criterion used in the fixed point Sylvester solver + %, qz_criterium = 0.999999 % value used to split stable from unstable eigenvalues in reordering the Generalized Schur decomposition used for solving first order problems [IS THIS CORRET @wmutschl] + %, qz_zero_threshold = 1e-6 % value used to test if a generalized eigenvalue is 0/0 in the generalized Schur decomposition + , mode_check + %, mode_check_neighbourhood_size=0.5 + %, mode_check_symmetric_plots=0 + %, mode_check_number_of_points=25 + ); + + + diff --git a/tests/estimation/method_of_moments/RBC_MoM_SMM_ME.mod b/tests/estimation/method_of_moments/RBC_MoM_SMM_ME.mod index a5199c1c0bfd15d2e1a0921cbe1a00fe8354006d..a0e4ea654cd699c3db19dffc5a75645ba02f3cab 100644 --- a/tests/estimation/method_of_moments/RBC_MoM_SMM_ME.mod +++ b/tests/estimation/method_of_moments/RBC_MoM_SMM_ME.mod @@ -16,11 +16,11 @@ % ========================================================================= % Define testscenario -@#define orderApp = 2 +@#define orderApp = 1 @#define estimParams = 0 % Note that we will set the numerical optimization tolerance levels very large to speed up the testsuite -@#define optimizer = 13 +@#define optimizer = 5 @#include "RBC_MoM_common.inc" @@ -33,14 +33,14 @@ varobs n c iv; @#if estimParams == 0 estimated_params; - DELTA, 0.02; - BETTA, 0.9; - B, 0.4; + DELTA, 0.025; + BETTA, 0.984; + B, 0.5; %ETAl, 1; - ETAc, 1.5; - ALFA, 0.6; - RHOA, 0.9; - stderr u_a, 0.010; + ETAc, 1; + ALFA, 0.667; + RHOA, 0.979; + stderr u_a, 0.0072; %THETA, 3.48; stderr n, 0.01; @@ -76,7 +76,7 @@ end; @#endif % Simulate data -stoch_simul(order=@{orderApp},pruning,nodisplay,nomoments,periods=750,drop=500); +stoch_simul(order=@{orderApp},pruning,nodisplay,nomoments,periods=250); save('RBC_MoM_data_@{orderApp}.mat', options_.varobs{:} ); pause(1); @@ -128,8 +128,10 @@ matched_moments_ = { % , penalized_estimator % use penalized optimization , pruning % use pruned state space system at higher-order % , verbose % display and store intermediate estimation results - , weighting_matrix = OPTIMAL % weighting matrix in moments distance objective function; possible values: OPTIMAL|IDENTITY_MATRIX|DIAGONAL|filename - , additional_optimizer_steps = [4] % vector of additional mode-finders run after mode_compute + , weighting_matrix = ['identity_matrix'] % weighting matrix in moments distance objective function; possible values: OPTIMAL|IDENTITY_MATRIX|DIAGONAL|filename + , weighting_matrix_scaling_factor = 10 + , burnin=250 + %, additional_optimizer_steps = [4] % vector of additional mode-finders run after mode_compute % , prefilter=0 % demean each data series by its empirical mean and use centered moments % % Options for SMM diff --git a/tests/estimation/method_of_moments/RBC_MoM_prefilter.mod b/tests/estimation/method_of_moments/RBC_MoM_prefilter.mod index de5d12d5f02a3b81520d3bd99fe36d28bc59dd0c..22924d0666800b38b523efa406562c68a75dc02b 100644 --- a/tests/estimation/method_of_moments/RBC_MoM_prefilter.mod +++ b/tests/estimation/method_of_moments/RBC_MoM_prefilter.mod @@ -87,7 +87,7 @@ matched_moments_ = { % [iiv iiv] [0 -1], [1 1]; }; -weighting_matrix=diag([1000;ones(6,1)]); +weighting_matrix=diag([1000;ones(8,1)]); save('test_matrix.mat','weighting_matrix') @#for mommethod in ["GMM", "SMM"] diff --git a/tests/estimation/method_of_moments/RBC_MoM_steady_helper.m b/tests/estimation/method_of_moments/RBC_MoM_steady_helper.m new file mode 100644 index 0000000000000000000000000000000000000000..08185c1e16ef38dedd379c6e46d726df66b545fe --- /dev/null +++ b/tests/estimation/method_of_moments/RBC_MoM_steady_helper.m @@ -0,0 +1,8 @@ +function N = RBC_MoM_steady_helper(THETA,ETAl,ETAc,BETTA,B,C_O_N,W) +if ETAc == 1 && ETAl == 1 + N = (1-BETTA*B)*(C_O_N*(1-B))^-1*W/THETA/(1+(1-BETTA*B)*(C_O_N*(1-B))^-1*W/THETA); +else + % No closed-form solution use a fixed-point algorithm + N0 = 1/3; + N = fsolve(@(N) THETA*(1-N)^(-ETAl)*N^ETAc - (1-BETTA*B)*(C_O_N*(1-B))^(-ETAc)*W, N0,optimset('Display','off','TolX',1e-12,'TolFun',1e-12)); +end \ No newline at end of file