NLMOD Procedure
Programming Statements
Programming statements define the arguments of the MODEL, ESTIMATE, and PREDICT statements in PROC NLMOD. Most of the programming statements that you can use in the SAS DATA step can also be used in the NLMOD procedure. For a description of SAS programming statements, see SAS Language Reference: Concepts. You can use the following programming statements:
ABORT;
CALL name [ ( expression [, expression …] ) ];
DELETE;
DO[variable = expression
[TO expression] [BY expression]
[, expression [ TO expression] [ BY expression ] …]
]
[ WHILE expression ] [ UNTIL expression ] ;
END;
GOTO statement_label;
IF expression;
IF expression THEN program_statement;
ELSE program_statement;
variable = expression;
variable + expression;
LINK statement_label;
PUT [variable] [=] […];
RETURN;
SELECT[(expression)];
STOP;
SUBSTR( variable, index, length )= expression;
WHEN (expression) program_statement;
OTHERWISE program_statement;
For the most part, these SAS programming statements work the same as they do in the SAS DATA step, as documented in SAS Language Reference: Concepts. However, they differ as follows:
The ABORT statement does not allow any arguments.
-
The DO statement does not allow a character index variable. Thus, PROC NLMOD supports the first of the following statements, but not the second:
do i = 1,2,3; do i = 'A','B','C'; In contrast to other procedures that share PROC NLMOD’s programming syntax, PROC NLMOD does not support the LAG function. Because observations are not processed sequentially when high-performance analytical procedures perform the parameter optimization, information for computing lagged values is not available.
-
The PUT statement, used mostly for program debugging in PROC NLMOD, supports only some of the features of the DATA step PUT statement, and it has some new features that the DATA step PUT statement does not have:
The PROC NLMOD PUT statement does not support line pointers, factored lists, iteration factors, overprinting, _INFILE_, the colon (:) format modifier, or "$".
-
The PROC NLMOD PUT statement supports expressions, but the expression must be enclosed in parentheses. For example, the following statement displays the square root of x:
put (sqrt(x)); -
The PROC NLMOD PUT statement supports the item _PDV_, which displays a formatted listing of all variables in the program. For example, the following statement displays a much more readable listing of the variables than the _ALL_ print item:
put _pdv_;
-
The WHEN and OTHERWISE statements enable you to specify more than one programming statement. That is, DO/END groups are not necessary for multiple WHEN statements. For example, the following syntax is valid:
select; when (exp1) stmt1; stmt2; when (exp2) stmt3; stmt4; end;
When you write your programming statements, avoid defining variables that begin with an underscore (_), because they might conflict with internal variables that PROC NLMOD creates. The MODEL statement must follow any SAS programming statements that define or modify terms that are used to specify the model.
Special Variable _WEIGHT_
Defining the special variable _WEIGHT_ in your PROC NLMOD programming statements enables you either to request weighted nonlinear least squares estimation of parameters or to request that each observation in the input data set be weighted by a value.
You can define the _WEIGHT_ variable as in the following statement:
_weight_ = expression;
When you specify this statement, the expression on the right-hand side of the assignment statement is evaluated for each observation in the data set. You can simply provide a variable name instead of an expression. PROC NLMOD uses the value of the _WEIGHT_ variable in two ways, depending on which type of model you request:
When you do not specify a particular distribution, PROC NLMOD performs the weighted nonlinear least squares method by using the value of the
_WEIGHT_expression for each observation. These values multiplied byare taken as inverse elements of the diagonal variance-covariance matrix of the dependent variable. The larger the
_WEIGHT_value, the more importance the observation is given.When you specify either a built-in distribution function or a general likelihood function, PROC NLMOD performs the maximum likelihood method by weighting each observation in the input data set by the value of the
_WEIGHT_expression.
Note that the _WEIGHT_ expression can be a function of the estimated parameters. For estimation purposes, the derivative of the _WEIGHT_ expression with respect to the parameters is not included in the gradient and Hessian of the loss function. This is usually the desired approach for iteratively reweighted least squares estimation. When the _WEIGHT_ expression is a function of the parameters, the gradient and Hessian that are used can lead to poor convergence or nonconvergence of the requested estimation. To have the derivative of the _WEIGHT_ expression with respect to the parameters included in the gradient and Hessian of the loss function, do not use the _WEIGHT_ programming statement. Instead, redefine the model as
where y is the original dependent variable, is the nonlinear model, and
is the weight that is a function of the parameters.