RATS 11
RATS 11

Instructions /

MAXIMIZE Instruction

Home Page

← Previous Next →

MAXIMIZE(options)   frml start end funcval

 

MAXIMIZE estimates the parameters of a fairly generalized type of maximization problem. It can be used for maximum likelihood estimation of models for which RATS does not have a direct estimator. It finds (or attempts to find) the \(\theta\) which solves:

 

\(\mathop {\max }\limits_\theta  \,G(\theta ) = \sum\limits_{t = 1}^T {{\kern 1pt} {\kern 1pt} f\left( {{y_t},{\kern 1pt} {\kern 1pt} {\kern 1pt} {\kern 1pt} {{\bf{X}}_t},{\kern 1pt} {\kern 1pt} \theta } \right)} \)       

 

where f is a RATS formula (FRML). Before you can use it, you must:

 

Set the list of free parameters using NONLIN

Create the explanatory formula f using FRML

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

Parameters

frml

This is the FRML (created with the FRML instruction) which computes the function f.

start, end

the estimation range. If you have not set a SMPL, it defaults to the range over which frml can be computed.

 

Some FRML's (particularly recursively defined formulas such as GARCH models) require you to specify a range. If you get the error message:

 

Missing Values ... Leave No Usable Data Points


your range either has to be set explicitly or, if you have already specified one, it must be changed to match the available data.

funcval

SERIES for final values of the frml

General Options

PARMSET=PARMSET to use [default internal]

This option selects the PARMSET (parameter set) to be estimated. RATS maintains a single unnamed parameter set which is the one used for estimation if you don’t use PARMSET to specify a named set.
 

METHOD=BHHH/[BFGS]/SIMPLEX/GENETIC/ANNEALING/GA/EVALUATE

Chooses the estimation method. BHHH should be used only if the function being maximized is the log likelihood (apart from additive constants). BFGS and BHHH require the formula to be twice continuously differentiable and are the only ones that can compute standard errors. The others are derivative-free, make less stringent assumptions and are generally used as a PMETHOD choice to refine initial guess values rather than as the final estimation method.

 

METHOD=EVALUATE simply evaluates the function at the current settings of the parameters and produces no output other than the variables like %LOGL and %FUNCVAL.

 

ITERATIONS=iteration limit [100]

SUBITERATIONS=subiteration limit [30]

CVCRIT=convergence limit [.00001]

TRACE/[NOTRACE]

ITERATIONS sets the maximum number of iterations, SUBITERS sets the maximum number of subiterations, CVCRIT the convergence criterion. TRACE prints the intermediate results. For METHOD=SIMPLEX, an “iteration” is actually defined as K vertex changes, where K is the number of free parameters. This makes the number of calculations per “iteration” similar to the other methods.

 

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

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—MAXIMIZE will automatically switch to the "METHOD" choice after completing the "preliminary" iterations requested using PMETHOD and PITERS.

 

HESSIAN=initial guess for inverse Hessian (METHOD=BFGS only)

This allows you to supply initial values for the inverse Hessian. This option is only available on instructions that offer the BFGS method, and only when using that method. Without it, the estimation will start with a BHHH matrix, but with diagonal elements only.

 

STARTUP=FRML evaluated at period "start"

ONLYIF=expression tested before calculating start option [not used]

You can use the START option to provide an expression which is computed once per function evaluation, before any of the regular formulas are computed. This allows you to do any time-consuming calculations that depend upon the parameters, but not upon time. It can be an expression of any type. ONLYIF calculates the expression provided; if it evaluates to a zero value, the function evaluation doesn’t continue, and the function is assigned the missing value. ONLYIF is examined before doing START, unlike REJECT (below), which is done after the START.

 

REJECT=FRML indicating a “rejection” zone for the parameters

If the FRML evaluates to a non-zero (“true”) value, the function is immediately assigned the missing value.

 

[PRINT]/NOPRINT

VCV/[NOVCV]

TITLE="title for output" [“MAXIMIZE”]

These are the standard output control options.

 

SMPL=Standard SMPL option [unused]

WEIGHT=series of weights for the data points

These are the standard options form skipping data points or reweighting observations.

 

ROBUSTERRORS/[NOROBUSTERRORS]

LAGS=correlated lags [0]

LWINDOW=NEWEYWEST/BARTLETT/DAMPED/PARZEN/QUADRATIC/[FLAT]/PANEL/WHITE

LWFORM=VECTOR with the window form [not used]

CLUSTER=series with category values for clustered standard errors [not used]

DAMP=value of \(\gamma\) for LWINDOW=DAMPED [0.0]

These permit calculation of a consistent covariance matrix or clustered standard errors if you are doing Quasi Maximum likelihood estimation. With MAXIMIZE, the LAGS, LWINDOW, LWFORM and CLUSTER options are used for dealing with correlation in the gradient elements.

 

DERIVES=(output) VECTOR[SERIES] for partial derivatives [unused]

This saves the series of partial derivatives of the function f. The first series in the VECTOR will be the partials with respect to the first parameter displayed in the MAXIMIZE output, the second series will be the partials with respect to the second parameter, and so on.

Hypothesis tests

If you have used METHOD=BFGS or METHOD=BHHH, you can test hypotheses on the coefficients using TEST, RESTRICT and MRESTRICT and compute standard errors for functions of the coefficients using SUMMARIZE. Coefficients are numbered by their positions parameter set. See "Technical Information" regarding the validity of these test statistics.

Missing Values

MAXIMIZE drops any entry which cannot be computed because of missing values.

Technical Information

MAXIMIZE uses numerical derivatives when a gradient is needed. After the first iteration, the perturbations used in computing these adapt to the estimates of the dispersion of the parameters. NLPAR includes special controls for the process of taking numerical derivatives, and for the "climbing" algorithms.

 

The validity of the covariance matrix and standard errors produced by MAXIMIZE depend upon the functional form and the options that you choose. In general, standard errors produced using METHOD=BHHH are asymptotically correct only if the function being maximized is the log likelihood apart from additive constants. This is true even if the function you use is a 1–1 monotonic transformation of the log likelihood, and thus has an identical maximum. The default standard error calculations for BFGS are correct only under similar circumstances. If you’re maximizing a function other than the log likelihood, you should use the combination of METHOD=BFGS and ROBUSTERRORS.

Variables Defined

%BETA

coefficient VECTOR

%XX

covariance matrix (SYMMETRIC)

%TSTATS

VECTOR containing the t-stats for the coefficients

%STDERRS

VECTOR of coefficient standard errors

%NOBS

number of observations (INTEGER)

%NREG

number of regressors (INTEGER)

%NFREE

number of free parameters (INTEGER)

%FUNCVAL

final value of the function being maximized. (REAL)

%ITERS

iterations completed (INTEGER)

%CONVERGED

=1 or 0. 1 indicates that the process converged (INTEGER)

%CVCRIT

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

%LAGRANGE

VECTOR of Lagrange multipliers if estimating with constraints.

Examples

This estimates a probit model for a data set where there are repetitions of settings for the explanatory variables (X1 and X2), with REPS and SUCCESS giving the total observations and the number of successes. Note the use of the “sub-formula” to describe the function of the explanatory variables and how the PROBIT formula evaluates this just once and puts it into the variable Z. The use of the sub-formula allows quick changes to the basic model.

 

nonlin b0 b1 b2

frml zfrml = b0+b1*x1+b2*x2

frml probit = (z=zfrml(t)) , $

     success*log(%cdf(z))+(reps-success)*log(1-%cdf(z))

compute b0=b1=b2=0.0

maximize probit


 

Box-Cox models (Box and Cox, 1964) can take several forms. The only one which requires use of MAXIMIZE rather than NLLS has the dependent variable subject to a Box-Cox transformation with unknown parameter. In RATS, you can compute the Box-Cox class of transformations using the function %BOXCOX. The following estimates using maximum likelihood the model

      

\({y_t}^{\left( \lambda  \right)} = {\beta _0} + {\beta _1}X_t^{\left( \lambda  \right)} + {u_t}\,\,;\,\,{u_t} \sim N(0,{\sigma ^2})\,\,i.i.d\)

 

Initial guess values are obtained using a linear regression, which (with an adjustment to the intercept) is a special case for \(\lambda=1\).

 

nonlin b0 b1 lambda sigmasq

frml rhsfrml  = b0+b1*%boxcox(x,lambda)

frml boxcox   = (lambda-1)*log(y) + $

    %logdensity(sigmasq,%boxcox(y,lambda)-rhsfrml(t))

linreg y

# constant x

compute sigmasq=%seesq,b0=%beta(1)+%beta(2)-1

compute b1=%beta(2),lambda=1.0

maximize(method=bfgs,robusterrors,iters=200) boxcox

 

Note: convergence can be extremely slow with these models, which is why the iterations limit is increased.


 

This estimates a linear regression on a panel data set allowing for heteroscedasticity among the (five) individuals. The variance parameters are in the vector SIGSQ, while the regression parameters come off the vector B generated using FRML with the LASTREG option.

 

linreg iv

# constant f c

frml(lastreg,vector=b) zfrml

dec vector sigsq(5)

compute sigsq=%const(1.0)

nonlin b sigsq

frml groupgls = %logdensity(sigsq(%indiv(t)),iv-zfrml)

maximize(iters=200,method=bfgs) groupgls


 

Here Y given E is assumed to have an exponential distribution with mean B+E, where B is a parameter to be estimated. This is estimated by maximum likelihood using the BHHH algorithm.

 

data(format=prn,org=columns) 1 20 id y e

nonlin b

frml logl = -log(b+e)-y/(b+e)

maximize(method=bhhh) logl


 


Copyright © 2025 Thomas A. Doan