Samples from Bayesian model using input from data frame
est_naloxone(
d,
psi_vec = c(0.7, 0.2, 0.1),
max_delays = 3,
delay_alpha = 2,
delay_beta = 1,
priors = the$default_priors,
run_estimation = TRUE,
rw_type = 1,
chains = 4,
iter = 2000,
seed = 42,
adapt_delta = 0.85,
pars = the$default_outputs,
include = TRUE,
...
)
data frame with format
unique id for region
time in months
Kits ordered
Kits reported as used
Kits reported as distributed
Optional label for region
reporting delay distribution
maximum delay from kit ordered to kit distributed
shape parameter for order to distributed delay distribution
shape parameter for order to distributed delay distribution
list of prior values including their mean (mu) and standard deviation (sigma)
if TRUE
will sample from posterior otherwise will
sample from prior only
1
- random walk of order one. 2
- random walk of order 2.
A positive integer specifying the number of Markov chains. The default is 4.
A positive integer specifying the number of iterations for each chain (including warmup). The default is 2000.
Seed for random number generation
(double, between 0 and 1, defaults to 0.8)
A vector of character strings specifying parameters of interest.
The default is NA
indicating all parameters in the model.
If include = TRUE
, only samples for parameters named in pars
are stored in the fitted results. Conversely, if include = FALSE
,
samples for all parameters except those named in pars
are
stored in the fitted results.
Logical scalar defaulting to TRUE
indicating
whether to include or exclude the parameters given by the
pars
argument. If FALSE
, only entire multidimensional
parameters can be excluded, rather than particular elements of them.
other parameters to pass to rstan::sampling
An S4 rstan::stanfit class object containing the fitted model
Other inference:
est_naloxone_vec()
if (FALSE) {
library(rstan)
library(bayesplot)
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores(logical = FALSE))
d <- generate_model_data()
priors <- list(
c = list(mu = 0, sigma = 1),
ct0 = list(mu = 0, sigma = 1),
zeta = list(mu = 0, sigma = 1),
mu0 = list(mu = 0, sigma = 1),
sigma = list(mu = 0, sigma = 1)
)
fit <- est_naloxone(d, priors = priors, iter = 100, chains = 1)
mcmc_pairs(fit,
pars = c("sigma", "mu0"),
off_diag_args = list(size = 1, alpha = 0.5)
)
}