ERROR: Division by zero

Dear all,
I received the following error message when solving a steady state.
I can not find which term is zero.

Can anybody help me with this problem?
Thank you in advance.
The code can be found in the attachment.
mix.mod (14.6 KB)

You have

PZR=0;
XR=YRT2*(1-KAPPA)*(S_R/PZR)^RO;

This is clearly a division by 0.

Thank you for your help.

Hello,
The following error message occurred when I was solving the steady state.
The residuals of some equations are not 0.
This error message only appears when I join the foreign trade conditions of the open economy, which are lines 515-539 in mix.mod.
The code can be found in the attachment.
Does anyone have similar problems or know how to solve them?
Thanks.

Residuals of the static equations:

Equation number 1 : 0 : LAMBDA1
Equation number 2 : 0 : 2
Equation number 3 : 0.0020555 : W
Equation number 4 : 0 : 4
Equation number 5 : 0 : 5
Equation number 6 : -0.67653 : Y
Equation number 7 : 0.33685 : LR
Equation number 8 : 8.9029 : KR
Equation number 9 : 1.5756 : WR
Equation number 10 : 0 : 10
Equation number 11 : -0.0094038 : KP
Equation number 12 : 0.052059 : 12
Equation number 13 : 0.16382 : YP
Equation number 14 : 0 : YR
Equation number 15 : 0 : WP
Equation number 16 : 0 : 16
Equation number 17 : -0.021705 : RK
Equation number 18 : 0.01911 : P_STAR
Equation number 19 : 0.46594 : S1
Equation number 20 : 0.5864 : S2
Equation number 21 : 0 : PR_STAR
Equation number 22 : 0 : S3
Equation number 23 : 0 : S4
Equation number 24 : 0 : 24
Equation number 25 : 0 : DPR
Equation number 26 : 0 : 26
Equation number 27 : 0 : DP
Equation number 28 : 0 : MCP
Equation number 29 : 0 : MCR
Equation number 30 : 0.077085 : PSIP
Equation number 31 : 0 : Z
Equation number 32 : 0 : M
Equation number 33 : 0 : T
Equation number 34 : 0 : 34
Equation number 35 : 0 : 35
Equation number 36 : 0 : 36
Equation number 37 : 0 : 37
Equation number 38 : 0 : 38
Equation number 39 : 1 : real_r
Equation number 40 : 0 : WELF
Equation number 41 : 0 : CA
Equation number 42 : 0 : CARBON_TAX
Equation number 43 : 0 : PZP
Equation number 44 : 0 : PZR
Equation number 45 : 0.94982 : KG
Equation number 46 : 0 : LAMBDA12
Equation number 47 : 0 : 47
Equation number 48 : 0.0020555 : W2
Equation number 49 : 0 : 49
Equation number 50 : 0 : 50
Equation number 51 : 6.9376 : Y2
Equation number 52 : 0.33685 : LR2
Equation number 53 : 8.9029 : KR2
Equation number 54 : 1.5756 : WR2
Equation number 55 : 0 : 55
Equation number 56 : -0.0094038 : KP2
Equation number 57 : 0.052059 : 57
Equation number 58 : 0.16382 : YP2
Equation number 59 : 0 : YR2
Equation number 60 : 0 : WP2
Equation number 61 : 0 : 61
Equation number 62 : -0.021705 : RK2
Equation number 63 : 0.01911 : P_STAR2
Equation number 64 : 0.46594 : S12
Equation number 65 : 0.5864 : S22
Equation number 66 : 0 : PR_STAR2
Equation number 67 : 0 : S32
Equation number 68 : 0 : S42
Equation number 69 : 0 : 69
Equation number 70 : 0 : DPR2
Equation number 71 : 0 : 71
Equation number 72 : 0 : DP2
Equation number 73 : 0 : MCP2
Equation number 74 : 0 : MCR2
Equation number 75 : 0.077085 : PSIP2
Equation number 76 : 0 : Z2
Equation number 77 : 0 : M2
Equation number 78 : 0 : T2
Equation number 79 : 0 : 79
Equation number 80 : 0 : 80
Equation number 81 : 0 : 81
Equation number 82 : 0 : 82
Equation number 83 : 0 : 83
Equation number 84 : 1 : real_r2
Equation number 85 : -0.08861 : WELF2
Equation number 86 : 0 : CA2
Equation number 87 : 0 : 87
Equation number 88 : 0 : PZP2
Equation number 89 : 0 : PZR2
Equation number 90 : 0.94982 : KG2
Equation number 91 : 0 : 91
Equation number 92 : 0 : S_R
Equation number 93 : 2.9302 : MP
Equation number 94 : -2.3543 : YPT
Equation number 95 : 0.16609 : YPH
Equation number 96 : 0 : 96
Equation number 97 : 3.7947 : MR
Equation number 98 : -3.0488 : YRT
Equation number 99 : 0 : 99
Equation number 100 : 0.21509 : YRH
Equation number 101 : 0 : 101
Equation number 102 : 0 : S_R2
Equation number 103 : 3.3177 : MP2
Equation number 104 : -2.3543 : YPT2
Equation number 105 : 0 : 105
Equation number 106 : 0.16609 : YPH2
Equation number 107 : 4.2965 : MR2
Equation number 108 : -3.0488 : YRT2
Equation number 109 : 0 : 109
Equation number 110 : 0.21509 : YRH2

Warning: Matrix is singular to working precision.

In trust_region>dogleg (line 198)
In trust_region (line 115)
In dynare_solve (line 253)
In evaluate_steady_state (line 221)
In steady_ (line 55)
In steady (line 80)
In mix.driver (line 1256)
In dynare (line 293)

Residuals of the static equations:

Equation number 1 : 0 : LAMBDA1
Equation number 2 : 0 : 2
Equation number 3 : 0.0020555 : W
Equation number 4 : 0 : 4
Equation number 5 : 0 : 5
Equation number 6 : -0.67653 : Y
Equation number 7 : 0.33685 : LR
Equation number 8 : 8.9029 : KR
Equation number 9 : 1.5756 : WR
Equation number 10 : 0 : 10
Equation number 11 : -0.0094038 : KP
Equation number 12 : 0.052059 : 12
Equation number 13 : 0.16382 : YP
Equation number 14 : 0 : YR
Equation number 15 : 0 : WP
Equation number 16 : 0 : 16
Equation number 17 : -0.021705 : RK
Equation number 18 : 0.01911 : P_STAR
Equation number 19 : 0.46594 : S1
Equation number 20 : 0.5864 : S2
Equation number 21 : 0 : PR_STAR
Equation number 22 : 0 : S3
Equation number 23 : 0 : S4
Equation number 24 : 0 : 24
Equation number 25 : 0 : DPR
Equation number 26 : 0 : 26
Equation number 27 : 0 : DP
Equation number 28 : 0 : MCP
Equation number 29 : 0 : MCR
Equation number 30 : 0.077085 : PSIP
Equation number 31 : 0 : Z
Equation number 32 : 0 : M
Equation number 33 : 0 : T
Equation number 34 : 0 : 34
Equation number 35 : 0 : 35
Equation number 36 : 0 : 36
Equation number 37 : 0 : 37
Equation number 38 : 0 : 38
Equation number 39 : 1 : real_r
Equation number 40 : 0 : WELF
Equation number 41 : 0 : CA
Equation number 42 : 0 : CARBON_TAX
Equation number 43 : 0 : PZP
Equation number 44 : 0 : PZR
Equation number 45 : 0.94982 : KG
Equation number 46 : 0 : LAMBDA12
Equation number 47 : 0 : 47
Equation number 48 : 0.0020555 : W2
Equation number 49 : 0 : 49
Equation number 50 : 0 : 50
Equation number 51 : 6.9376 : Y2
Equation number 52 : 0.33685 : LR2
Equation number 53 : 8.9029 : KR2
Equation number 54 : 1.5756 : WR2
Equation number 55 : 0 : 55
Equation number 56 : -0.0094038 : KP2
Equation number 57 : 0.052059 : 57
Equation number 58 : 0.16382 : YP2
Equation number 59 : 0 : YR2
Equation number 60 : 0 : WP2
Equation number 61 : 0 : 61
Equation number 62 : -0.021705 : RK2
Equation number 63 : 0.01911 : P_STAR2
Equation number 64 : 0.46594 : S12
Equation number 65 : 0.5864 : S22
Equation number 66 : 0 : PR_STAR2
Equation number 67 : 0 : S32
Equation number 68 : 0 : S42
Equation number 69 : 0 : 69
Equation number 70 : 0 : DPR2
Equation number 71 : 0 : 71
Equation number 72 : 0 : DP2
Equation number 73 : 0 : MCP2
Equation number 74 : 0 : MCR2
Equation number 75 : 0.077085 : PSIP2
Equation number 76 : 0 : Z2
Equation number 77 : 0 : M2
Equation number 78 : 0 : T2
Equation number 79 : 0 : 79
Equation number 80 : 0 : 80
Equation number 81 : 0 : 81
Equation number 82 : 0 : 82
Equation number 83 : 0 : 83
Equation number 84 : 1 : real_r2
Equation number 85 : -0.08861 : WELF2
Equation number 86 : 0 : CA2
Equation number 87 : 0 : 87
Equation number 88 : 0 : PZP2
Equation number 89 : 0 : PZR2
Equation number 90 : 0.94982 : KG2
Equation number 91 : 0 : 91
Equation number 92 : 0 : S_R
Equation number 93 : 2.9302 : MP
Equation number 94 : -2.3543 : YPT
Equation number 95 : 0.16609 : YPH
Equation number 96 : 0 : 96
Equation number 97 : 3.7947 : MR
Equation number 98 : -3.0488 : YRT
Equation number 99 : 0 : 99
Equation number 100 : 0.21509 : YRH
Equation number 101 : 0 : 101
Equation number 102 : 0 : S_R2
Equation number 103 : 3.3177 : MP2
Equation number 104 : -2.3543 : YPT2
Equation number 105 : 0 : 105
Equation number 106 : 0.16609 : YPH2
Equation number 107 : 4.2965 : MR2
Equation number 108 : -3.0488 : YRT2
Equation number 109 : 0 : 109
Equation number 110 : 0.21509 : YRH2

Error using print_info (line 32)
Impossible to find the steady state (the sum of square residuals of the static equations is 299.5879). Either the model doesn’t have
a steady state, there are an infinity of steady states, or the guess values are too far from the solution

Error in steady (line 102)
print_info(info,options_.noprint, options_);

Error in mix.driver (line 1256)
steady;

Error in dynare (line 293)
evalin(‘base’,[fname ‘.driver’]) ;

You did not upload the mod-file. Should your modification of the file alter the steady state? If not, did you try to start from the steady state found for the old model?

Sorry.
Here are the files.
ss_policy.m (2.3 KB)
mix.mod (14.8 KB)

You did not answer my questions. Given the size of your model, it’s unreasonable to expect people to understand what is going on in your codes.

Hello,
I modified the steady state that will be affected, and also added the corresponding steady state of new open economic variables.

Then you need to check whether there is a mistake in the equations you added. It is rarely a good idea to start from such a big model. It makes debugging extremely hard.

Thank you for your advice. I will examine each equation carefully.

I first added enterprise heterogeneity to a closed economic model, and then expanded it to an open economy. These two steps were successful until I added the international terms of trade and import and export variables.

Then you should carefully investigate those equations. Are you sure that the model features a unique steady state after your modification?

I think there should be a unique steady state. I am also considering another way to describe the terms of foreign trade and import and export.

I was asking, because in many small open economy models the net foreign asset position has a unit root and therefore infinitely many steady states exist. Similarly, the terms of trade can often be normalized, but not endogenously computed without fully specifying the rest of the world.