R: Posterior samples of parameters averaged across models

posterior_average.brmsfit {brms} | R Documentation

## Posterior samples of parameters averaged across models

### Description

Extract posterior samples of parameters averaged across models. Weighting can be done in various ways, for instance using Akaike weights based on information criteria or marginal likelihoods.

### Usage

    ## S3 method for class 'brmsfit'
    posterior_average(x, ..., pars = NULL,
      weights = "loo2", nsamples = NULL, missing = NULL,
      model_names = NULL, control = list(), seed = NULL)

    posterior_average(x, ...)

### Arguments

`x` | A fitted model object.
`...` | More fitted model objects or further arguments passed to the underlying post-processing functions.
`pars` | Names of parameters for which to average across models. Only those parameters can be averaged that appear in every model. Defaults to all overlapping parameters.
`weights` | Name of the criterion to compute weights from. Should be one of `"loo"`, `"waic"`, `"kfold"`, `"loo2"` (current default), or `"marglik"`. For the former three options, Akaike weights will be computed based on the information criterion values returned by the respective methods. For `"loo2"`, method `loo_model_weights` will be used to obtain weights. For `"marglik"`, method `post_prob` will be used to compute weights based on log marginal likelihood values (make sure to specify reasonable priors in this case). Alternatively, `weights` can be a numeric vector of pre-specified weights.
`nsamples` | Total number of posterior samples to use.
`missing` | An optional numeric value or a named list of numeric values to use if a model does not contain a parameter for which posterior samples should be averaged. Defaults to `NULL`, in which case only those parameters can be averaged that are present in all of the models.
`model_names` | If `NULL` (the default) will use model names derived from deparsing the call. Otherwise will use the passed values as model names.
`control` | Optional `list` of further arguments passed to the function specified in `weights`.
`seed` | A single numeric value passed to `set.seed` to make results reproducible.

### Details

Weights are computed with the `model_weights` method.

### Value

A `data.frame` of posterior samples. Samples are rows and parameters are columns.

### See Also

`model_weights`, `pp_average`

### Examples

    ## Not run:
    # model with 'treat' as predictor
    fit1 <- brm(rating ~ treat + period + carry, data = inhaler)
    summary(fit1)

    # model without 'treat' as predictor
    fit2 <- brm(rating ~ period + carry, data = inhaler)
    summary(fit2)

    # compute model-averaged posteriors of overlapping parameters
    posterior_average(fit1, fit2, weights = "waic")

    ## End(Not run)

[Package brms version 2.6.0 Index]