impute {oncomsm} | R Documentation |
Sample visits from predictive distribution
Description
impute()
samples visits for individuals in data
and potentially missing
individuals up to a maximum of n_per_group
from the posterior
predictive distribution of the given model.
sample_predictive()
draws samples from the predictive distribution of a
model given a parameter sample.
Usage
impute(
model,
data,
nsim,
n_per_group = NULL,
sample = NULL,
p = NULL,
shape = NULL,
scale = NULL,
now = NULL,
seed = NULL,
nsim_parameters = 1000L,
warmup_parameters = 250L,
nuts_control = list(),
as_mstate = FALSE,
...
)
sample_predictive(
model,
nsim,
n_per_group,
sample = NULL,
p = NULL,
shape = NULL,
scale = NULL,
seed = NULL,
nsim_parameters = 1000L,
warmup_parameters = 250,
nuts_control = list(),
as_mstate = FALSE,
...
)
Arguments
model |
an object of class srpmodel containing prior information |
data |
a data frame with variables
|
nsim |
integer, number of samples to draw |
n_per_group |
integer vector with number of individuals per group. |
sample |
a stanfit object with samples from the respective model. |
p |
numeric, vector of optional fixed response probabilities to use for sampling |
shape |
numeric, matrix of optional fixed Weibull shape parameters to use for sampling must be a matrix of dim c(n_groups, 3) where the second dimension corresponds to the transitions between s->r, s->p, r->p |
scale |
numeric, matrix of optional fixed Weibull scale parameters to use for sampling must be a matrix of dim c(n_groups, 3) where the second dimension corresponds to the transitions between s->r, s->p, r->p |
now |
numeric, time since first visit in data if not last recorded visit time |
seed |
integer, fixed random seed; NULL for no fixed seed |
nsim_parameters |
integer, number of parameter samples |
warmup_parameters |
integer, number of warmup samples for the rstan sampler before retaining samples of the parameters. |
nuts_control |
list, parameters for NUTS algorithm see |
as_mstate |
logical, return data in mstate format? |
... |
further arguments passed to method implementations |
Value
a data frame with variables
subject_id<chr>
(subject identifier),
group_id<chr>
(group identifier),
t<dbl>
(time of visit, relative to first visit in study),
state<chr>
(state recorded at visit)
iter<int>
(re-sample indicator).
Allowed states are "stable", "response", "progression" (or death),
and "EOF" (end of follow-up).
The EOF state marks the end of an individual's follow-up before the absorbing
state "progression".
See Also
sample_prior()
sample_posterior()
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", "stable")
)
impute(mdl, tbl, 1L, seed = 38L)
sample_predictive(mdl, 1L, 20L, seed = 38L)