Learn R Programming

NAPrior (version 0.2.0)

NAP_oc: Simulation for operating-characteristics applying NAP-based priors

Description

Runs Monte Carlo simulations of an E vs C2 trial and performs Bayesian analysis with a NAP-based prior constructed by NAP_prior(). The routine supports both single external study setting and multiple external studies settings as encoded in the provided NAP_prior object, and works with either a fixed mixture weight (mNAP) or an elastic, data-adaptive weight (eNAP).

Usage

NAP_oc(
  NAP_prior = NULL,
  theta_EC2 = 0,
  n_EC2 = 200,
  lambda = 2,
  sim_model = c("Exponential", "Weibull"),
  model_param = 0.05,
  iter = 2000,
  chains = 4,
  seed = 123,
  nsim = 100,
  jags_model = NULL
)

Value

A data frame with one row per replicate containing:

  • post_mean, post_sd, low95, hi95 — posterior mean, SD, and 95\

  • prob_E_better — posterior probability theta_{E,C2} < 0.

  • prior_weight, post_weight — prior and updated weights used in the mixture (for eNAP, prior_weight is w(Z)).

  • sigma_hat — posterior mean of between-study SD (RE only; NA for FE).

Arguments

NAP_prior

An object returned by NAP_prior() that contains the prior specification and (for eNAP) any calibrated tuning parameters a, b.

theta_EC2

Numeric scalar. True log-hazard ratio for E vs C2 used to generate the direct trial data.

n_EC2

Integer. Total sample size for the simulated E vs C2 trial.

lambda

Numeric scalar \(> 0\). Randomization ratio E:C2; e.g., lambda = 2 means 2:1 allocation to E:C2.

sim_model

Character string. Event-time model used to simulate individual times; one of "Exponential" or "Weibull".

model_param

Named numeric vector for the baseline hazard of the control arm. For sim_model = "Exponential", use c(rate = ...). For sim_model = "Weibull", use c(shape = ..., rate = ...).

iter

Integer. Total MCMC iterations per chain for JAGS (default 2000).

chains

Integer. Number of MCMC chains (default 4).

seed

Integer. Random seed for the simulation replicates.

nsim

Integer. Number of Monte Carlo replicates (default 100).

jags_model

Either a length-1 character string containing JAGS model code (e.g., a packaged object such as jags_model_RE) or a file path to a .txt JAGS model. If NULL, a default FE/RE model is chosen to match the NAP_prior mode.