Parameter loops

Hello,

I have a basic DSGE model and am trying to find the value of a parameter (b) that solves a particular equation (f(X)=0) where X is a vector of covariances.

More specifically, using Dynare I can solve the DSGE model conditional on the value of parameter b and derive covariances of endogenous variables which I denote as a vector, X(b). This allows me to compute the equation f(X(b)) and see if it is close to 0.

I would like to do this for many values of b and find the value of b that makes f(X(b)) closest to 0, which I think requires me to do a loop.

Is there a simple way to implement loops in Dynare? I have looked at some other forum posts, but I am still unclear as to how to implement loops.

Thank you.

Best,
John

The closest would be

or