sample_posterior {oncomsm} | R Documentation |
Sample parameters from a model
Description
sample_posterior()
draws samples from the
posterior distribution of the specified model given a data set with
visit data.
sample_prior()
draws samples from the
prior distribution of the specified model object.
Usage
sample_posterior(
model,
data,
now = NULL,
nsim = 2000L,
seed = NULL,
warmup = 500L,
nuts_control = list(),
acceptable_divergent_transition_fraction = 0.1,
...
)
sample_prior(
model,
nsim = 2000L,
seed = NULL,
warmup = 500L,
nuts_control = list(),
...
)
Arguments
model |
an object of class srpmodel containing prior information |
data |
a data frame with variables
|
now |
numeric, time from first visit in data if different form last recorded visit |
nsim |
integer, number of samples to draw |
seed |
integer, fixed random seed; NULL for no fixed seed |
warmup |
integer, number of warm-up samples for the MCMC sampler
before retaining samples; see |
nuts_control |
list, parameters for NUTS algorithm see |
acceptable_divergent_transition_fraction |
numeric between 0 and 1 giving the acceptable fraction of divergent transitions before throwing an error |
... |
further arguments passed to method implementations |
Value
A rstan::stanfit object with posterior samples.
See Also
rstan::stan()
parameter_sample_to_tibble()
sample_predictive()
impute()
Examples
mdl <- create_srpmodel(A = define_srp_prior())
tbl <- tibble::tibble(
subject_id = c("A1", "A1"),
group_id = c("A", "A"),
t = c(0, 1.5),
state = c("stable", "response")
)
sample_posterior(mdl, tbl, seed = 42L)
sample_prior(mdl, seed = 42L)