Problem with macro-loop

Dear all,

I’m using macro-loops in my .mod file to make it easier but strangely, when I want to test for one parameter to be equal to 0 or not, it’s working fine with one the loop (see line 88-90) and it’s not working with line 182 while it’s the same structure. Do you have an idea of what’s going on ? I think it’s a basic issue but I can’t find a way out of this.

Thank you so muchSecteur_N.mod (6.3 KB)Secteur_N.m (26.6 KB)

The part

       if GAMMA_@{sectora+sectorb}
         var M_@{sectora+sectorb};
       end

is not a preprocessor command. It is only known at runtime to Dynare. That is no problem for the parameter initialization where Matlab expressions with if are valid. But it is not valid Dynare syntax within the model block.

Ok thank you very much Professor.

Do you have an idea of how to use the loop in the model block ?

Thanks

Without knowing what you are trying to do here, no.

Basically, how can we use an “if” condition in a model block ? In some equations of my model, I want some variables to be added only if they exist and this is why I need this “if” condition.

Then you need to code it in a way that this is known to the preprocessor. What is the logic when a variable does not exist?

Okay : so we have a cobb-douglas production function with linkages between sectors. But since we have a cobb-douglas function, if a good is not an input for a sector, its import should be 0. But Dynare can’t compute the jacobians because then there are some values of imports that are initialized as 0.

See here the specification of the model.

Ok, and the issue is that you do not know whether an input is 0 unless you check a parameter values in an Excel file?