sensmediation: Estimate natural direct and indirect effects based on...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Function to estimate the natural direct and indirect effects based on parametric regression models. Standard errors for the effects are calculated using the delta method. The function also gives sensitivity analysis results for unobserved confounding. Implements methods introduced in Lindmark, de Luna and Eriksson (2018).

Usage

1
2
3
4
5
sensmediation(med.model, out.model, exp.model = NULL, exp.name = NULL,
  med.name = NULL, type = "my", Rho = 0, progress = TRUE,
  conf.level = 0.95, covariates = NULL, alt.decomposition = FALSE,
  control.value = 0, exp.value = 1, covariance = NULL,
  med.full = NULL, out.full = NULL, all.interactions = NULL, ...)

Arguments

med.model

Fitted glm model object representing the mediator model at the basis of the estimation (see Details for more information).

out.model

Fitted glm model object representing the outcome model at the basis of the estimation (see Details for more information).

exp.model

Fitted glm model object representing the exposure model. Should be provided if type="zm" or type="zy".

exp.name

A character string indicating the name of the exposure variable used in the models. Needs to match the name of the exposure found in the output from the fitted glm-models (this is especially important to check for exposures of class factor).

med.name

A character string indicating the name of the mediator used in the models. Needs to match the name of the mediator found in the output from the outcome glm-model (this is especially important to check for mediators of class factor).

type

the type of confounding for which the sensitivity analysis is to be performed. type="my", the default, corresponds to unobserved mediator-outcome confounding, type="zm" to exposure-mediator confounding and type="zy" to exposure-outcome confounding.

Rho

The sensitivity parameter vector. If type="my" the correlation between the error terms in the mediator and outcome models. If type="zm" the correlation between the error terms in the exposure and mediator models. If type="zy" the correlation between the error terms in the exposure and outcome models.

progress

Logical, indicating whether or not the progress (i.e. the proc.time for each Rho) of the optimization will be output

conf.level

the confidence level to be used for confidence intervals and uncertainty intervals.

covariates

if conditional effects are to be estimated the named list of covariate values (see Details). Covariates not specified are marginalized over.

alt.decomposition

logical indicating whether or not alternative definitions of the direct and indirect effects should be used (see Details).

control.value

value of the exposure variable used as the control (unexposed) condition, default is 0.

exp.value

value of the exposure variable used as the exposure condition, default is 1.

covariance, med.full, out.full, all.interactions

arguments used in previous versions of the package that are now deprecated.

...

Additional arguments to be passed on to the maxLik function. Can be used to set the method and control arguments of the maxLik function (see coefs.sensmed).

Details

To obtain the ML estimates of the regression parameters used to calculate mediation effects and perform sensitivity analysis sensmediation calls coefs.sensmed. The maximization of the log-likelihood is performed using maxLik, the default is to use the Newton-Raphson method and an analytic gradient and Hessian.

The mediator and outcome models (and exposure model for type = "zm" or "zy") should be fitted using glm and can be of two types, probit models (family = binomial(link = 'probit')) for binary mediators or outcomes (exposures) and linear regression models (family = gaussian) for continuous mediators or outcomes (exposures). The outcome model may contain exposure-mediator, exposure-covariate, mediator-covariate and exposure-mediator-covariate interactions. The mediator model may contain exposure-covariate interactions. All models may also contain interactions between covariates. Note, however that interactions may not be included in a model without also including the main effects of the interacting variables. That is, interactions should be specified either as X1*X2 or X1 + X2 + X1:X2, not as X1:X2 alone.

To obtain results conditional on specific covariate values, these values should be provided through the covariates argument as a named list (see Examples). The effects will be averaged over covariates not specified in the list.

The total effect can be decomposed into a direct and indirect effect in different ways. Let z be the exposure value and z* the control (unexposed) value. The default is to give the decomposition into the "pure direct effect" E(Y(z,M(z*)))-E(Y(z*,M(z*))) (here denoted NDE) and the "total indirect effect" E(Y(z,M(z)))-E(Y(z,M(z*))) (denoted NIE). Setting alt.decomposition=TRUE instead gives the decomposition into the "total direct effect" E(Y(z,M(z)))-E(Y(z*,M(z))) (here denoted NDE*) and "pure indirect effect" E(Y(z*,M(z)))-E(Y(z*,M(z*))) (denoted NIE*).

Standard errors for the effects are calculated using the delta method. Confidence intervals (CI) for (and p-values for tests of) the natural direct and indirect effects for each value of the sensitivity parameter are constructed based on a normal approximation. Uncertainty intervals (UI) are constructed as the union of all CIs over the sensitivity parameter vector.

Value

sensmediation returns an object of class "effectsMed".

The function summary (summary.effectsMed) gives a summary of the results in the form of a table with the estimated effects and results of the sensitivity analysis. The function plot (plot.effectsMed) plots the estimated natural indirect or direct effects with confidence intervals over the range of the sensitivity parameter.

call

The matched call

Rho

The sensitivity parameter vector.

type

character, the type of confounding the sensitivity analysis is performed for.

coefs.sensmed

a list with the output from coefs.sensmed

NIE

matrix with the estimated NIEs (or NIE*s if alt.decomposition=TRUE) over the range of the sensitivity parameter Rho.

NDE

matrix with the estimated NDEs (or NDE*s if alt.decomposition=TRUE) over the range of the sensitivity parameter Rho.

std.errs

list with the standard errors of the NIE (NIE*), NDE (NDE*) and total effect over the range of the sensitivity parameter Rho.

CI

a list with the confidence intervals of the NIE (NIE*), NDE (NDE*) and total effect over the range of the sensitivity parameter Rho.

UI

matrix with the uncertainty intervals for the NIE (NIE*) and NDE (NDE*) over the range of the sensitivity parameter Rho.

conf.level

numeric, the confidence level used for confidence intervals and uncertainty intervals.

covariates

list of the covariate values that the effects are conditioned on.

exp.name

character vector containing the name of the exposure variable.

med.name

character vector containing the name of the mediator variable.

exp.value

value of the exposure variable used as the exposure condition.

control.value

value of the exposure variable used as the control (unexposed) condition.

alt.decomposition

logical, indicating whether the alternative definitions of the direct and indirect effects have been used

med.model

the mediator model input.

out.model

the outcome model input.

betas

list of the estimated mediator model parameters over Rho, with

  • beta0 Intercept

  • beta1 Exposure

  • beta2 Covariates

  • beta3 Exposure-covariate interactions

Components that are not included in the input mediator model are set to 0.

thetas

list of the estimated outcome model parameters over Rho, with

  • theta0 Intercept

  • theta1 Exposure

  • theta2 Mediator

  • theta3 Exposure-mediator interaction

  • theta4 Covariates

  • theta5 Exposure-covariate interactions

  • theta6 Mediator-covariate interactions

  • theta7 Exposure-mediator-covariate interactions

Components that are not included in the input outcome model are set to 0.

part.deriv

List with the partial derivatives of the NDE (Lambda), NIE (Gamma) and TE (Eta) wrt the mediator and outcome model parameters for each value of Rho. See partdevs.

sigma.thetabeta

a list with the joint covariance matrix of the outcome and mediator model parameters for each value of Rho. Note that the covariance matrix is constructed for all estimated parameters listed in betas and thetas but that components not included in the input mediator and outcome models are set to 0.

Author(s)

Anita Lindmark

References

Lindmark, A., de Luna, X., Eriksson, M. (2018) Sensitivity Analysis for Unobserved Confounding of Direct and Indirect Effects Using Uncertainty Intervals, Statistics in Medicine, 37(10), pp 1744–1762.

See Also

more.effects which can be used to calculate additional direct and indirect effects with sensitivity analysis using the same sensitivity parameter without running the optimization again.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Example with data from Riksstroke (the Swedish stroke register)

data(RSdata)

# Probit mediator and outcome models:
m.model <- glm(lowered.consc ~ AF + age.cat + sex, data = RSdata,
   family = binomial(link = 'probit'))
o.model <- glm(cf.3mo ~ AF + lowered.consc + age.cat + sex, data = RSdata,
   family = binomial(link = 'probit'))

# Estimation of NIE, NDE and sensitivity analyses to mediator-outcome confounding:
# (note that the name of the exposure is "AF1" to match the name in coef(out.model))
sensmed <- sensmediation(m.model, o.model, exp.name = "AF1", med.name = "lowered.consc",
   Rho = c(0, 0.1))
summary(sensmed)
plot(sensmed)
plot(sensmed, effect = "direct")

## Not run: 
# Conditional effects and sensitivity analysis to mediator-outcome confounding using
# more.effects():
sensmed.cond <- more.effects(sensmed.object = sensmed,
   covariates = list(sex = 1, age.cat = "70-79"))
summary(sensmed.cond)

## End(Not run)

## Not run: 
## Sensitivity analysis to exposure-mediator confounding:
  e.model <- glm(AF ~ age.cat + sex, data = RSdata,
     family = binomial(link = 'probit'))

  sensmed.zm <- sensmediation(med.model = m.model, out.model = o.model,
     exp.model = e.model, type = "zm", Rho = seq(0, 0.5, 0.1), exp.name = "AF1",
     med.name = "lowered.consc")

  summary(sensmed.zm)

## End(Not run)

## Not run: 
# Additional effects using more.effects:
# Results with conf.level = 0.99:
sensmed.zm.99 <- more.effects(sensmed.object = sensmed.zm, conf.level = 0.99)
summary(sensmed.zm.99)

## End(Not run)

## Not run: 
# Examples with simulated data, continuous exposure:

require(mvtnorm)

n <- 1000
set.seed(102677)

x <- rnorm(n)
z <- -0.5 + 0.1*x + rnorm(n)
R <- 0.5
Sigma <- cbind(c(1,R), c(R,1))
epsilon <- rmvnorm(n, sigma = Sigma)
m <- -1.2 + 0.8*z + 0.13*x + epsilon[,1]
y <- -1 + 0.05*z + 3*m + 0.5*x + epsilon[,2]

# Models:
z.model <- glm(z ~ x)
m.model2 <- glm(m ~ z + x)
y.model <- glm(y ~ z + m + x)

## Estimation of NIE, NDE. Note that the exposure condition is 2
## so effects are calculated for a 2 unit increase of the exposure:
eff.contz <- sensmediation(med.model = m.model2, out.model = y.model,
           exp.name = "z", med.name = "m", control.value = 0, exp.value = 2)
summary(eff.contz)

## End(Not run)

sensmediation documentation built on June 3, 2019, 9:02 a.m.