Skip to contents

Method to sample from compiled Stan model and return a CmdStanMCMC object with draws.

Usage

mcmc_sample(x, ...)

# S4 method for ANY
mcmc_sample(x, ...)

# S4 method for Analysis
mcmc_sample(
  x,
  iter_warmup = 1000L,
  iter_sampling = 10000L,
  chains = 4L,
  verbose = FALSE,
  ...
)

Arguments

x

object to sample, such as Analysis (created with create_analysis_obj()) or Simulation.

...

additional arguments passed to the $sample() method of a cmdstanr Stan model. See https://mc-stan.org/cmdstanr/reference/model-method-sample.html

iter_warmup

The number of warm up iterations to run per chain. The default is 1000.

iter_sampling

The number of post-warm up iterations to run per chain. The default is 10000.

chains

The number of Markov chains to run. The default is 4.

verbose

logical. Whether to print sampler updates (TRUE) or not (FALSE)

Value

An object of class CmdStanMCMC

Examples

## Analysis objects
anls <- create_analysis_obj(
  data_matrix = example_matrix,
  covariates = add_covariates(
    covariates = c("cov1", "cov2"),
    priors = normal_prior(0, 1000)
  ),
  outcome = weib_ph_surv_dist(
    "time",
    "cnsr",
    shape_prior = normal_prior(0, 1000)
  ),
  borrowing = borrowing_details(
    "BDB",
    "ext",
    exponential_prior(.001),
    baseline_prior = normal_prior(0, 1000)
  ),
  treatment = treatment_details("trt", normal_prior(0, 1000))
)
#> Inputs look good.
#> Error: CmdStan path has not been set yet. See ?set_cmdstan_path.

mcmc_results <- mcmc_sample(anls)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'mcmc_sample': object 'anls' not found