cmf: Coordinate-wise Mediation Filter

View source: R/cmf.R

cmfR Documentation

Coordinate-wise Mediation Filter

Description

This function performs CMF on a set of potential mediators, given an input and an output variable. It selects those mediators that are deemed relevant by a default or a user-defined decision function, *conditional* on the other mediators in the model. By doing this cyclically, and with multiple random starts, the algorithm outputs an estimate of the best mediators.

Usage

cmf(
  x,
  M,
  y,
  decisionFunction = "prodcoef",
  nStarts = 1000,
  nCores = 2,
  cutoff = 0.5,
  maxIter = 25,
  stableLag = 5,
  pb = TRUE,
  ...
)

Arguments

x

exogenous variable; numeric vector or data frame with x, y, and at least one M column

M

potential mediators; data frame with column names

y

outcome variable; numeric vector

decisionFunction

either a function with as inputs x, m, y, parameters, and as output a TRUE (include) or FALSE (exclude) statement or a string indicating the built-in decision function to use (see details)

nStarts

how many times to start the algorithm

nCores

how many threads (cores) to use for parallel processing (default 2)

cutoff

a cutoff value for selection: variables are selected if they display a selection rate higher than this value. Only relevant when multiple starts are specified. Can also be specified post-hoc using setCutoff.

maxIter

the maximum number of iterations for each start

stableLag

how long does the selection need to be stable before deciding the algorithm has converged

pb

Whether to display a progress bar (default TRUE). Only available with built-in decision functions

...

parameters passed to decisionFunction

Details

Available decision functions. These functions are implemented in C++ to speed up computation. Between brackets the additional parameter that may be passed to the function in the ... argument of this function. (arguments = defaultvalue):

- prodcoef (p.value = 0.1): Test for the product of coefficients, Sobel test

- causalsteps (p.value = 0.1): Causal steps test min(Ta, Tb)

Value

an object of class cmf. See cmf-methods

Examples

# generate some data
dat <- generateMed(a = (1:10)/20, b = (1:10)/20)
# Run CMF on this data
cmf(dat)


vankesteren/cmfilter documentation built on April 6, 2023, 3:40 a.m.