Description Usage Arguments Value See Also Examples

Add weights to `draws`

objects, with one weight per draw, for use in
subsequent weighting operations. For reasons of numerical accuracy, weights
are stored in the form of unnormalized log-weights (in a variable called
`.log_weight`

). See `weights.draws()`

for details how to extract weights from
`draws`

objects.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ```
weight_draws(x, weights, ...)
## S3 method for class 'draws_matrix'
weight_draws(x, weights, log = FALSE, ...)
## S3 method for class 'draws_array'
weight_draws(x, weights, log = FALSE, ...)
## S3 method for class 'draws_df'
weight_draws(x, weights, log = FALSE, ...)
## S3 method for class 'draws_list'
weight_draws(x, weights, log = FALSE, ...)
## S3 method for class 'draws_rvars'
weight_draws(x, weights, log = FALSE, ...)
``` |

`x` |
(draws) A |

`weights` |
(numeric vector) A vector of weights of length |

`...` |
Arguments passed to individual methods (if applicable). |

`log` |
(logicla) Are the weights passed already on the log scale? The
default is |

A `draws`

object of the same class as `x`

.

`weights.draws()`

, `resample_draws()`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ```
x <- example_draws()
# sample some random weights for illustration
wts <- rexp(ndraws(x))
head(wts)
# add weights
x <- weight_draws(x, weights = wts)
# extract weights
head(weights(x)) # defaults to normalized weights
head(weights(x, normalize=FALSE)) # recover original weights
head(weights(x, log=TRUE)) # get normalized log-weights
# add weights which are already on the log scale
log_wts <- log(wts)
head(log_wts)
x <- weight_draws(x, weights = log_wts, log = TRUE)
# extract weights
head(weights(x))
head(weights(x, log=TRUE, normalize = FALSE)) # recover original log_wts
``` |

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.