RATS 11
RATS 11

Instructions /

NONLIN Instruction

Home Page

← Previous Next →

NONLIN( options )  parameterfields (separated by blanks)

Sets and maintains sets of free parameters for non-linear estimation for the instructions which allow general sets of parameters (NLLS, NLSYSTEM, MAXIMIZE, FIND, CVMODEL, DLM). It can also impose constraints on those parameters. Note that:

 

You should do the NONLIN before you construct the formula with FRML

The variables should be given initial values before you do the estimation (the default initial value is 0).

Nonlinear parameters are stored in objects called "parameter sets", or "parmset" for short. You can use DISPLAY to view the contents of an existing parameter set (applies only for "named" parameter sets, not the default internal—PARMSET option below).

Wizard

You can define a list of nonlinear parameters when using the Statistics—Equation/FRML Definition Wizard to define a formula.

Parameters

parameterfields

a parameter field is one of the following:

 

a simple REAL variable, such as B1

a real array (VECTOR, RECTANGULAR, SYMMETRIC, PACKED)

an array of arrays, such as a VECTOR of VECTORs

a substitution operation: B3=B1*B2

an equality constraint: B3==B1*B2

an inequality constraint: B3>=0.0. You cannot use a strict inequality here (for instance, B3>0.0 is illegal).

 

Options

PARMSET=PARMSET to define [default internal]

Using the PARMSET option, you can define or redefine a parameter set. By using the PARMSET option on your estimation instruction, you can switch easily from one parameter set to another. RATS maintains a single unnamed parameter set which is the one used for estimation if you don’t provide a named set.

 

ZEROS/[NOZEROS]

If you use the ZEROS option, the elements of the PARMSET are initialized to zero. By default, whatever values they previously had are retained—a new variable name will be initialized to NA. If you use the PARMSET without initializing some of the values, you will get a warning message like:

 

## NL6. NONLIN Parameter C1 Has Not Been Initialized. Trying 0

 

Thus, zero is (in effect) the default guess value for any parameter—the warning is there in case you run into numerical problems related to not having proper guess values. If zeroes are a reasonable set of guesses (for instance, linear functions aren't sensitive to guess values), then the ZEROS option will allow you to use the PARMSET without explicit guess values and without getting the warnings.

 

ADD/[NOADD]

This allows you to add parameters or constraints to a parameter set without reentering the full set. Changes are added to the default parameter set if you don’t use the PARMSET option, or to the PARMSET being defined if you did.

 

ADD is largely obsolete because you can now separate the parameter set into different parts and “add” them using the + operator when you need to use them for estimation. That is, MAXIMIZE(PARMSET=MODELPARMS+GARCH) will combine the MODELPARMS and GARCH parameter sets to form the working parameter set.

Notes

If you use an array, it must be DECLAREd before the NONLIN. It does not need to be DIMENSIONed until you are ready to use it. You can include inequality constraints on the individual elements of an array, or on all of them at once. For instance,

 

declare vector b

nonlin b b>=0.0

 

constrains all elements of B to be non-negative.

 

Use a substitution constraint rather than an equality constraint wherever possible. RATS handles B3=B1*B2 by setting B3 equal to B1*B2 every time B1 or B2 changes, thus eliminating one free parameter. With B3==B1*B2, RATS estimates the three parameters separately, and uses Lagrange multiplier methods to push the estimates towards the constraint. This is a much slower process. The equality constraint should be used only when you can’t easily solve out for one parameter in terms of the others.

 

The FRML instruction can be used to create a formula and matching PARMSET from a linear equation or regression. This can be very handy when there is a linear model for the mean whose form you don’t want to fix in advance.

 

Before you can use any of the estimation instructions, you should set initial values for the parameters. If all zeros is reasonable, you can use the ZEROS option on the NONLIN; otherwise COMPUTE and INPUT are the two simplest ways to accomplish this—the two examples below show two ways of setting the same set of initial values:

 

compute b1=b2=b3=0.0,b4=1.0

input b1 b2 b3 b4

 0 0 0 1

 

You can use the DISPLAY instruction to display a list of the variables in a parameter set, along with the current values of those variables. This only works for “named” parameter sets—you cannot display the contents of the (unnamed) default internal set.

Examples

nonlin alpha lambda sig_eta sig_eps

 

defines the default parameter set as having the five named parameters.

 

dec vect b(n)

nonlin(parmset=meanparms) b

 

defines the PARMSET named MEANPARMS as a VECTOR of dimension N.

 

nonlin(parmset=base) mu1 mu2 mu3 $

   p11 p12 p13 p21 p22 p23 p31 p32 p33

nonlin(parmset=relax) ep14 ep24 ep34

nonlin(parmset=symmetry) p12=p21 p13=p31 p23=p32

 

This defines three PARMSETS. BASE has a base set of parameters, RELAX has some added ones and SYMMETRIC forces equality constraints among three pairs. Note that these use = which means that they are forced to be equal.


 

nonlin(parmset=lrrest) lrf(1)(2,3)==0.0


This defines a PARMSET called LRREST. This imposes an implicit constraint (note the ==). This is used because the LRF(1)(2,3) is a matrix calculation of other parameters.


Copyright © 2025 Thomas A. Doan