Real business cycle in emerging countries

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
data and code.zip (26.8 KB)

Could you please explain what you changed?

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.
data_argentina.xls (47 KB)
GarciaCiccoetal2010.mod (11.5 KB)

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

compared to yours

(2).My Trade balance

Compared to yours

(3).My steady_state_model

dbar=ybar*d_share; d=dbar; c =(gbar/r-1)*d +y-s-invest; d=exp(d);

Compared to yours

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

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:

r = RSTAR + PSSI * (exp(d-DBAR) - 1) + exp(mu-1)-1;

[quote=“ZBCPA”]

Please find attached code written by Johannes Pfeifer.[/quote]

Thank you, ZBCPA.

[quote=“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:

r = RSTAR + PSSI * (exp(d-DBAR) - 1) + exp(mu-1)-1; [/quote]

Dear Johhanes,

I find in your code it writes resource constraint asy= log(tb) + c + s + invest + phi/2 * (k(+1)/k*g -gbar)^2;
however, according to the original paper appendix, it should be 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
appendix.pdf (99.1 KB)

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

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.

1 Like

[quote=“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

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.[/quote]

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

[quote=“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

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.[/quote]

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=(dtXt-1 - dt+1Xt)/rt (here rt is gross rate)

However, the TB data Generally does NOT appear Trend, so how can the equation above be altered to

tb=d-d(+1)*g/r Do you mean TBt/Xt-1=tbt ?

  1. Since TB in data has negative numbers, to make the steady state all positive (because of loglinear command), you define

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 becomelog(log(tb_y)=log(log(tb))-logy
which is ACTUALLY(here tb_y and tb have no exp any more) log(tb_y)=logtb-logy ?

Best regards,
Huan

See my answer at ["logdata" must be used after "loglinear")

Hi Prof. Pfeifer,

Sorry to open the discussion. I am estimating a similar model with an additional shock.

  1. The author wrote in page 10 “Measurement errors are permitted to absorb no more than 6 percent of the variance of the corresponding observable time series”.
    My question is how to implement this restriction in Dynare?

  2. My estimation result shows that the contribution to variance decomposition of measurement error associated with trade-balance-to-output ratio is pretty high (37%). What could be the potential sources of such high contribution and how can I address this? Please note that when I set the parameter representing the debt sensitivity of interest rate (psi) to a low value of 0.001, the contribution is trivial. However, either calibrating psi with a relatively high value (0.0355) or estimating it makes the contributions of measurement error and preference shocks to variance decomposition very high.
    I could not figure it out. Is there any intuition behind the connection between this parameter and preference shock?

  3. From the dataset for Argentina, I computed the 25% of standard deviations of observables as follows:
    g_y = 0.013; g_x = 0.051; g_c = 0.019; tb_y = 0.013;
    In your code, you set the upper bound of the measurement errors for observables as below:
    g_y sqrt(0.13);
    g_c sqrt(0.19);
    g_x sqrt(0.51);
    tb_y sqrt(0.13);

I am certain that there is a good reason for doing this. Could you please give me a brief explanation? Does this way of setting upper bound ensure that the measurement errors will contribute upto a certain percentage?

Thanks and regards
Saidul

  1. You can do this by setting an upper bound, e.g. for the uniform distribution. Of course, you first need to compute the cutoff value based on the data’s variance.
  2. Have a look at
  1. Have a look at the Notes in the file:

The standard deviations of the estimated measurement error reported in Table 3 of the paper are actually variances. This mod-file reflects this difference to the published version by taking the square root.

Thank you a lot, Prof. Pfeifer.

  1. Here’s how I compute the cutoff value:
    The standard deviation of tby is 0.0154 and it’s 25% is 0.0038 and I set this value as upper bound. Is it the correct way of computing cutoff value? The Garcia-Cicco et al. also set 25% of the standard deviations of the observables as the upper bound. I use the following syntax:

stderr eps_tby_ME, , , ,uniform_pdf, , , 0.0001, 0.0038;

Is the syntax correct for setting upper bound?
After running with this setup, I encountered the following error:
Initial value(s) of SE_eps_tby_ME are outside parameter bounds.

What I understood from the Dynare manual is that if initial value is not set then the prior mean (0.00195) will be set as default. So, why is the error message? Is this because of the standard deviation (sqrt(0.0038-0.0001)^2/12)?

  1. Probably, my problem is not measurement error hitting upper bound. It’s about the contribution of measurement error (eps_tby_ME) in posterior (mean) variance decomposition. Please have a look.
    Posterior mean variance decomposition (in percent)
           eps_al      eps_vl      eps_ga      eps_gv      eps_xi   eps_tby_ME
g_y         28.60       3.32       43.71        8.93       15.45        0.00
g_c         12.18       0.06       46.77        2.41       38.58        0.00
g_x         22.99       16.36      20.99       12.69       26.97        0.00
tby          3.91        0.53      27.45       13.88        7.85       **36.37**

This high contribution (36.37%) results from setting debt-elastic interest rate parameter (psi) to 0.0355, which, in turn, is to induce theoretical standard deviation of trade-balance-to-output ratio to its empirical value (0.0154). But for a lower value (0.001) of psi, the contribution is pretty low (less than 5%).

  1. Previously, I saw this note and had confusion. That’s why I raised this issue.

Thanks again
Saidul

  1. Yes, that is correct. You must be setting the initial value somewhere else to get that message.
  2. Again, that is a sign of misspecification. The model tries to explain the trade balance mostly with the measurement error.
  3. The not simply means that the original code does not do what the paper claimed to be doing. They should have used the variance, but did not do so. Thus the square root.
  1. I assumed that both the way of computing cutoff value and syntax are correct. Did you mean that I have already set initial value somewhere which resulted in the error message or I should set the value in its respective field to tackle the error?

  2. Things got complicated. What could be the potential sources of misspecification and how can this issue be usually resolved? Is this something related to the observation equation for tby as attached?
    Trade balance to output ratio.pdf (305.7 KB)

  3. I understood.

  1. Without the codes it is impossible to tell.
  2. Yes, that is the hard part. Understanding what causes this requires a lot of trial and error which model features could potentially account for this. What you could try is check the smoothed series for the trade balance without the measurement error (Dynare should produce that) and check if there is something immediately suspicious.

Thank you so much for quick reply with precious advice.

  1. Here’s the mod file
    SOE_RBC_linear_est.mod (9.3 KB)
    and the data file
    data_Bangladesh.xlsx (137.0 KB)

  2. Estimated model without measurement error to trade balance but with a error to output growth. Here’s the smoothed variable plot.


    Nothing seems suspicious to me.

  1. Your code contains
estimated_params_init(use_calibration); //Use their posterior as starting values for estimation; for measurement error, only the 
    stderr eps_tby_ME, sqrt(0.0175018482467928);

which is outside of the specified bounds.

  1. No, I meant: estimate the model with the measurement error, but inspect the actual trade balance without the measurement error to see what the measurement error does.