Learn R Programming

ordinal (version 2019.4-25)

ranef: Extract conditional modes and conditional variances from clmm objects

Description

The ranef function extracts the conditional modes of the random effects from a clmm object. That is, the modes of the distributions for the random effects given the observed data and estimated model parameters. In a Bayesian language they are posterior modes.

The conditional variances are computed from the second order derivatives of the conditional distribution of the random effects. Note that these variances are computed at a fixed value of the model parameters and thus do not take the uncertainty of the latter into account.

Usage

ranef(object, ...)

condVar(object, ...)

# S3 method for clmm ranef(object, condVar=FALSE, ...)

# S3 method for clmm condVar(object, ...)

Arguments

object

a clmm object.

condVar

an optional logical argument indicating of conditional variances should be added as attributes to the conditional modes.

currently not used by the clmm methods.

Value

The ranef method returns a list of data.frames with the random effects predictions/estimates computed as conditional modes. If condVar = TRUE a data.frame with the conditional variances is stored as an attribute on each data.frame with conditional modes.

The condVar method returns a list of data.frames with the conditional variances. It is a convenience function that simply computes the conditional modes and variances, then extracts and returns only the latter.

Details

The ranef method returns a list of data.frames; one for each distinct grouping factor. Each data.frame has as many rows as there are levels for that grouping factor and as many columns as there are random effects for each level. For example a model can contain a random intercept (one column) or a random intercept and a random slope (two columns) for the same grouping factor.

If conditional variances are requested, they are returned in the same structure as the conditional modes (random effect estimates/predictions).

Examples

Run this code
# NOT RUN {
fm1 <- clmm(rating ~ contact + temp + (1|judge), data=wine)

## Extract random effect estimates/conditional modes:
re <- ranef(fm1, condVar=TRUE)

## Get conditional variances:
attr(re$judge, "condVar")
## Alternatively:
condVar(fm1)

# }

Run the code above in your browser using DataLab