SECTION 2.

GRADX

For description of the algorithm see the description of
quadratic hill-climbing in S.M.Goldfeld and R.E.Quandt, *Nonlinear
Methods in Econometrics*, North Holland Publ. Co., 1972, Pp.
5-9,

STORAGE REQUIREMENTS

NQ = i2 = 4*NP*NP + 6*NP when IVER = 1

NQ = 5*NP*NP + 7*NP when IVER = 2

TERMINATION FLAGS

IER = Greater than 0 if optimum is achieved

IER= 3 Function value is accurate to relative ACC

IER= 2 NORM of gradient is less than ACC

IER= 1 Attempted step size is less than ACC (relatively)

IER= -1 Iteration limit exceeded

IER= -2 Function error in FP or SP

IER= -3 Input error

IER= -4 Not enough scratch storage

IER= -5 Continual straying into forbidden region

IER= -6 Excessive R31 loops, may be at the optimum

IER= -7 Backtrack cycle exceeded, may be at the optimum

IER= -8 Eigenvalues did not converge

IER= -9 Function error in first call of FUNC

IER=-13 No stopping criterion enabled

Besides the general options the following are available.... The options which will most likely be of interest to the user are ISP, IST,FDFRAC,IVER in decreasing order.

COMMON/BOPT/IVER,LT,IFP,ISP,NLOOP,IST,ILOOP

IVER = 1 for Version 1 of GRADX. Works by optimizing a
quadratic approximation on a hypersphere. Default value is 1.

IVER = 2 for Version 2 of GRADX. Works by optimizing on a
suitably oriented ellipsoid.

LT = For internal use only

IFP = For DFP only (GRADX uses symmetric first derivatives)

ISP = 1 if symmetric 2nd derivatives are desired.

ISP = 2 if simple 2nd derivatives are desired. (Default value).

Note: The simple (one-sided)
derivatives are cheaper but less accurate than the symmetric
ones.

NLOOP = Number of times the method loops trying to find an
improved function value (Default value is 7).

IST = 0 if no stretching is desired.

IST = 1 if linear stretching is desired via parabolic method
DLNSR

IST = 2 if stretching via LNSR is desired.

IST = 3 if stretching via STRCH is desired. Default value is 1.

ILOOP = For internal use only.

COMMON/BFIDIF/FDFRAC,FDMIN

FDFRAC = Fraction of X(I) over which finite differences of the
function are taken for numerical derivatives (.0001 to .001)
Default value is .0001

FDMIN = Minimum acceptable value of FDFRAC*X(I). The equation
used is

E = MAX(ABS(X(I)*FDFRAC),FDMIN)

Default is 1.D-6

COMMON/BLNSR/STEP1,STPACC,NLNSR

STEP1 = Not applicable for GRADX.

STPACC = Accuracy required in linear optimizing. Default is
ACC/NP.

NLNSR = Max number of steps in each linear search. Default is 20.

COMMON/BGRDX2/RTM,EIG,RTMULT

RTM = (.25 to 1.00) Initial value of RTMOD. Default is .25

EIG = Smallest allowable absolute value of eigenvalue. Default is
1.D-8

RTMULT = Modifier of RTMOD. Default is 1.15

COMMON/BSPD/ISPD

ISPD = Frequency at which SPD should be reevaluated (Default = 1, i.e., at every iteration). This option can save computer time for problems with large NP, if the second derivatives are expensive to evaluate. The following options are parameters used by ZFU and BFU.

COMMON/BGRDX3/ACTI,ACTW,ZFUL,BETM

ACTI = Degree of actual improvement over apparent (.15 to .30)
Default is .2

ACTW = Degree of actual worsening over apparent (.15 to .30)
Default is .2

ZFUL = ZFU linear interpolation limit Default is 2.

BETM = Bet modifier .le. 1 Default is .5

SECTION 2.2 BHHH ESTIMATES OF THE HESSIAN

In the case of likelihood maximization, the user may wish to employ the approximation to the Hessian matrix discussed in Berndt, E.K., B.H. Hall,T.E. Hall, J.A. Hausman, "Estimation and Inference in Non- linear Structural Models, Annals of Economic and Social Measurement, 3 (1974), 653-666. In order to employ this technique, the customary SUBROUTINE FUNC(X,NP,F,*) must be written so as to evaluate and return in F not the likelihood or loglikelihood, but the logdensity. If this is not observed, erroneous results will be generated. In order to enable SUBROUTINE FUNC to return a logdensity, the user must insert in the MAIN program and in the SUBROUTINE FUNC the following statement:

COMMON/BGRDX1/NTRM,NBHHH,LBHHH,KBHHH

NTRM = The number of terms in the loglikelihood; to be set in
the MAIN program by the user.

NBHHH = 0 if the BHHH procedure is not to be used (Default=0)

NBHHH = 1 if the BHHH procedure is to be used.

LBHHH = used by GRADX internally; of no interest to the user.

KBHHH = the variable used by GRADX for indexing terms of the
loglikelihood. The user must use this variable in FUNC so that it
returns the logdensity associated with the KBHHH-th observation.
(See example at the end of this subsection). Since this procedure
uses a different line-search algorithm, the user may wish to
insert in the MAIN program the following:

COMMON/BSSVM1/THETAA,PHII,SHRIP1,SHRIP2,EPSS

THETAA = Not used by GRADX (see Section 9
).

PHII = Not used by GRADX (see Section 9 ).

SHRIP1 = Shrinkage factor in linear search (Default=0.2)

SHRIP2 = Expansion factor in linear search (Default=2.0)

EPSS = Used in linear search. Must be greater than 0.0 and less
than 0.5. (Default=0.05)

Example: Assume that NTRM observations are available on a variable Y which is distributed normally with unknown mean and variance. It is desired to obtain maximum likelihood estimates of the mean and variance. (This is obviously not proposed as a realistic illustration of the use of GRADX). Two function subroutines are shown: FUNCA is the appropriate function if the BHHH procedure is not to be used; FUNCB is the correct one if the BHHH procedure is to be used. In both, it is assumed that the observations on the variable Y are in an array Y( ) and that there are 20 observations. Thus, in the MAIN program, NTRM (see COMMON/BGRDX1/ ... ) will have been set = 20.

SUBROUTINE FUNCA(X,NP,F,*) IMPLICIT REAL*8 (A-H,O-Z) DIMENSION X(NP) C NEXT STATEMENT PASSES THE OBSERVATIONS COMMON/USER/Y(20) C NEXT STATEMENT PASSES THE NUMBER OF OBSERVATIONS IN NTRM COMMON/BGRDX1/NTRM,NBHHH,LBHHH,KBHHH C X(1) IS THE MEAN, X(2) THE VARIANCE C TEST IF GRADX HAS PROPOSED A STEP WITH NONPOSITIVE VARIANCE VALUE IF(X(2).LE.0.0) RETURN 1 F=0.0 C NOW LOOP TO COMPUTE LOGLIKELIHOOD DO I=1,NTRM F=F-(Y(I)-X(1))**2/(2.0*X(2)) END DO F=F-DFLOAT(NTRM)*DLOG(X(2))/2.0 RETURN END

SUBROUTINE FUNCB(X,NP,F,*) IMPLICIT REAL*8 (A-H,O-Z) DIMENSION X(NP) C NEXT STATEMENT PASSES THE OBSERVATIONS COMMON/USER/Y(20) C NEXT STATEMENT PASSES THE NUMBER OF OBSERVATIONS AND THE OBSERVATION C INDEX COMMON/BGRDX1/NTRM,NBHHH,LBHHH,KBHHH C TEST FOR NONPOSITIVE VARIANCE IF(X(2).LE.0.0) RETURN 1 C COMPUTE LOGDENSITY F=-DLOG(X(2))/2.0-(Y(KBHHH)-X(1))**2/(2.0*X(2)) RETURN END

Note: If the user wishes to employ analytic derivatives supplied by the user himself, he should consult Section 1.6