sim_barfield: Simulate & test mediation methods as in Barfield et al....

View source: R/sim_barfield.R

sim_barfieldR Documentation

Simulate & test mediation methods as in Barfield et al. (2017)

Description

Simulate & test mediation methods as in Barfield et al. (2017). If multiple genes are simulated, only 1st is tested. For each simulation, count proportion of p-values < alpha, and at end calculate mean proportion.

Usage

sim_barfield(
  med.fnm,
  b1t2.v = c(0, 0.14, 0.39),
  t1 = 0.59,
  alpha = 0.05,
  nsamp = 50,
  nsim = 10^4,
  ngene = 0,
  seed = 0,
  verbose = TRUE,
  ...
)

Arguments

med.fnm

Quoted name of mediation function to test. The function must accept parameters and output matrix with mediation p-value in column "EMY.p", like hitman.

b1t2.v

Numeric vector of values that both theta2 ("t2") and beta1 ("b1") take.

t1

Numeric value of theta2 i.e. the effect of the exposure on the outcome.

alpha

Alpha level.

nsamp

Number of samples.

nsim

Number of simulations.

ngene

Number of genes other than that of primary interest to simulate.

seed

Random seed for reproducibility.

verbose

Logical; should the number of simulations be printed every 100 simulations?

...

Sent to med.fcn

Value

Matrix with proportion of significant calls for every combination of t2 and b1.

References

Barfield R, Shen J, Just AC, Vokonas PS, Schwartz J, Baccarelli AA, VanderWeele TJ, Lin X. Testing for the indirect effect under the null for genome-wide mediation analyses. Genet Epidemiol. 2017 Dec;41(8):824-833.


jdreyf/Hitman documentation built on April 12, 2025, 1:35 p.m.