I am trying to calibrate IDEIR by using your SGU 2003 codes. As you do included only EDEIR. so, I am adding one line of equation to your codes give below but when I use a very small value of debt friction (psi_2 ) I don’t the error given below. However , in this case, I don’t get the second moments similar to others as it should be. It seems problem is in Equation number 10. I tried by removing exp() or log on interest rate but it did not work.
riskpremium = psi_2*(exp(d-d_bar)-1)+ (exp(d-d_bar))dpsi_2;
I am getting the error below
Residuals of the static equations:

Equation number 1 : 0 : Eq. (4), Evolution of debt
Equation number 2 : 0 : Eq. (5), Production function
Equation number 3 : 0 : Eq. (6), Law of motion for capital
Equation number 4 : 0 : Eq. (24), Euler equation
Equation number 5 : 0 : Eq. (25), Definition marginal utility
Equation number 6 : 0 : Eq. (26), Labor FOC
Equation number 7 : 0 : Eq. (27), Investment FOC
Equation number 8 : 0 : Eq. (14), Law of motion for TFP
Equation number 9 : 0 : Eq. (23), country interest rate
Equation number 10 : -5.522e-05
Equation number 11 : 0 : p. 169, Definition of trade balance to ouput ratio
Equation number 12 : 0
Equation number 13 : 0 : Definition felicity function

Error using print_info (line 76)
The steadystate file did not compute the steady state

Error in check (line 76)
print_info(info, 0, options);

Error in SSEON3RD (line 215)
oo_.dr.eigval = check(M_,options_,oo_);

Thanks for replying. The only value I can change is psi_2. If I am understood correctly what you said? In SS d = d_bar so riskpremium= 0, . Is there any change in steady_state_model eq.?Would you please explain a bit? Seoane(2015) [Near Unit Root Small Open Economies ∗
published in Journal of Economic Dynamics and Control , 2015, vol. 53, issue C, 37-46] has used psi_2 = 0.00025 for 3rd order. As you mentioned already “Note that I tried the SGU 2003 model with third-order perturbation. It turns out that the approximation order hardly matters, because the original model is quite close to linear” Now when I used psi_2 = 0.00025 I get the following error

Residuals of the static equations:

Equation number 1 : 0 : Eq. (4), Evolution of debt
Equation number 2 : 0 : Eq. (5), Production function
Equation number 3 : 0 : Eq. (6), Law of motion for capital
Equation number 4 : 0 : Eq. (24), Euler equation
Equation number 5 : 0 : Eq. (25), Definition marginal utility
Equation number 6 : 0 : Eq. (26), Labor FOC
Equation number 7 : 0 : Eq. (27), Investment FOC
Equation number 8 : 0 : Eq. (14), Law of motion for TFP
Equation number 9 : 0 : Eq. (23), country interest rate
Equation number 10 : -0.0005522
Equation number 11 : 0 : p. 169, Definition of trade balance to ouput ratio
Equation number 12 : 0
Equation number 13 : 0 : Definition felicity function

Error using print_info (line 76)
The steadystate file did not compute the steady state

Error in check (line 76)
print_info(info, 0, options);

Error in SOE2 (line 213)
oo_.dr.eigval = check(M_,options_,oo_);

I have now tested the codes of Ambrogio Cesa-Bianchi given at his web page https://sites.google.com/site/ambropo/dynarecodes.
I just added one line of equation i.e. riskpremium = psi*(exp(d-d_bar)-1)+ (exp(d-d_bar))dpsi for psi= 0.00035. so I get the exactly the same second moments as that of EDEIR. Though, I can see some slight difference between formulation of your codes for SGU 2003 and his codes. However, I am getting error in your codes. I could not fix that error so far given above.

Thank you so much. Yes, I did check, but, I get error message as “The steadystate file did not compute the steady state” I have used psi_2 = 0.00035 for SGU_2003. Changing your codes to IDEIR ,shall not make any change in steady state model equation. But still I will cross check. As I mentioned above, for Ambrogio Cesa-Bianchi codes, I get the same seconds moments as for EDEIR. when added risk premium for IDEIR case.The detail of error is given below:

Residuals of the static equations:

Equation number 1 : 0 : Eq. (4), Evolution of debt
Equation number 2 : 0 : Eq. (5), Production function
Equation number 3 : 0 : Eq. (6), Law of motion for capital
Equation number 4 : 0 : Eq. (24), Euler equation
Equation number 5 : 0 : Eq. (25), Definition marginal utility
Equation number 6 : 0 : Eq. (26), Labor FOC
Equation number 7 : 0 : Eq. (27), Investment FOC
Equation number 8 : 0 : Eq. (14), Law of motion for TFP
Equation number 9 : 0 : Eq. (23), country interest rate
Equation number 10 : -0.0005522 : p. 171 below Eq. (28), definition risk premia
Equation number 11 : 0 : p. 169, Definition of trade balance to ouput ratio
Equation number 12 : 0
Equation number 13 : 0 : Definition felicity function

Error using print_info (line 76)
The steadystate file did not compute the steady state

Error in check (line 76)
print_info(info, 0, options);

Error in SOE2 (line 214)
oo_.dr.eigval = check(M_,options_,oo_);

Thanks a lot. But I,m talking about psi_2 for extending it to IDEIR. You are right that in previous notes that by adding rikspremium in IDEIR form, the steady state equation of the model will change too. so d = d_bar (in the case of EDEIR) will not hold for IDEIR. Therefore, for IDEIR, . Is the SS now be d_bar = Log (1+d)+d, Am I right? But I can’t log for d as it can be negative. Please guide me on this.

I think you need to explicitly describe in detail what you are doing and what the issue is that you are encountering. Of course you cannot take the logarithm of a negative number. But that would imply b<-1 in which case your debt elastic interest rate does not make sense anymore.

Thanks for asking further detail. For the debt elastic interest rate premium, there are two version (1) External Debt Elastic Interest Rate Model(EDEIR), You have calibrated this in your codes , SGU_2003.mod. (2) Internal Debt Elastic Interest Rate Model (IDEIR) Which you have not included in your codes SGU_2003.mod.

Now, I am using your SGU_2003 codes to include (IDEIR). so I add riskpremium = psi_2*(exp(d-d_bar)-1)+ (exp(d-d_bar))dpsi_2. to your codes. But, d = d_bar is no longer hold for IDEIR. If we solve Euler equation of IDEIR in the SS, we get, (1+d) exp^(d- d_bar). Once, we solve this we get d_bar = Log (1+d)+d.

My Question: How to put steady level of debt for IDEIR as described above and in also previous note into steady_state_model in your codes.

That depends on your strategy. If you can solve for d, then simply set d_bar to be consistent with this level. If you want a particular debt level d_bar, compute the parameters required to achieve this level.

Thanks a lot, All is your codes for SGU_2003.mod. I am adding only riskpremium = psi_2*(exp(d-d_bar)-1)+ (exp(d-d_bar))dpsi_2; [Please check line 371 in mode file] to make it for Internal debt elastic model. But, d = d_bar (as in your codes ) is no longer hold for IDEIR. If we solve Euler equation of IDEIR in the SS, we get, (1+d) exp^(d- d_bar). Once, we solve this we get d_bar = Log (1+d)+d. This is problem, I could not solve.

In your codes SGU 2003, for Endogenous discount factor and Endogenous discount factor without internalization, psi_1 is adjusted by the model. I am trying to locate in dynare output for the value psi_1. How to find the value of psi_1 as adjusted by the model? How do I know what value of psi_1 is given by the model.?