Page 1 of 1

Real business cycle in emerging countries

PostPosted: Wed Sep 23, 2015 3:57 am
by ZBCPA
Dear Johhanes,

Based on your dynare code of "Real business cycle in emerging countries", I change a little of the domestic interest rate function. Then I match the new code with another country's data. Using dynare 2015-08-16 edition,I think the estimation results look fine, except the following issues after mode finding:

Warning: Matrix is singular to working precision.
> In lyapunov_symm (line 151)
In dsge_likelihood (line 379)
In mode_check (line 143)
In dynare_estimation_1 (line 365)
In dynare_estimation (line 92)
In au (line 303)
In dynare (line 223)
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND
= NaN.
> In kalman_filter (line 182)
In dsge_likelihood (line 651)
In mode_check (line 143)
In dynare_estimation_1 (line 365)
In dynare_estimation (line 92)
In au (line 303)
In dynare (line 223)

Could help give me some advise to solve this problem?
Please find attached data and code files if you need.

Best regards,
Huan

Re: Real business cycle in emerging countries

PostPosted: Wed Sep 23, 2015 8:13 pm
by jpfeifer
Could you please explain what you changed?

Re: Real business cycle in emerging countries

PostPosted: Thu Sep 24, 2015 8:17 am
by sfking
Dear jpfeifer, I am from China, and could not access to your website, will you post your uribe2010AER code here? Thank you.

Re: Real business cycle in emerging countries

PostPosted: Sat Sep 26, 2015 5:04 am
by ZBCPA
sfking wrote:Dear jpfeifer, I am from China, and could not access to your website, will you post your uribe2010AER code here? Thank you.


Please find attached code written by Johannes Pfeifer.

Re: Real business cycle in emerging countries

PostPosted: Sat Sep 26, 2015 9:54 am
by ZBCPA
jpfeifer wrote:Could you please explain what you changed?


Dear Johhanes,

I will try my best to explain it and hope will not make you feel confused due to my poor English.What I change to your original code is mainly the interest rate equation(financial friction model) and debt.

1. The orignal paper define interest rate in model : rt=rstar+psi*(exp(Dt+1/Xt-dbar)-1)+exp(mu-1)-1 , and Dt+1/Xt should be equal to dt+1,however the authers make Dt+1/Xt=dt in stead of dt+1 in their appendix. I guess this might be a typo,since Uribe and Schmitt-Grohe write a textbook "Open economy macroeconomics" which has not been published yet and in this text book Chapter 5, they correct the interest rate equation to make Dt+1/Xt=dt+1.

2. I do not know why they calibrate d=0.007. According to the original AER paper, it writes "We set the parameter dbar to induce a small steady-state trade balance to output ratio of about 0.25%, as observed on average in Argentina over the period 1900-2005" . I think the value of dbar is calculated from budget constraint at steady state.Howeve,budget constrain has tbbar and dbar at steady state, if both sides divided by ybar, we can get dbar/ybar is a function of tbbar/ybar,which might match the data TB/Y, here "bar"mean steady state value). So I put ybar in the interest rate equation .
At same time , I suppose tbbar/ybar(steady state of detrended TB/ steady state of detrended Y) equal to average TB/Y data value. Is this right? Otherwise we won't know the value of tbbar/ybar. In their textbook chapter 5 section 4 ,they use rt=rstar+psi*(exp((Dt+1/Xt-dbar)/ybar)-1) . And it seems that they also calibrate tbbar/ybar=average TB/Y data value.Since in my own data,trade blance to output raito on average is negative, then dbar/ybar (denote it to be d_share)would be negative, so I calibrate it to be d_share=-0.66(calculated from budget constraint)

So I write my code like the following(related to dbar part):
(1). My Interest Rate
Code: Select all
r = RSTAR + psi*(exp((log(d(+1))/ybar)-(dbar/ybar)) - 1)+exp(mu-1)-1;


compared to yours
Code: Select all
r = RSTAR + psi*(exp(d-dbar) - 1)+exp(mu-1)-1;


(2).My Trade balance
Code: Select all
log(tb)= log(d) - log(d(+1))*g/r;


Compared to yours
Code: Select all
log(tb)= d - d(+1)*g/r;


(3).My steady_state_model
Code: Select all
dbar=ybar*d_share;
d=dbar;
c =(gbar/r-1)*d +y-s-invest;
d=exp(d);


Compared to yours
Code: Select all
d = dbar;
c =(gbar/r-1)*d +y-s-invest;


Do you think there is some problem if I change the code like the above?

Best regards,
Huan

Re: Real business cycle in emerging countries

PostPosted: Mon Sep 28, 2015 9:11 pm
by jpfeifer
You can adjust your model however you deem sensible. I can only tell you that for your first point, the replication code at the AER clearly shows they used the timing with d_t:
Code: Select all
r = RSTAR + PSSI * (exp(d-DBAR) - 1) + exp(mu-1)-1;

Re: Real business cycle in emerging countries

PostPosted: Thu Oct 01, 2015 9:12 am
by sfking
ZBCPA wrote:
sfking wrote:Dear jpfeifer, I am from China, and could not access to your website, will you post your uribe2010AER code here? Thank you.


Please find attached code written by Johannes Pfeifer.


Thank you, ZBCPA.

Re: Real business cycle in emerging countries

PostPosted: Sat Oct 03, 2015 7:45 am
by ZBCPA
jpfeifer wrote:You can adjust your model however you deem sensible. I can only tell you that for your first point, the replication code at the AER clearly shows they used the timing with d_t:
Code: Select all
r = RSTAR + PSSI * (exp(d-DBAR) - 1) + exp(mu-1)-1;



Dear Johhanes,

I find in your code it writes resource constraint as
Code: Select all
y= log(tb) + c + s + invest + phi/2 * (k(+1)/k*g -gbar)^2;

however, according to the original paper appendix, it should be
Code: Select all
y= log(tb) + c + s + invest + phi/2 * (k(+1)/k*g -gbar)^2*k;
.

Is it a typo of your code?

Please find attached appendix to Real business cycle in emerging countries.

Best regards,
Huan

Re: Real business cycle in emerging countries

PostPosted: Sat Oct 03, 2015 3:20 pm
by jpfeifer
Dear Huan, the answer is yes and no. My code currently follows the replication codes at the AER one to one. And there, the trade balance is defined as
Code: Select all
tb = yy - c - s - ivv - PHI/2 * (kp/k*g -G)^2;

But you are correct in that there is a k missing in that equation. However, this is inconsequential as this term is 0 up to first order.
I will add a disclaimer to my code.

Re: Real business cycle in emerging countries

PostPosted: Sun Oct 04, 2015 9:39 am
by ZBCPA
jpfeifer wrote:Dear Huan, the answer is yes and no. My code currently follows the replication codes at the AER one to one. And there, the trade balance is defined as
Code: Select all
tb = yy - c - s - ivv - PHI/2 * (kp/k*g -G)^2;

But you are correct in that there is a k missing in that equation. However, this is inconsequential as this term is 0 up to first order.
I will add a disclaimer to my code.


Many thanks, Johannes. Your disclaimers in code are all very helpful.

Re: Real business cycle in emerging countries

PostPosted: Wed Oct 07, 2015 3:57 am
by ZBCPA
jpfeifer wrote:Dear Huan, the answer is yes and no. My code currently follows the replication codes at the AER one to one. And there, the trade balance is defined as
Code: Select all
tb = yy - c - s - ivv - PHI/2 * (kp/k*g -G)^2;

But you are correct in that there is a k missing in that equation. However, this is inconsequential as this term is 0 up to first order.
I will add a disclaimer to my code.



Dear Johhanes,

Could I ask two more questions about trade-balance in your code?

1. Actually, the definition of trade-balance BEFORE detrending is
TBt=Dt-Dt+1*/rt=(dt*Xt-1 - dt+1*Xt)/rt (here rt is gross rate)

However, the TB data Generally does NOT appear Trend, so how can the equation above be altered to
Code: Select all
tb=d-d(+1)*g/r
Do you mean TBt/Xt-1=tbt ?


2. Since TB in data has negative numbers, to make the steady state all positive (because of loglinear command), you define
Code: Select all
tb=exp(tb);
tb_y=exp(tb_y);


I am just wondering how to write the original measurement equation of the observable TBt/Yt(Since I am loglinearing the whole model using pencil and paper instead of loglinear command to do it again).

By the way, the definition trade-balance to output ratio
log(tb_y)=log(tb)/y;
After the "loglinear" command, does it become
Code: Select all
log(log(tb_y)=log(log(tb))-logy

which is ACTUALLY(here tb_y and tb have no exp any more)
Code: Select all
log(tb_y)=logtb-logy
?


Best regards,
Huan

Re: Real business cycle in emerging countries

PostPosted: Sat Oct 10, 2015 7:31 am
by jpfeifer