楼主: guanzihuan
3148 4

[DSGE讨论专题] DSGE估计出错,遇到问题,求教!! [推广有奖]

  • 1关注
  • 2粉丝

讲师

60%

还不是VIP/贵宾

-

威望
0
论坛币
4821 个
通用积分
248.3864
学术水平
37 点
热心指数
45 点
信用等级
26 点
经验
5711 点
帖子
165
精华
0
在线时间
961 小时
注册时间
2015-10-10
最后登录
2024-4-3

50论坛币
各位老师们好!
   本人自学DSGE,参考一些文章与他们的代码,在estimation这块遇到了很多问题,请教一下各位大神老师们!

程序报错如下:
Prior distribution for parameter thet has two modes!
警告: BETAINV did not converge for a = 0.000606609, b = 0.000298778, p = 0.001.
> In betainv at 61
  In draw_prior_density at 46
  In plot_priors at 55
  In dynare_estimation_init at 257
  In dynare_estimation_1 at 81
  In dynare_estimation at 89
  In laoshigai2 at 436
  In dynare at 180
警告: BETAINV did not converge for a = 0.000606609, b = 0.000298778, p = 0.999.
> In betainv at 61
  In draw_prior_density at 47
  In plot_priors at 55
  In dynare_estimation_init at 257
  In dynare_estimation_1 at 81
  In dynare_estimation at 89
  In laoshigai2 at 436
  In dynare at 180
警告: BETAINV did not converge for a = 0.000606609, b = 0.000298778, p = 1e-10.
> In betainv at 61
  In prior_bounds at 84
  In dynare_estimation_init at 260
  In dynare_estimation_1 at 81
  In dynare_estimation at 89
  In laoshigai2 at 436
  In dynare at 180
Loading 64 observations from datause.mat

Error in computing likelihood for initial parameter values

ESTIMATION_CHECKS: There was an error in computing the likelihood for initial parameter values.
ESTIMATION_CHECKS: You should try using the calibrated version of the model as starting values. To do
ESTIMATION_CHECKS: this, add an empty estimated_params_init-block with use_calibration option immediately before the estimation
ESTIMATION_CHECKS: command (and after the estimated_params-block so that it does not get overwritten):


错误使用 print_info (line 45)
Blanchard Kahn conditions are not satisfied: indeterminacy

出错 print_info (line 45)
        error(['Blanchard Kahn conditions are not satisfied:' ...

出错 initial_estimation_checks (line 69)
    print_info(info, DynareOptions.noprint, DynareOptions)

出错 dynare_estimation_1 (line 179)
    oo_ =
    initial_estimation_checks(objective_function,xparam1,dataset_,M_,estim_params_,options_,bayestopt_,oo_);

出错 dynare_estimation (line 89)
    dynare_estimation_1(var_list,dname);

出错 laoshigai2 (line 436)
dynare_estimation(var_list_);

出错 dynare (line 180)
evalin('base',fname) ;



mod源代码如下:(这是英文原文中的代码,再加入一个关于G财政支出的方程)
var y c ci cii i rr k x q h j hii b bii a pi r G u has;
varexo e_R  e_j e_u e_a e_has e_ltv e_g;  
parameters lamdaH rouH thet X c_Y ci_Y cii_Y I_Y qh_Y gam delt gamE m mii beta phiE gamH phiH iota iotaii h_H hi_H hii_H eta nu J psi mu alph kap b_Y qhi_Y qhii_Y R bii_Y si sii lamda_g rho_R rho_pi rho_Y rho_j rho_u rho_a rho_has omeg betaii;

beta = 0.99;
delt = 0.025;
alph = 0.64;
mu = 0.39;
X = 1.05;
thet = 0.75;
eta = 1.01;
gam = 0.95;
betaii = 0.985;
nu = 0.11;
J = 0.1;
m = 0.89;
mii = 0.55;
psi = 2;
phiE = 0;
phiH = 0;

rho_u = 0.59;
rho_j = 0.85;
rho_a = 0.03;

rho_Y  = 0.13; %fed does not react to output
rho_pi = 0.27;
rho_R  = 0.73;
rho_has = 0.75;
lamda_g = 0.6;
lamdaH = 0.2;
rouH = 0.2;

%  Extra Definitions
gamE = (1-m)*gam + m*beta;
R = 1/beta;
qh_Y = gam*nu/((1-gamE)*X);
b_Y = beta*m*gam*nu/((1-gamE)*X);
si = (alph*(1-mu-nu) + X - 1)/X; %income share of patient household
sii = (1-alph)*(1-mu-nu)/X; %income share of impatient household
qhi_Y = J*si/(1-beta) + J*m*gam*nu/((1-gamE)*X) + J*mii*sii/(1-betaii-mii*(beta-betaii-J*(1-beta)));
qhii_Y = J*sii/(1-betaii-mii*(beta-betaii-J*(1-beta)));
bii_Y = J*beta*mii*sii/(1-betaii-mii*(beta-betaii) + J*mii*(1-beta));
cii_Y = (1-betaii-mii*(beta-betaii))*sii/(1-betaii-mii*(beta-betaii)+J*mii*(1-beta));
c_Y = (mu+nu-delt*gam*mu/(1-gam*(1-delt)) - (1-beta)*m*gam*nu/(1-gamE))/X;
omeg = (betaii-mii*betaii)/(1-mii*betaii);
iota = (1-beta)*(1-qhi_Y-qhii_Y)/qhi_Y;
iotaii = (1-beta)*qhii_Y/qhi_Y;
gamH = betaii + mii*(beta-betaii);
kap = (1-thet)*(1-beta*thet)/thet;

I_Y = 0.3; %must be calibrated. Not clear what the author used.

%
%Model   
%
model(linear);
rr = r - pi(+1); %//ex ante real rate

// Aggregate Demand Block
y = c_Y*c + (1-c_Y-cii_Y-I_Y)*ci + cii_Y*cii + I_Y*i ;
ci = ci(+1) - rr;
i - k(-1) = gam*(i(+1)-k) + ((1-gam*(1-delt))/psi)*(y(+1)-x(+1)-k) + (1/psi)*(c-c(+1));

// Housing/Consumption Block
q = gamE*q(+1)+(1-gamE)*(y(+1)-x(+1)-h) - m*beta*rr-(1-m*beta)*(c(+1)-c)-phiE*(h - h(-1) - gam*(h(+1) - h));
q = gamH*q(+1) + (1-gamH)*(j - hii) - mii*beta*rr + (1-mii*beta)*cii-omeg*cii(+1) - phiH*(hii-hii(-1) - betaii*(hii(+1)-hii));
q = beta*q(+1) + (1-beta)*j + iota*h + iotaii*hii + ci - beta*ci(+1) + (phiH/qhi_Y)*(qh_Y*(h - h(-1)) + qhii_Y*(hii-hii(-1)) - beta*qh_Y*(h(+1)-h) - beta*qhii_Y*(hii(+1)-hii));

// Borrowing Constraints
b = q(+1) + h - rr;
bii = q(+1) + hii - rr;

// Aggregate Supply and Markup
y = (eta/(eta-(1-nu-mu)))*(a + nu*h(-1) + mu*k(-1)) - ((1-nu-mu)/(nu-(1-nu-mu)))*(x + alph*ci + (1-alph)*cii);
pi = beta*pi(+1) - kap*x + u; %// markup shock enters here

// Flow of Funds/Evolution of State Variables
k = delt*i + (1-delt)*k(-1);
b_Y*b = c_Y*c + qh_Y*(h-h(-1)) + I_Y*i + R*b_Y*(r(-1) + b(-1) - pi) - (1-si-sii)*(y-x) + has;
bii_Y*bii = cii_Y*cii + qhii_Y*(hii-hii(-1)) + R*bii_Y*(bii(-1) + r(-1) - pi) - sii*(y-x) + has;

// Monetary Policy Rule and Shock Processes
r = (1-rho_R)*(1+rho_pi)*pi(-1) + rho_Y*(1-rho_R)*y(-1) + rho_R*r(-1) + e_R;
G = lamda_g*G(-1) - lamdaH*(q-q(-1)) + e_g;
j = rho_j*j(-1) - rouH*(q-q(-1)) + e_j;
u = rho_u*u(-1) + e_u;
a = rho_a*a(-1) + e_a;
has = rho_has*has(-1) + e_has;
end;

steady;                 
check;

shocks;
var e_R; stderr 0.29;
var e_j; stderr 24.89;
var e_u; stderr 0.17;
var e_a; stderr 2.24;
var e_has; stderr 1.0;
var e_g; stderr 0.1;
end;

stoch_simul(irf=24);

varobs G y pi q i;

estimated_params;
J, beta_pdf, 0.2, 0.05;
m, beta_pdf, 0.6, 0.05;
mii, beta_pdf, 0.6, 0.05;
alph, beta_pdf, 0.7, 0.05;
phiE, inv_gamma_pdf, 1, 0.5;
phiH, inv_gamma_pdf, 1, 0.5;
thet, beta_pdf, 0.67, 0.47;
rho_Y, normal_pdf, 6.74, 6.38;
rho_pi, normal_pdf, 0.04, 0.02;
rho_R, beta_pdf, 0.75, 0.1;
end;

estimation(datafile=datause,nobs=64) G y pi q i;


figure(5)
suptitle({'Full Iacoviello Model Responses',' '})

subplot(4,4,1)
plot(r_e_R,'b')
title('Response of R','FontSize',10)
ylabel('Shock to R','FontSize',10)

subplot(4,4,2)
plot(pi_e_R,'b')
title('Response of \pi','FontSize',10)

subplot(4,4,3)
plot(q_e_R,'b')
title('Response of q','FontSize',10)

subplot(4,4,4)
plot(y_e_R)
title('Response of Y','FontSize',10)

subplot(4,4,5)
plot(r_e_u,'b')
ylabel('Shock to \pi','FontSize', 10)

subplot(4,4,6)
plot(pi_e_u,'b')

subplot(4,4,7)
plot(q_e_u,'b')

subplot(4,4,8)
plot(y_e_u,'b')

subplot(4,4,9)
plot(r_e_j,'b')
ylabel('Shock to q','FontSize',10)

subplot(4,4,10)
plot(pi_e_j,'b')

subplot(4,4,11)
plot(q_e_j,'b')

subplot(4,4,12)
plot(y_e_j,'b')

subplot(4,4,13)
plot(r_e_a,'b')
ylabel('Shock to Y','FontSize',10)

subplot(4,4,14)
plot(pi_e_a,'b')

subplot(4,4,15)
plot(q_e_a,'b')

subplot(4,4,16)
plot(y_e_a,'b')

关键词:DSGE observations distribution Constraints calibration 文章 程序
已有 1 人评分经验 收起 理由
Captain-CUI + 60 鼓励积极发帖讨论

总评分: 经验 + 60   查看全部评分

沙发
guanzihuan 学生认证  发表于 2016-8-29 12:59:36 |只看作者 |坛友微信交流群
再往上看了一下报错结果,发现
There are 10 eigenvalue(s) larger than 1 in modulus for 10 forward-looking variable(s)
是不是因为特征根有10个,太多了,所以导致BK条件没法满足呢?
如果是的话,要怎么处理呢?

使用道具

藤椅
guanzihuan 学生认证  发表于 2016-8-29 13:14:46 |只看作者 |坛友微信交流群
There are 10 eigenvalue(s) larger than 1 in modulus for 10 forward-looking variable(s)
The rank condition is verified.  但是秩条件满足。。

使用道具

板凳
guanzihuan 学生认证  发表于 2016-9-3 16:21:43 |只看作者 |坛友微信交流群
个人已经解决了!模型缺个括号,加上去,同时调整了一下参数
就跑出来了!!
其实想问的是。。悬赏的东西自己解决了咋办呢。。。

使用道具

报纸
guanzihuan 学生认证  发表于 2016-9-3 16:31:38 |只看作者 |坛友微信交流群
这里的BK条件不满足  应该就是参数的问题跟模型少了个括号的问题
后面estimation的时候有时会出现海赛矩阵不为正的报错,感觉这个报错应该会导致估计结果不可信
后来修改参数就解决了

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加JingGuanBbs
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 05:53