ComputeEffectxx: Computes direct, indirect, or total effects of xx

View source: R/compute_effects.R

ComputeEffectxxR Documentation

Computes direct, indirect, or total effects of xx

Description

ComputeEffectxx computes either direct, indirect, or total effect of each xx variable on response y when transition x from xp to xpp.

Usage

ComputeEffectxx(dat, fit, effect, xp = 0, xpp = 1, risk_scale = NULL,
  mmn = FALSE, rmean = NULL)

Arguments

dat

List containing data (see SimulateData for format)

fit

List with path coefficients.

effect

Either 'direct', 'indirect', or 'total'

xp

The initial value of x.

xpp

The new value of x.

risk_scale

Either 'diff' (for risk difference) or 'ratio' (for odds). see details for more information.

mmn

Should gene set network be simulated. If FALSE assume conditionally independent mediators.

Value

Vector of effects.

Examples

params <- SimpleSim()
dat <- SimulateData(params)
fit <- ComputePath(dat)
d <- ComputeEffectxx(dat,fit,"direct")
i <- ComputeEffectxx(dat,fit,"indirect")
to <- ComputeEffectxx(dat,fit,"total")
## effects computed by estimating integrals
print(c(d,i,to))
## effects using model linearity assumption
ComputeEffectsLinear(fit) ## based on sample
## exact effects using simulation coefficients
ComputeEffectsLinear(params) ## exact

longjp/mediateR documentation built on May 24, 2023, 12:30 p.m.