diff --git a/tests/estimation/method_of_moments/RBC_MoM_common.inc b/tests/estimation/method_of_moments/RBC_MoM_common.inc index 625a9c50b88616ac61628a67eec2f587a1e2e461..d480e35c06253961f95edf3d597a61ef44bd14c8 100644 --- a/tests/estimation/method_of_moments/RBC_MoM_common.inc +++ b/tests/estimation/method_of_moments/RBC_MoM_common.inc @@ -60,7 +60,7 @@ IV_O_N = DELTA*K_O_N; Y_O_N = A*K_O_N^(1-ALFA); C_O_N = Y_O_N - IV_O_N; -N=RBC_MoM_steady_helper(THETA,ETAl,ETAc,BETTA,B,C_O_N,W); +[N, info]=RBC_MoM_steady_helper(THETA,ETAl,ETAc,BETTA,B,C_O_N,W); C=C_O_N*N; Y=Y_O_N*N; IV=IV_O_N*N; diff --git a/tests/estimation/method_of_moments/RBC_MoM_steady_helper.m b/tests/estimation/method_of_moments/RBC_MoM_steady_helper.m index 08185c1e16ef38dedd379c6e46d726df66b545fe..df37641486ab0c346398cf25535084f5ce648826 100644 --- a/tests/estimation/method_of_moments/RBC_MoM_steady_helper.m +++ b/tests/estimation/method_of_moments/RBC_MoM_steady_helper.m @@ -1,8 +1,17 @@ -function N = RBC_MoM_steady_helper(THETA,ETAl,ETAc,BETTA,B,C_O_N,W) +function [N, info]= RBC_MoM_steady_helper(THETA,ETAl,ETAc,BETTA,B,C_O_N,W) +info=0; +if ~isreal(C_O_N) + info=1; + N=NaN; + return; +end 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)); + [N, ~, exitflag] = 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)); + if exitflag<1 + info=1; + end end \ No newline at end of file