The RANDOM statement defines a single random effect and its prior distribution or an array of random effects and their prior distribution. The random-effect must be represented by either a symbol or an array. The RANDOM statement must consist of the random-effect, a tilde (~), the distribution for the random effect, and then a SUBJECT= variable.
The random-effects parameters associated with each subject in the same RANDOM statement are assumed to be conditionally independent of each other, given other parameters and data set variables in the model. The other parameters include model parameters (declared in the PARMS statements), random-effects parameters (from other RANDOM statements), and missing data variables.
Table 61.4 shows the distributions that you can specify in the RANDOM statement.
Table 61.4: Valid Distributions in the RANDOM Statement
Distribution Name |
Definition |
---|---|
beta (<a=>, <b=>) |
Beta distribution with shape parameters and |
binary (<prob|p=> p) |
Binary (Bernoulli) distribution with probability of success p. You can use the alias bern for this distribution. |
gamma
(<shape|sp=> a, scale|s= ) |
Gamma distribution with shape a and scale or inverse-scale |
dgeneral (ll) |
General log-prior function that you construct using SAS programming statements for univariate or multivariate discrete random effects. See the section Specifying a New Distribution for more details. |
general (ll) |
General log-prior function that you construct using SAS programming statements for univariate or multivariate continuous random effects. See the section Specifying a New Distribution for more details. |
igamma
(<shape|sp=> a, scale|s= ) |
Inverse-gamma distribution with shape a and scale or inverse-scale |
laplace
(<location|loc|l=> , scale|s= ) |
Laplace distribution with location and scale or inverse-scale . This is also known as the double exponential distribution. You can use the alias dexpon for this distribution. |
normal
(<mean|m=> , sd= ) |
Normal (Gaussian) distribution with mean and a value of for the standard deviation, variance, or precision. You can use the aliases gaussian, norm, or n for this distribution. |
poisson (<mean|m=> ) |
Poisson distribution with mean |
table
(<p=> p) |
Table (categorical) distribution with probability vector p. You can also use the alias cat for this distribution |
uniform (<left|l=> a, <right|r=> b) |
Uniform distribution with range a and b. You can use the alias unif for this distribution. |
mvn (<mu=>, <cov=>) |
Multivariate normal distribution with mean vector and covariance matrix |
mvnar
(<mu=>, sd= , <rho=>) |
Multivariate normal distribution with mean vector and a covariance matrix . The covariance matrix is a multiple of the scale and a matrix with a first-order autoregressive structure |
The following RANDOM statement specifies a scale effect, where s2u
can be a constant or a model parameter and index
is a data set variable that indicates group membership of the random effect u
:
random u ~ normal(0,var=s2u) subject=index;
The following statements specify multidimensional effects, where mu
and cov
can be either parameters in the model or constant arrays:
array w[2]; array mu[2]; array cov[2,2]; random w ~ mvn(mu, cov) subject=index;
You can specify multiple RANDOM statements. Hyperparameters in the prior distribution of a random effect can be other random
effects in the model. For example, the following statements are allowed because the random effect g
appears in the distribution for the random effect u
:
random g ~ normal(0,var=s2g) subject=month; random u ~ normal(g,var=s2u) subject=day;
These two RANDOM statements specify a nested hierarchical model in which the random-effects g
is the hyperparameter of the random-effects u
. You can build the hierarchical structure as deep as you want. You can also use multiple RANDOM statements to build non-nested
random-effects models, where the effects could enter the model on different levels but not in the same hierarchy of each other.
The number of random-effects parameters in each RANDOM statement is determined by the number of unique values in the SUBJECT= variable, which can be either unsorted numeric or unsorted character literal. Unlike the model parameters that are explicitly declared in the PARMS statement (with therefore a fixed total number), the number of random-effects parameters in a program depends on the values of the SUBJECT= data set variable. That number can change from one BY group to another.
The order of the RANDOM statements, or their relative placement with respect to other statements in the program (such as the
PRIOR
statement or the MODEL
statement), is not important. The programming order becomes relevant if any hyperparameters are defined variables in the
program. For example, in the following statements, the hyperparameter s
is defined as a function of some variable or parameter in the model:
s = sqrt(s2g); random g ~ normal(0,sd=s) subject=month;
That definition of s
must appear before the RANDOM statement that requires it. If you switched the order of the statements as follows, PROC MCMC
would not be able to calculate the prior density for some subjects correctly and would produce erroneous results.
random g ~ normal(0,sd=s) subject=month; s = sqrt(s2g);
The names of the random-effects parameters are created internally. See the NAMESUFFIX= option for the naming convention of the random-effects parameters. The random-effects parameters are updated conditionally in the simulation. All posterior draws are saved to the OUTPOST= output data set by default, and you can use the MONITOR= option to monitor any of the parameters. For more information about available sampling algorithms, see the ALGORITHM= option. For more information about how to set a random-effects parameter to a constant (also known as corner-point constraint), see the CONSTRAINT option.
You can specify the following options in the RANDOM statement: