RATS 11.1
RATS 11.1

FIND( options )  MAXIMUM/MINIMUM/ROOT expression

  instruction or block of instructions used in computing expression

END FIND

 

FIND is the “catch-all” optimization instruction. You can use it to find the maximum, minimum, or root (zero) of almost anything that can be computed with a RATS instruction or set of instructions. The only restriction is that the parameters must be continuous and real-valued. Before you can use it, you must:

 

Set the list of free parameters using NONLIN.

Set initial values for the parameters (usually with COMPUTE or INPUT).

Parameters

MAXIMUM, MINIMUM, or ROOT

Choose which operation you wish to do.

expression

This is the (real-valued) expression that FIND is optimizing. This will usually be a variable set within the block of instructions. You must declare any variables in this expression which are set within the instruction block.

Options

PARMSET=PARMSET to estimate [default internal]

This tells which PARMSET is to be estimated by the FIND. If you don’t provide a PARMSET, FIND uses the last one created by NONLIN.

 

METHOD=[SIMPLEX]/BFGS/GENETIC/ANNEALING/GA/GRID

ITERATIONS=iteration limit[100]

SUBITERATIONS=subiteration limit [30]

CVCRIT=convergence limit [.00001]

TRACE/[NOTRACE]

These control the optimization method. Of these, only BFGS makes assumptions about differentiability (it requires the function be twice continuously differentiable) and is the only one capable of producing standard errors for the estimates. SIMPLEX requires continuity, while the others have no special requirements. GRID is specific to FIND and does a grid search over a range of values provided by the GRID option.

 

ITERATIONS sets the maximum number of iterations, SUBITERS sets the maximum number of subiterations, CVCRIT the convergence criterion. TRACE prints the intermediate results. The "iteration" counts for simplex, genetic, annealing and GA are designed to give a similar amount of calculation to what an iteration in BFGS requires).
 

PMETHOD=[SIMPLEX]/BFGS/GENETIC/ANNEALING/GA/GRID

PITERS=number of PMETHOD iterations to perform [none]

Use PMETHOD and PITERS if you want to use a preliminary estimation method to refine your initial parameter values before switching to one of the other estimation methods. For example, to do 20 simplex iterations before switching to BFGS, you use the options PMETHOD=SIMPLEX, PITERS=20, and METHOD=BFGS.
 

GRID=VECTOR[VECTOR] with values for grid search (METHOD=GRID only)

With METHOD=GRID or PMETHOD=GRID, use this option to provide the values you want FIND to search over. The VECT[VECT] should contain one vector for each parameter in the parameter set being estimated.

 

STDERRS/[NOSTDERRS]

With this you can decide whether or not to show the computed standard errors of the coefficients. This is only an option if you use METHOD=BFGS, as the other methods don't assume enough about the function to allow standard errors calculations. If you use METHOD=BFGS, you can use STDERRS to make the output show standard errors, t–statistics and significance levels, just like other estimation instructions. However, if the function that you are maximizing isn’t a likelihood or quasi-likelihood function, the numbers reported are unlikely to be interpretable as standard errors.

 

[PRINT]/NOPRINT

VCV/[NOVCV]

TITLE=description of optimization being done [none]

These are the same as for other estimation instructions. VCV only works with METHOD=BFGS and only if you use the STDERRS option.

Statement Block

FIND is actually very similar to the instruction LOOP. A function evaluation will execute all instructions between the FIND and the END FIND. A BREAK instruction within the statement block will cause FIND to abort estimation.

Variables Defined

%BETA

The estimated parameter values (VECTOR)

%FUNCVAL

Final value of expression (REAL)

%CONVERGED

= 1 or 0. Set to 1 if the process converged, 0 if not.

%NFREE

Number of free parameters (INTEGER)

%CVCRIT

final convergence criterion. This will be equal to zero if the subiterations limit was reached on the last iteration (REAL)

%LAGRANGE

VECTOR of Lagrange multipliers if estimating with constraints and METHOD=BFGS.

Technical Information

FIND ROOT actually minimizes the absolute value of the expression. This allows the optimization algorithms to be used, but it can be thrown off if initial values are near a local minimum of the function. FIND ROOT is provided as a convenience, but is not a dedicated “root finder.” Make sure you check the function value (either in the output or in the %FUNCVAL variable) to see if it is near zero before using the results.

Notes

FIND can be very slow. The instructions it controls will have to be executed once for each function evaluation, and it may take several hundred function evaluations to reach convergence even with just four or five free parameters.

Examples

This estimates a model where the log likelihood is computed across the full sample by concentrating it. Since a concentrated likelihood can't be computed entry by entry, you can't use MAXIMIZE.

 

dec real concentrate

nonlin theta

find maximum concentrate

   set yadjust = log(y)+theta*y

   linreg(noprint) yadjust

   # constant logk logl

   sstats / log(1+theta*y)-log(y)>>yterms

   compute concentrate=yterms+%logl

end find


 

This finds a DSGE that comes closest to matching a set of estimated impulse responses.

 

nonlin(parmset=dsgeparms) b1 b2 nai delta1 delta2 gamma1 gamma2 gamma3

declare real ceemetric

find minimum ceemetric

   *

   * Solve the DSGE given the current values

   *

   dsge(a=a,f=f,model=loanmodel) y rm l rl eta

   @dlmirf(a=a,f=f*.2,steps=nsteps,results=theoretical)

   compute ceemetric=0.0

   do h=1,nsteps

      do i=1,4

         compute ceemetric=ceemetric+(theoretical(i,1)(h)-estimated(i,1)(h))^2/estvar(i,1)(h)

      end do i

   end do h

end find


 

The code below does a preliminary grid search for C (estimating the other parameters) then estimates a final model starting at the best value found by the grid search.

 

stats(fractiles) y

compute grid=%seqa(%fract01,(%fract99-%fract01)/99.0,100)

nonlin(parmset=conly) c

nonlin(parmset=gammaonly) gamma

find(parmset=conly,method=grid,grid=||grid||) min %rss

   nlls(frml=star,parmset=regparms+gammaonly,noprint) y

end find

nonlin(parmset=starparms) gamma c

nlls(frml=star,parmset=regparms+starparms,print) y


Sample Output

This is a typical output from a FIND instruction. Because there is no connection to “data” in the basic instruction, there aren’t any goodness of fit statistics or the like. Standard errors, t–statistics and significance levels are included only if you use METHOD=BFGS and the STDERRS option and you should do that only if you are quite sure that the use of the inverse Hessian as an estimate of the covariance matrix is proper.

 

FIND Optimization - Estimation by Genetic

Convergence in    43 Iterations. Final criterion was  0.0000061 <  0.0000100

Function Value                       0.99668260

 

   Variable                     Coeff

*****************************************

1.  XM                       -0.999996023

 


Copyright © 2026 Thomas A. Doan