R: Support Functions for 'emmeans'

emmeans-brms-helpers {brms} | R Documentation

## Support Functions for emmeans

### Description

Functions required for compatibility of brms with emmeans. Users are not required to call these functions themselves. Instead, they will be called automatically by the `emmeans` function of the emmeans package.

### Usage

    recover_data.brmsfit(
      object,
      data,
      resp = NULL,
      dpar = NULL,
      nlpar = NULL,
      re_formula = NA,
      epred = FALSE,
      ...
    )

    emm_basis.brmsfit(
      object,
      trms,
      xlev,
      grid,
      vcov.,
      resp = NULL,
      dpar = NULL,
      nlpar = NULL,
      re_formula = NA,
      epred = FALSE,
      ...
    )

### Arguments

`object` | An object of class `brmsfit`.
`data, trms, xlev, grid, vcov.` | Arguments required by emmeans.
`resp` | Optional names of response variables. If specified, predictions are performed only for the specified response variables.
`dpar` | Optional name of a predicted distributional parameter. If specified, expected predictions of this parameters are returned.
`nlpar` | Optional name of a predicted non-linear parameter. If specified, expected predictions of this parameters are returned.
`re_formula` | Optional formula containing group-level effects to be considered in the prediction. If `NULL`, include all group-level effects; if `NA` (default), include no group-level effects.
`epred` | Logical. If `TRUE` compute predictions of the posterior predictive distribution's mean (see `posterior_epred.brmsfit`) while ignoring arguments `dpar` and `nlpar`. Defaults to `FALSE`.
`...` | Additional arguments passed to emmeans.

### Details

In order to ensure compatibility of most brms models with emmeans, predictions are not generated 'manually' via a design matrix and coefficient vector, but rather via `posterior_linpred.brmsfit`. This appears to generally work well, but note that it produces an '.@linfct' slot that contains the computed predictions as columns instead of the coefficients.

### Examples

    ## Not run:
    fit <- brm(time | cens(censored) ~ age * sex + disease + (1|patient),
                data = kidney, family = lognormal())
    summary(fit)

    # summarize via 'emmeans'
    library(emmeans)
    rg <- ref_grid(fit)
    em <- emmeans(rg, "disease")
    summary(em, point.est = mean)

    # obtain estimates for the posterior predictive distribution's mean
    epred <- emmeans(fit, "disease", epred = TRUE)
    summary(epred, point.est = mean)

    ## End(Not run)

[Package brms version 2.16.1 Index]