Learn R Programming

NAPrior (version 0.2.0)

NAP_posterior: Conduct posterior inference with NAP-based priors

Description

Draw posterior via MCMC (JAGS) with derived NAP priors from NAP_prior function both setting (one external trial/multiple external trials) and NAP method (NAP/mNAP/eNAP) will be determined by the provided NAP_prior object. If using eNAP, make sure the tuning parameter used to derive NAP_prior are calibrated by tune_param_eNAP function.

Usage

NAP_posterior(
  NAP_prior = NULL,
  y_EC2,
  s_EC2,
  iter = 2000,
  chains = 4,
  model = NULL
)

Value

A list of class "NAP_posterior_result" with elements:

  • posterior_sum: data frame with posterior summaries for \(\theta_{E,C2}\) (mean, sd, 95\ weights (prior_weight, post_weight).

  • enap_prior: For eNAP only: data frame describing the eNAP prior with calculated data-dependent weight: columns for NAP (Informative) and Vague, rows for Mixing Weight, Mean, Variance, and ESS (events) if available.

  • jags_fit: the R2jags fit object.

#'

Arguments

NAP_prior

An object returned by NAP_prior() containing the full the NAP prior (and if eNAP without assumed direct effects, calibrated tuning parameters (a,b))

y_EC2

Numeric scalar. Direct estimate \(y_{EC2}\) (e.g., log-HR) for \(E\) vs \(C2\).

s_EC2

Positive numeric scalar. Sampling variance \(s^2_{EC2}\) for \(y_{EC2}\).

iter

Total MCMC iterations per chain (default 2000).

chains

Number of MCMC chains (default 4).

model

Either a length-1 character string containing JAGS model code or a path to a JAGS model file. If NULL, a package default will be used.

Examples

Run this code
# \donttest{
# Create a NAP_prior object
my_naprior <- NAP_prior(
  weight_mtd = "fixed", w = 0.50,       # fixed mixture weight
  y_EC1  = -0.36, s_EC1  = 0.16^2,
  y_C2C1 = -0.30, s_C2C1 = 0.14^2,      # single external trial
  tau0   = 1000
)

# Calculate posterior
out <- NAP_posterior(
  NAP_prior = my_naprior,
  y_EC2 = -0.20, s_EC2 = 0.18^2,
  iter = 1000, chains = 2
)
out$posterior_sum
out$enap_prior
# }

Run the code above in your browser using DataLab