-
Notifications
You must be signed in to change notification settings - Fork 0
/
model_weights.Rmd
56 lines (42 loc) · 1.77 KB
/
model_weights.Rmd
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
title: "``brms::model_weights.brmsfit`` Extract Parameter Names"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(brms)
```
model_weights.brmsfit Model Weighting Methods
#### Description
Compute model weights in various ways, for instance via stacking of predictive distributions,
Akaike weights, or marginal likelihoods.
#### Usage
<pre><code>
## S3 method for class 'brmsfit'
model_weights(x, ..., weights = "loo2",
model_names = NULL)
model_weights(x, ...)
</code></pre>
#### Arguments
* x A fitted model object.
* ... More fitted model objects or further arguments passed to the underlying postprocessing functions.
* 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 likelihoodvalues (make sure to specify reasonable priors in this case). Alternatively, weights can be a numeric vector of pre-specified weights.
* model_names If NULL (the default) will use model names derived from deparsing the call. Otherwise will use the passed values as model names.
#### Examples
```{r}
# model with 'treat' as predictor
fit1 <- brm(rating ~ treat + period + carry, data = inhaler)
summary(fit1)
```
```{r}
# model without 'treat' as predictor
fit2 <- brm(rating ~ period + carry, data = inhaler)
summary(fit2)
```
```{r}
# obtain Akaike weights based on the WAIC
model_weights(fit1, fit2, weights = "waic")
```
#### Value
A numeric vector of weights for the models.