Skip to contents

Performs a single chain execution in the Metropolis-Hastings algorithm for Bayesian inference, specifically tailored for cancer risk estimation. This function can handle both sex-specific and non-sex-specific scenarios.

Usage

mhChain(
  seed,
  n_iter,
  burn_in,
  chain_id,
  ncores,
  data,
  twins,
  max_age,
  baseline_data,
  prior_distributions,
  prev,
  median_max,
  BaselineNC,
  var,
  age_imputation,
  imp_interval,
  remove_proband,
  sex_specific
)

Arguments

seed

Integer, the seed for the random number generator to ensure reproducibility.

n_iter

Integer, the number of iterations to perform in the Metropolis-Hastings algorithm.

burn_in

Integer, the number of initial iterations to discard (burn-in period).

chain_id

Integer, the identifier for the chain being executed.

ncores

Integer, the number of cores to use for parallel computation.

data

Data frame, containing family and genetic information used in the analysis.

twins

Information on monozygous twins or triplets in the pedigrees.

max_age

Integer, the maximum age considered in the analysis.

baseline_data

Numeric matrix or vector, containing baseline risk estimates for different ages and sexes.

prior_distributions

List, containing prior distributions for the parameters being estimated.

prev

Numeric, the prevalence of the risk allele in the population.

median_max

Logical, indicates if the maximum median age should be used for the Weibull distribution.

BaselineNC

Logical, indicates if non-carrier penetrance should be based on SEER data.

var

Numeric, the variance for the proposal distribution in the Metropolis-Hastings algorithm.

age_imputation

Logical, indicates if age imputation should be performed.

imp_interval

Integer, the interval at which age imputation should be performed when age_imputation = TRUE.

remove_proband

Logical, indicates if the proband should be removed from the analysis.

sex_specific

Logical, indicates if the analysis should differentiate by sex.

Value

A list containing samples, log likelihoods, log-acceptance ratio, and rejection rate for each iteration.