RANDOM random-effects </ options>;
Using notation from the section Notation for the Generalized Linear Mixed Model, the RANDOM statement defines the matrix of the mixed model, the random effects in the
vector, and the covariance structure of
.
The matrix is constructed exactly like the
matrix for the fixed effects, and the
matrix is constructed to correspond to the effects that constitute
. The covariance structure of
is defined by using the TYPE= option. The random effects can be classification or continuous effects, and you can specify multiple RANDOM statements.
You can specify INTERCEPT (or INT) as a random effect to indicate the intercept. PROC BGLIMM does not include the intercept in the RANDOM statement by default as it does in the MODEL statement.
Table 9 summarizes the options available in the RANDOM statement. All options are then discussed in alphabetical order.
Table 9: RANDOM Statement Options
| Option | Description |
|---|---|
| Construction and Sampling of Covariance Structure | |
| COVPRIOR= | Specifies the prior for the |
| GROUP= | Varies the |
| NUTS | Specifies options for the No-U-Turn Sampler of the Hamiltonian |
| Monte Carlo algorithm for the |
|
| RESIDUAL | Designates a covariance structure as R-side |
| SUBJECT= | Identifies the subjects in the model |
| TYPE= | Specifies the type of the |
| Statistical Output | |
| G | Displays the estimated |
| GCORR | Displays the correlation matrix that corresponds to the estimated |
| MONITOR | Displays the summary, diagnostic statistics, and plots |
| of individual random effects | |
| NOOUTPOST | Suppresses storing the posterior samples of |
| individual random effects in the OUTPOST= data set | |
You can specify the following options in the RANDOM statement after a slash (/).
specifies a prior distribution for the covariance matrix, , of the random effects, when the
matrix is of the UN, UN(1), VC, or TOEP(1) type, where a conjugate sampler is used to sample the covariance matrix. This option is ignored for other covariance types, because you assign a flat prior to the
matrix if its type is not UN, UN(1), VC, or TOEP(1). For more information, see the section Prior for the G-Side Covariance.
You can specify one of the following prior-distributions:
specifies the prior to be a half-Cauchy distribution. The half-Cauchy prior is applied only to the diagonal terms (variances) of the matrix. The off-diagonal terms of the
matrix are assumed to have a flat prior.
You can specify the scale parameter a of the half-Cauchy distribution. The scale parameter a must be positive. By default, SCALE=25.
specifies the prior to be a half-normal distribution. The half-normal prior is applied only to the diagonal terms (variances) of the matrix. The off-diagonal terms of the
matrix are assumed to have a flat prior.
You can specify the variance a of the half-normal distribution. The variance a must be positive. By default, VAR=25.
specifies an inverse gamma prior, , with the density
for each diagonal term of the
matrix. It is the default prior for the covariance types UN(1), VC, and TOEP(1).
You can set the parameters of the inverse gamma distribution by specifying one or both of the following options, separated by a comma or a space:
specifies the shape parameter a of the inverse gamma distribution. By default, SHAPE=2.
specifies the scale parameter b of the inverse gamma distribution. BY default, SCALE=2.
specifies an inverse Wishart prior, , for the
matrix of the random effects. The hyperparameters a and
are the degrees of freedom and scale matrix of an inverse Wishart distribution, respectively. The inverse Wishart prior is the default prior for the UN covariance type. The following examples show several ways to specify an inverse Wishart prior distribution:
covprior=iwishart covprior=iwishart(scale=25) covprior=iwishart(df=6, diagonal=(1 4 9))
You can set the parameters of the inverse Wishart distribution by specifying one or more of the following options, separated by a comma or a space:
specifies the degrees of freedom of the inverse Wishart distribution. The default is the dimension of the matrix plus 3.
specifies as the scale matrix of the inverse Wishart distribution, where
is the identity matrix. The default is the dimension of the
matrix plus 3. You can set the scale matrix
by specifying one of these options: SCALE=, DIAGONAL=, or COV=.
specifies a list of positive values for the diagonal terms in the scale matrix of the inverse Wishart distribution. The default value of each diagonal term is the dimension of the
matrix plus 3. You can set the scale matrix
by specifying one of these options: SCALE=, DIAGONAL=, or COV=.
specifies a list of values for the entries in the lower-triangle portion of the scale matrix for the inverse Wishart distribution. The specified values of the diagonal terms must be positive, and the whole matrix must be positive definite. The order of the list is rowwise. The default setting is
, where b is the dimension of the
matrix plus 3. You can set the scale matrix
by specifying one of these options: SCALE=, DIAGONAL=, or COV=.
specifies a scaled inverse Wishart prior for the matrix of the random effects.
You can set the parameters of the scaled inverse Wishart distribution by specifying one or more of the following options, separated by a comma or a space:
specifies the degrees of freedom a of the scaled inverse Wishart distribution. The default is the dimension of the matrix of the random effects plus 3.
specifies as the scale matrix of the scaled inverse Wishart distribution, where
is the identity matrix. The default is the dimension of the
matrix of the random effects plus 3.
specifies the variance parameter c of the normal prior for . By default, VAR=1.
specifies a uniform prior, , for the
matrix of the random effects. The uniform prior is applied to standard deviations (the square root of the diagonal terms) of the
matrix.
You can set the lower and upper bounds of the uniform distribution by specifying one or both of the following options, separated by a comma or a space:
specifies the lower bound a of the uniform distribution. The lower bound must be nonnegative. By default, LOWER=0.
specifies the upper bound b of the uniform distribution. The upper bound must be positive. By default, UPPER=1E10.
displays the estimated matrix for G-side
random effects that are associated with this RANDOM statement. PROC BGLIMM displays blanks for values that are 0. The ODS table name is G.
displays the correlation matrix that corresponds to the estimated matrix for G-side
random effects that are associated with this RANDOM statement. PROC BGLIMM displays blanks for values that are 0. The ODS table name is GCORR.
identifies groups by which to vary the covariance parameters. All observations that have the same level of the effect have the same covariance parameters. Each new level of the grouping effect produces a new set of covariance parameters. You should exercise caution in properly defining the effect, because strange covariance patterns can result when it is misused. Also, the effect can greatly increase the number of estimated covariance parameters, which can adversely affect the sampling process.
The GROUP= effect must be specified in the CLASS statement.
displays results (summary, diagnostic statistics, and plots) for the individual-level random-effects parameters. By default, to save time and space, PROC BGLIMM does not print results for individual-level random-effects parameters. In models that have a large number of individual random effects (for example, tens of thousands), it can take a long time to display the summary, diagnostic statistics, and plots for all the individual-level parameters, so be cautious when using this option.
You can monitor a subset of the random-effects parameters. You can provide a numeric list of the SUBJECT indexes, or PROC BGLIMM can randomly choose a subset of all subjects for you.
To monitor a list of random-effects parameters for certain subjects, you can provide their indexes as follows:
random x / subject=index monitor=(1 to 5 by 2 23 57);
In this case, PROC BGLIMM outputs results of random effects for subjects 1, 3, 5, 23, and 57. If the number of items in the list is greater than the number of subjects, the extra list items are ignored.
PROC BGLIMM can also randomly choose a subset of all the subjects to monitor, if you submit a statement such as the following:
random x / subject=index monitor=(random(12));
In this case, PROC BGLIMM outputs results of random effects for 12 randomly selected subjects. You control the sequence of the random indexes by specifying the SEED= option in the PROC BGLIMM statement.
When you specify the MONITOR option, it uses the values that you specify in the STATISTICS= and PLOTS= options in the PROC BGLIMM statement.
suppresses storing the posterior samples of individual random-effects parameters in the OUTPOST= data set. By default, PROC BGLIMM outputs the posterior samples of all random-effects parameters to the OUTPOST= data set. You can use this option to avoid saving the random-effects parameters. In models that have a large number of individual random effects (for example, tens of thousands), PROC BGLIMM can run faster if it does not save the posterior samples of all the individual random effects.
When you specify both the NOOUTPOST option and the MONITOR option, PROC BGLIMM outputs the list of variables that are monitored.
There is a limit on the maximum number of variables that you can save to an OUTPOST= data set. If you run a large-scale random-effects model in which the number of parameters exceeds that limit, the NOOUTPOST option is invoked automatically and PROC BGLIMM does not save the individual random-effects draws to the output data set. You can use the MONITOR option to select a subset of the parameters to store in the OUTPOST= data set.
specifies options for the No-U-Turn Sampler (NUTS) of the Hamiltonian algorithm that is used to sample the parameters in the matrix of the corresponding RANDOM statement. The NUTS algorithm is a version of the adaptive Hamiltonian Monte Carlo algorithm with automatic tuning of the step size and number of steps in each iteration. For more information, see the section Hamiltonian Monte Carlo Sampler. You can specify the following nuts-options:
specifies the target acceptance rate during the tuning process of the NUTS algorithm. Increasing the value can often improve mixing, but it can also significantly slow down the sampling. By default, DELTA=0.6.
specifies the maximum height of the NUTS algorithm tree. The taller the tree, the more gradient evaluations per iteration the procedure calculates. The number of evaluations is . Usually, the height of a tree should be no more than 10 during the sampling stage, but it can go higher during the tuning stage. A larger number indicates that the algorithm is having difficulty converging. By default, MAXHEIGHT=10.
specifies the number of tuning iterations for the NUTS algorithm to use. By default, NTU=1000.
specifies the initial step size in the NUTS algorithm. By default, STEPSIZE=0.1.
specifies that the random effects listed in this statement
be R-side effects. You use this option in the RANDOM statement if the covariance matrix is for the R-side. Specifying this option is equivalent to using the REPEATED statement. For example, if it is necessary to order the columns of the R-side AR(1) covariance structure by the Time variable, you can use the RESIDUAL option as in the following statements:
class time id;
random time / subject=id type=ar(1) residual;
identifies the subjects in the model for the random effects.
A set of random effects is estimated for each subject. All variables in the effect must be declared as categorical variables in the CLASS statement. PROC BGLIMM assumes independence across subjects, conditional on other parameters in the model. Specifying a subject effect is equivalent to nesting all other effects in the RANDOM statement within the subject effect. Thus, for the RANDOM statement, the SUBJECT= option produces a block-diagonal structure that has identical blocks.
For more information about specifying a random effect with or without the SUBJECT= variable, see the section Treatment of Subjects in the RANDOM Statement.
specifies the covariance structure of the matrix for G-side effects.
Although a variety of structures are available, many applications call for either simple diagonal (TYPE=VC) or unstructured covariance matrices. The default structure is TYPE=VC (variance components), which models a different variance component for each random effect.
If you want different covariance structures in different parts of , you must use multiple RANDOM statements with different TYPE= options.
Valid values for covariance-structure and their descriptions are provided in Table 10.
Table 10: Covariance Structures
In Table 10, Parms refers to the number of covariance parameters in the structure, t is the overall dimension of the covariance matrix, q is the order parameter, and equals 1 when A is true and 0 otherwise. For example, 1
equals 1 when
and 0 otherwise, and 1
equals 1 when
and 0 otherwise. For the TYPE=TOEPH structures,
.
specifies a first-order antedependence structure
(Kenward 1987; Patel 1991) parameterized in terms of variances and correlation parameters. If t ordered random variables have a first-order antedependence structure, then each
,
, is independent of all other
, given
. This Markovian structure is characterized by its inverse variance matrix, which is tridiagonal. Parameterizing an ANTE(1) structure for a random vector of size t requires 2t – 1 parameters: variances
and t – 1 correlation parameters
. The covariances among random variables
and
are then constructed as
PROC BGLIMM constrains the correlation parameters to satisfy . For variable-order antedependence models see Macchiavelli and Arnold (1994).
specifies a first-order autoregressive structure,
The values and
are derived for the ith and jth observations, respectively, and are not necessarily the observation numbers. For example, in the following statements, the values correspond to the class levels for the
Time effect of the ith and jth observation within a particular subject:
proc bglimm;
class time patient;
model y = x x*x;
random time / sub=patient type=ar(1);
run;
specifies a heterogeneous first-order autoregressive structure,
where . This covariance structure has the same correlation pattern as the TYPE=AR(1) structure, but the variances are allowed to differ.
specifies the first-order autoregressive moving average structure,
Here, is the autoregressive parameter,
models a moving average component, and
is a scale parameter. In the notation of Fuller (1976, p. 68),
and
The example in Table 11 and imply that
where and
. PROC BGLIMM imposes the constraints
and
for stationarity, although for some values of
and
in this region, the resulting covariance matrix is not positive definite.
specifies the compound symmetry structure, which has constant variance and constant covariance
The compound symmetry structure arises naturally with nested random effects, such as when subsampling error is nested within experimental error. Hierarchical random assignments or selections, such as subsampling or split-plot designs, give rise to compound symmetric covariance structures. This implies exchangeability of the observations in the subunit, leading to constant correlations between the observations. Compound symmetry structures are thus usually not appropriate for processes in which correlations decline according to some metric, such as spatial and temporal processes.
specifies the heterogeneous compound symmetry structure, which is an equicorrelation structure but allows for different variances,
specifies the factor-analytic structure with one factor
(Jennrich and Schluchter 1986). This structure is of the form , where
is a
vector and
is a
diagonal matrix with t different parameters.
specifies a covariance structure that satisfies the general
Huynh-Feldt condition (Huynh and Feldt 1970). For a random vector that has t elements, this structure has positive parameters and covariances
A covariance matrix generally satisfies the Huynh-Feldt condition if it can be written as
. The preceding parameterization chooses
. Several simpler covariance structures give rise to covariance matrices that also satisfy the Huynh-Feldt condition. For example, TYPE=CS, VC, and UN(1) are nested within TYPE=HF. Note also that the HF structure is nested within an unstructured covariance matrix.
models a Toeplitz covariance structure. This structure can be viewed as an autoregressive structure whose order is equal to the dimension of the matrix,
specifies a banded Toeplitz structure,
This can be viewed as a moving average structure whose order is equal to q – 1. The specification TYPE=TOEP(1) is the same as , and it can be useful for specifying the same variance component for several effects.
models a Toeplitz covariance structure. The correlations of this structure are banded as in the TOEP or TOEP(q) structures, but the variances are allowed to vary:
The correlation parameters satisfy . If you specify the optional value q, the correlation parameters with
are set to 0, creating a banded correlation structure. The specification TYPE=TOEPH(1) results in a diagonal covariance matrix with heterogeneous variances.
specifies a completely general (unstructured) covariance matrix that is parameterized directly in terms of variances and covariances,
The variances are constrained to be nonnegative, and the covariances are unconstrained. This structure is constrained to be nonnegative definite. If you specify the order parameter q, then PROC BGLIMM estimates only the first q bands of the matrix, setting elements in all higher bands equal to 0.
specifies standard variance components and is the default structure for both G-side and R-side covariance structures. In a G-side covariance structure, a distinct variance component is assigned to each effect. In an R-side structure, TYPE=VC is usually used only to add overdispersion effects or, with the GROUP= option, to specify a heterogeneous variance model.
Table 11 lists some examples of the structures in Table 10.
Table 11: Covariance Structure Examples
| Description | Structure | Example |
|---|---|---|
| First-order antedependence |
ANTE(1) | |
| First-order autoregressive |
AR(1) | |
| Heterogeneous AR(1) |
ARH(1) | |
| First-order autoregressive moving average |
ARMA(1,1) | |
| Compound symmetry |
CS | |
| Heterogeneous compound symmetry |
CSH | |
| First-order factor analytic |
FA(1) | |
| Huynh-Feldt | HF | |
| Toeplitz | TOEP | |
| Toeplitz with two bands |
TOEP(2) | |
| Heterogeneous Toeplitz |
TOEPH | |
| Unstructured | UN | |
| Banded main diagonal |
UN(1) | |
| Variance components |
VC (default) | |