Description Usage Arguments Details See Also Examples

View source: R/bridgesampling.R

Compute posterior model probabilities from marginal likelihoods.
The `brmsfit`

method is just a thin wrapper around
the corresponding method for `bridge`

objects.

1 2 |

`x` |
A |

`...` |
More |

`prior_prob` |
Numeric vector with prior model probabilities.
If omitted, a uniform prior is used (i.e., all models are equally
likely a priori). The default |

`model_names` |
If |

Computing the marginal likelihood requires samples
of all variables defined in Stan's `parameters`

block
to be saved. Otherwise `post_prob`

cannot be computed.
Thus, please set `save_all_pars = TRUE`

in the call to `brm`

,
if you are planning to apply `post_prob`

to your models.

The computation of model probabilities based on bridge sampling requires
a lot more posterior samples than usual. A good conservative
rule of thump is perhaps 10-fold more samples (read: the default of 4000
samples may not be enough in many cases). If not enough posterior
samples are provided, the bridge sampling algorithm tends to be
unstable leading to considerably different results each time it is run.
We thus recommend running `post_prob`

multiple times to check the stability of the results.

More details are provided under
`bridgesampling::post_prob`

.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ```
## Not run:
# model with the treatment effect
fit1 <- brm(
count ~ zAge + zBase + Trt,
data = epilepsy, family = negbinomial(),
prior = prior(normal(0, 1), class = b),
save_all_pars = TRUE
)
summary(fit1)
# model without the treatent effect
fit2 <- brm(
count ~ zAge + zBase,
data = epilepsy, family = negbinomial(),
prior = prior(normal(0, 1), class = b),
save_all_pars = TRUE
)
summary(fit2)
# compute the posterior model probabilities
post_prob(fit1, fit2)
# specify prior model probabilities
post_prob(fit1, fit2, prior_prob = c(0.8, 0.2))
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.