Applied to an object of type stansim_simulation,
extract_data()
will return the object's simulation data as a
dataframe, subject to the filtering specified by the function arguments.
# S3 method for stansim_simulation extract_data(object, datasets = "all", parameters = "all", estimates = "all", values = NULL, param_expand = TRUE, ...)
object | An object of S3 class stansim_simulation. |
---|---|
datasets | Either a character vector containing the names of datasets
(as provided to the original |
parameters | Either a character vector containing the names of stan
model parameters present in the fitted stan models, or the string
|
estimates | Either a character vector containing the names of parameter
estimates calculated (e.g. c("2.5
|
values | Either a function taking a single numeric argument that returns
a Boolean value, or |
param_expand | If |
... | other arguments not used by this method |
A dataframe containing the specified data.
# NOT RUN { # extract full dataset extract_data(simulation) # extract all parameter means, 2.5% & 97.5% percentiles extract_data(simulation, estimates = c("2.5%", "mean", "97.5%")) # extract all Rhat estimates greater than 1.1 extract_data(simulation, estimates = "Rhat", values = function(x) x > 1.1) # extract all "eta" parameters extract_data(simulation, parameters = "eta") # extract all "eta[1]" parameters extract_data(simulation, parameters = "eta[1]", param_expand = FALSE) # extract all rows for dataset "data_file-12.rds" extract_data(simulation, datasets = "data_file-12.rds") # }