Model diagnostics and steady-state and convergence testing

Dear Professor
Hello! Sorry to bother you, I have some problems when doing the DSGE model here, I hope you can help answer them. When I didn’t add the parameter prior distribution and observed variables to the code for parameter estimation, the code worked fine, and the residual test and model diagnostic test were as follows, showing that there was no problem.
Residuals of the static equations:

Equation number 1 : 0 : 1

Equation number 2 : 0 : 2

Equation number 3 : 0 : 3

Equation number 4 : 0 : 4

Equation number 5 : 0 : 5

Equation number 6 : 0 : 6

Equation number 7 : 0 : 7

Equation number 8 : 0 : 8

Equation number 9 : -2.4009e-06 : 9

Equation number 10 : 2.4009e-06 : 10

Equation number 11 : 0 : Z

Equation number 12 : 0 : etau

Equation number 13 : 0 : etah

Equation number 14 : 0 : X

Equation number 15 : 0 : G

>> model_diagnostics(M_,options_,oo_)

MODEL_DIAGNOSTICS: No obvious problems with this mod-file were detected.

However, when I add the prior distribution of parameters and observed variables to the code for parameter estimation, the residual terms of many equations in the model are not 0, and the model diagnostic test shows that the steady state cannot be computed. At the same time, the convergence test graph is also very strange, and the results look terrible, I would like to ask what is the cause of this problem, and please ask the professor to guide me to solve the problem of my model. (The data and code have been uploaded, the equilibrium equation in the code is in exp form, and the observations in the data are the logarithms of output, consumption, and employment.) )

!!!WARNING!!!
    The rank of J (Jacobian of first two moments) is deficient!

    SE_epsX is collinear w.r.t. all other parameters!
    SE_epsZ is collinear w.r.t. all other parameters!
    SE_epsetau is collinear w.r.t. all other parameters!
    SE_epsG is collinear w.r.t. all other parameters!
    rhoX is collinear w.r.t. all other parameters!
    rhoZ is collinear w.r.t. all other parameters!
    rhoetau is collinear w.r.t. all other parameters!
    rhoG is collinear w.r.t. all other parameters!


Estimation::mcmc: Number of mh files: 1 per block.
Estimation::mcmc: Total number of generated files: 7.
Estimation::mcmc: Total number of iterations: 100000.
Estimation::mcmc: Current acceptance ratio per chain: 
                                                       Chain  1: 11.32%
                                                       Chain  2: 11.629%
                                                       Chain  3: 9.001%
                                                       Chain  4: 13.006%
                                                       Chain  5: 9.709%
                                                       Chain  6: 16.259%
                                                       Chain  7: 10.665%
Estimation::mcmc: Total number of MH draws per chain: 100000.
Estimation::mcmc: Total number of generated MH files: 1.
Estimation::mcmc: I'll use mh-files 1 to 1.
Estimation::mcmc: In MH-file number 1 I'll start at line 50001.
Estimation::mcmc: Finally I keep 50000 draws per chain.

>> model_diagnostics(M_,options_,oo_)

DYNARE_SOLVE (solve_algo=2|4|12): number of blocks = 6
DYNARE_SOLVE (solve_algo=2|4|12): solving block 6 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 6 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 5 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 5 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 4 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 4 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 3 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 3 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 2 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 2 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 1 of size 10.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 1 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): number of blocks = 6
DYNARE_SOLVE (solve_algo=2|4|12): solving block 6 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 6 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 5 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 5 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 4 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 4 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 3 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 3 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 2 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 2 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 1 of size 10.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 1 with trust_region routine.
MODEL_DIAGNOSTICS: The steady state cannot be computed
>> resid

Residuals of the static equations:

Equation number 1 : -3084.9423 : 1
Equation number 2 : 0.16051 : 2
Equation number 3 : -0.13112 : 3
Equation number 4 : 0.012922 : 4
Equation number 5 : 0 : 5
Equation number 6 : 0.23825 : 6
Equation number 7 : -0.25386 : 7
Equation number 8 : -0.30341 : 8
Equation number 9 : 0 : 9
Equation number 10 : 0 : 10
Equation number 11 : 0 : Z
Equation number 12 : 0 : etau
Equation number 13 : 0 : etah
Equation number 14 : 0 : X
Equation number 15 : 0 : G

I would appreciate it Professor could help me! Thank you very much!
datalne.mat (2.1 KB)
MODLECODE.MOD (3.9 KB)
Convergence test results.pdf (511.2 KB)

Dear Professor Pfeifer, if you have time, please look at some of my problems, which have been bothering me for a long time. I would be most grateful if you could give me some help.

  1. Your data still has a trend.
  2. You are not correctly handling parameter dependence.
  3. You should use an analytical steady state file for estimation.
  4. It seems that one of your exogenous processes is redundant, causing the identification issue.

For the first few issues, see Pfeifer(2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models”

Thank you very much for Professor Pfeifer’s reply. I have read your reference materials, but I’m really sorry that as a beginner, I don’t quite understand. Do you mean that my steady-state value is not calculated correctly? As for your third point, what do you mean by analytical steady state file? The fourth point you mentioned is that one of my exogenous shocks is superfluous. Can you point out which one is superfluous? I would like to apologize to Professor Pfeifer again. My question may be a little silly, but I can’t ask my friends or tutors for help. I can only ask Professor Pfeifer to reply again. If you have time, please take another look at my problem, I will certainly be grateful for your guidance and help!

  1. See
  1. You get a collinearity warning. That suggests that the data are only informative about three out of the four processes mentioned in
    SE_epsX is collinear w.r.t. all other parameters!
    SE_epsZ is collinear w.r.t. all other parameters!
    SE_epsetau is collinear w.r.t. all other parameters!
    SE_epsG is collinear w.r.t. all other parameters!

There is not a particular one that’s problematic.

Professor Pfeifer, thank you for your advice. However, I am very sorry that I followed your instructions in “DSGE_mod/RBC_baseline_first_diff_bayesian.mod at master · JohannesPfeifer/DSGE_mod · GitHub”. Placing the Settings in steady_state_model, I ran the code and got an error message“ERROR: MODLE111.mod: line 81, cols 1-6: h is not a parameter”.h is the labor variable.But your code also sets labor in this way. I don’t know where my problem is, could you please help me to answer it again
MODLE111.MOD (2.2 KB)

There is a typo in steady_state_model. You wrote stedy_state_model.

Dear Professor
Hello! Sorry to bother you again, I have modified the code according to your suggestion, and now the model can produce normal results, but the results of the model are not ideal, the relevant test results have been uploaded, may I ask what further improvements I should make? Please ask the professor to guide me to solve the problems in my model. (The data and code have been uploaded, the equilibrium equation in the code is in the original horizontal form, and the observed data in the data are the values of China’s output, consumption, investment and employment from 1978 to 2020, and the HP filtering process is done to take the fluctuation components). My ultimate goal is to obtain the depreciation rate variable value over the years and further do the capital stock accounting.
I would appreciate it if the professor could help with that! Thank you!

convergence diagnostic test.pdf (666.0 KB)
dataln.mat (2.1 KB)
MODLENEW.MOD (3.9 KB)

  1. You are not supposed to use a two-sided HP-filter for estimation. It’s a non-causal filter violating the recursiveness of the model solution.
  2. You are trying to match mean zero observables in the data to non-demeaned variables in the model. That cannot work.
1 Like

Thank you very much for Professor Pfeifer’s reply. Then can I take the logarithm of the original data and then make the difference, so that the mean value of the processed data is closer to the steady-state value in the model? Or should I log-linearize the equilibrium equations in the code and then use the data from the one-sided for estimation?I sincerely hope that professor can help me solve my doubts again. I would be very grateful for that.

As documented in Pfeifer(2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models” you use the one-sided HP filter and define the observable as

y_obs=log(y)-log(STEADY_STATE(y));

Thanks again for Professor Pfeifer’s patient answer. Following your advice, I took logarithms of the data and did one sided HP filter, and added the observation equation into the model code. The result of this version was much better. But I’m sorry that I may need to bother Professor Pfeifer again, because there are still some small problems in the model convergence diagnostic test, and there are still red dots in the mode check. Now, is this problem caused by the incorrect setting of my parameter prior values and prior distributions, or is it caused by other reasons? I sincerely thank Professor Pfeifer again for taking the time to answer questions and I hope you can look at my question again. Thank you very much.
1convergence diagnostic test.pdf (1015.7 KB)
DATALNHP1.mat (2.1 KB)
MODLENEW.MOD (4.2 KB)

The only really problematic issues is the mode for b being at the prior bound you specified.

Thanks again for Professor Pfeifer’s guidance, I have modified it according to your instructions, and I have uploaded the relevant mode check test and convergence diagnosis test results. If you have time, could you please help me check again? I am very sorry for bothering you for so long, this is my last question, I hope you can help me check again when you have time. Thank you very much Professor Pfeifer.
DATALNHP1.mat (2.1 KB)
MODLENEW.MOD (4.2 KB)
TEST1112.pdf (679.5 KB)

You should ideally conduct formal convergence tests. But what you posted looks good.

Sorry to bother Professor Pfeifer again, but I have one more small question. I am using the data to simulate economic parameter estimation, but the smoothed variable value is equal to the observed variable value in the end. I have compared the corresponding mean and standard deviation of each of them. This means that there are still problems with the model.How to compare the fitting effect between simulated economy and real economy?
The second question is that my mode check test results show a red dot. I run model_diagnostics(M_,options_,oo_) and show that the model does not have a problem. Can I ignore this red dot?
MODLESHEBEI.MOD (4.2 KB)
shebeishuju.mat (1.6 KB)
18d4d8fc878d7b0791c9ec2fa8900ad
MODE CHECK.pdf (669.3 KB)
I hope Professor can help me to answer my confusion again, thank you very much.

  1. I am not sure I understand the problem. By construction, the smoothed variables correspond to the data for observables. That is expected. Theoretical moments vs moments based on smoothed series may be relevant.
  2. You can usually ignore such dots at the border of the parameter space.