# The NLMIXED Procedure

### RANDOM Statement

• RANDOM random-effects ~distribution SUBJECT=variable <options>;

The RANDOM statement defines the random effects and their distribution. The random effects must be represented by symbols that appear in your SAS programming statements. The random effects usually influence the mean value of the distribution that is specified in the MODEL statement. The RANDOM statement consists of a list of the random effects (usually just one or two symbols), a tilde (~), the distribution of the random effects, and then a SUBJECT= variable.

The only distribution available for the random effects is normal(m,v), with mean m and variance v.

This syntax is illustrated as follows for one effect:

random u ~ normal(0,s2u) subject=clinic;


For multiple effects, you should specify bracketed vectors for m and v, the latter consisting of the lower triangle of the random-effects variance matrix listed in row order. This is illustrated for two random effects as follows:

random b1 b2 ~ normal([0,0],[g11,g21,g22]) subject=person;


Similarly, the syntax for three random effects is illustrated as follows:

random b1 b2 b3 ~ normal([0,0,0],[g11,g21,g22,g31,g32,g33])
subject=person;


The SUBJECT= variable determines the unique realizations of the random effects.

PROC NLMIXED constructs the subject clusters based on unique values in the SUBJECT= variable. This construction process of clusters, starting in SAS/STAT 13.1, is different from that in earlier releases of PROC NLMIXED, where a change in the SUBJECT= variable value indicates a new cluster. Because of this change, starting in SAS/STAT 13.1, the input data set does not need to be sorted by SUBJECT= variable to use the unique SUBJECT= variable values.

On the other hand, in earlier releases of SAS/STAT, PROC NLMIXED does not sort the input data set for you; rather, it processes the data sequentially and considers an observation to be from a new subject whenever the value of its SUBJECT= variable changes from the previous observation. To revert to this sequential process behavior of SAS/STAT 12.3 and previous releases, specify the NOSORTSUB option in the PROC NLMIXED statement.

You can specify multiple RANDOM statements; this is supported starting in SAS/STAT 13.2. When you specify more than one RANDOM statement, PROC NLMIXED assumes that the SUBJECT= variable from each RANDOM statement forms a containment hierarchy. For more information, see the section Hierarchical Model Specification. The syntax for two RANDOM statements is illustrated as follows:

random r11 ~ normal(0,sd1) subject = school;
random r21 ~ normal(0,sd2) subject = class(school);


You can specify the following options in the RANDOM statement:

ALPHA=

specifies the alpha level to be used in computing t statistics and intervals. The default value corresponds to the value of the ALPHA= option in the PROC NLMIXED statement.

DF=d

specifies the degrees of freedom to be used in computing t statistics and intervals in the OUT= data set. PROC NLMIXED calculates the default degrees of freedom as follows:

• When only one or no RANDOM statement is specified, the default value corresponds to the value of the DF= option in the PROC NLMIXED statement.

• When multiple RANDOM statements are specified, the default value is the number of subjects minus the number of random-effects variables in the corresponding RANDOM statement.

OUT=SAS-data-set

requests an output data set that contains empirical Bayes estimates of the random effects and their approximate standard errors of prediction.