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.
cmf(x, M, y, decisionFunction = "prodcoef", nStarts = 1000,
nCores = "auto", cutoff = 0.5, maxIter = 25, stableLag = 5,
pb = TRUE, ...)
exogenous variable; numeric vector or data frame with x, y, and at least one M column
potential mediators; data frame with column names
outcome variable; numeric vector
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)
how many times to start the algorithm
how many threads (cores) to use for parallel processing
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
.
the maximum number of iterations for each start
how long does the selection need to be stable before deciding the algorithm has converged
Whether to display a progress bar (default TRUE). Only available with built-in decision functions
parameters passed to decisionFunction
an object of class cmf
. See cmf-methods
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)
# NOT RUN {
# generate some data
dat <- generateMed(a = (1:10)/20, b = (1:10)/20)
# Run CMF on this data
cmf(dat)
# }
Run the code above in your browser using DataLab