rjMCMC {fkbma}R Documentation

Run Reversible Jump MCMC (rjMCMC) Procedure

Description

This function performs a Reversible Jump MCMC (rjMCMC) procedure to generate the posterior distribution, using Bayesian model averaging and free-knot B-splines.

Usage

rjMCMC(
  data,
  candsplinevars,
  candbinaryvars,
  candinter,
  outcome,
  factor_var,
  mcmc_specs = NULL,
  prior_params = NULL
)

Arguments

data

A data frame containing the observations, including the following columns:

factor_var

Exposure group binary indicator.

outcome

Continuous-valued outcome.

candsplinevars

All candidate spline variables as described in candsplinevars.

candbinaryvars

All candidate binary variables as described in candbinaryvars.

candsplinevars

A vector of names for continuous predictive candidate variables (default = NULL).

candbinaryvars

A vector of names for binary predictive candidate variables (default = NULL).

candinter

A vector indicating which of the candidate variables are tailoring (default = NULL).

outcome

A string indicating the name of the continuous outcome variable in data.

factor_var

A string indicating the name of the binary exposure variable in data.

mcmc_specs

A list containing:

iter

Number of total iterations per chain (including warmup; default = 4000).

warmup

Number of warmup/burn-in samples per chain (default = 2000).

thin

Thinning parameter (default = 1).

chain

Number of chains (default = 4).

sigma_v

Proposal variance for "jump" terms (default = 0.1).

bma

Boolean indicating whether to include Bayesian model averaging step (default = TRUE).

prior_params

A list containing prior parameters:

lambda_1

Prior parameter for the number of terms in the model (default = 0.1).

lambda_2

Prior parameter for the number of knots in each spline (default = 1).

a_0

Shape parameter for inverse gamma prior on individual-level variance (default = 0.01).

b_0

Rate parameter for inverse gamma prior on individual-level variance (default = 0.01).

degree

Degree of B-splines (default = 3).

k_max

Maximum number of knots for each spline term (default = 9).

w

Window for proposing knot location changes (default = 1).

sigma_B

Prior normal variance for model coefficients (default = sqrt(20)).

Value

An rjMCMC object with the following components:

accept_var

Matrix indicating the acceptance of variable inclusion/removal for each iteration.

accept_add_knot

Matrix indicating acceptance of knot addition for each spline term across iterations.

accept_remove_knot

Matrix indicating acceptance of knot removal for each spline term across iterations.

accept_move_knot

Matrix indicating acceptance of knot movement for each spline term across iterations.

splines_fitted

List of matrices, one per spline interaction term, containing fitted spline values across iterations.

binary_param

Matrix containing posterior samples of binary variable parameters.

inter_trt_param

Matrix containing posterior samples of the treatment intercept and main effect.

sigma_sq

Matrix of posterior samples for the residual variance (sigma squared).

vars_prop

Matrix indicating the inclusion of variables across iterations (1 for included, 0 for excluded).

vars_prop_summ

Posterior inclusion probabilities for all candidate variables (spline and binary).

k

Matrix indicating the number of knots for each spline term across iterations.

trt_eff_posterior

Matrix of posterior treatment effect estimates, including spline effects.

data_fit

The original dataset passed to the function.

candsplineinter

A character vector indicating the spline interaction terms.

candsplinevars

A character vector of candidate spline variables.

candbinaryvars

A character vector of candidate binary variables.

candinter

A character vector of interaction terms with treatment (can include splines and binary variables).

mcmc_specs

The MCMC specifications used in the procedure.

prior_params

The prior parameters used in the procedure.

References

Maleyeff, L., Golchi, S., Moodie, E. E. M., & Hudson, M. (2024) "An adaptive enrichment design using Bayesian model averaging for selection and threshold-identification of predictive variables" doi:10.1093/biomtc/ujae141

Examples


# Example dataset
data("simulated_data")

candsplinevars <- c("X_1")
candbinaryvars <- paste0("Z_", 1:5)
candinter <- c(candsplinevars, candbinaryvars)

results <- rjMCMC(simulated_data, candsplinevars, candbinaryvars, candinter,
                  outcome = "Y", factor_var = "trt")


[Package fkbma version 0.2.0 Index]