subset_draws {posterior} | R Documentation |
Subset draws
objects
Description
Subset draws
objects by variables, iterations, chains, and draws indices.
Usage
subset_draws(x, ...)
## S3 method for class 'draws_matrix'
subset_draws(
x,
variable = NULL,
iteration = NULL,
chain = NULL,
draw = NULL,
regex = FALSE,
unique = TRUE,
exclude = FALSE,
scalar = FALSE,
...
)
## S3 method for class 'draws_array'
subset_draws(
x,
variable = NULL,
iteration = NULL,
chain = NULL,
draw = NULL,
regex = FALSE,
unique = TRUE,
exclude = FALSE,
scalar = FALSE,
...
)
## S3 method for class 'draws_df'
subset_draws(
x,
variable = NULL,
iteration = NULL,
chain = NULL,
draw = NULL,
regex = FALSE,
unique = TRUE,
exclude = FALSE,
scalar = FALSE,
...
)
## S3 method for class 'draws_list'
subset_draws(
x,
variable = NULL,
iteration = NULL,
chain = NULL,
draw = NULL,
regex = FALSE,
unique = TRUE,
exclude = FALSE,
scalar = FALSE,
...
)
## S3 method for class 'draws_rvars'
subset_draws(
x,
variable = NULL,
iteration = NULL,
chain = NULL,
draw = NULL,
regex = FALSE,
unique = TRUE,
exclude = FALSE,
scalar = FALSE,
...
)
## S3 method for class 'rvar'
subset_draws(x, variable = NULL, ...)
## S3 method for class 'draws'
subset(x, ...)
Arguments
x |
(draws) A |
... |
Arguments passed to individual methods (if applicable). |
variable |
(character vector) The variables to select. All elements of non-scalar variables can be selected at once. |
iteration |
(integer vector) The iteration indices to select. |
chain |
(integer vector) The chain indices to select. |
draw |
(integer vector) The draw indices to be
select. Subsetting draw indices will lead to an automatic merging
of chains via |
regex |
(logical) Should |
unique |
(logical) Should duplicated selection of chains,
iterations, or draws be allowed? If |
exclude |
(logical) Should the selected subset be excluded?
If |
scalar |
(logical) Should only scalar variables be selected?
If |
Details
To ensure that multiple consecutive subsetting operations work correctly,
subset()
repairs the draws
object before and after
subsetting.
Value
A draws
object of the same class as x
.
Examples
x <- example_draws()
subset_draws(x, variable = c("mu", "tau"))
subset_draws(x, chain = 2)
subset_draws(x, iteration = 5:10, chain = 3:4)
# extract the first chain twice
subset_draws(x, chain = c(1, 1), unique = FALSE)
# extract all elements of 'theta'
subset_draws(x, variable = "theta")
# trying to extract only a scalar 'theta' will fail
# subset_draws(x, variable = "theta", scalar = TRUE)