tmle_exposed | R Documentation |
The tmle_exposed
is a Targeted Minumum-loss based
estimator (TMLE) that can be used to estimate effects of interventions
targeting an intermediate factor among the exposed. The intermediate factor
(Z) is an effect of the exposure (A) and a cause of the outcome (Y), A -> Z ->
Y. According to the intervention of interest, different parameters and
estimators can be chosen using intervention
. If
intervention='unexposed'
, which is the default, then the estimated
parameter is the expected change in outcome risk among the exposed (A=1) if
hypothetically the exposed had the same probability of the intermediate (Z)
variable as the unexposed (A=0). Other parameteres can be estimated by setting
intervention
to a number between 0 and 1. If intervention=1
,
then the estimated parameter is the expected outcome risk among the exposed
(A=1) if all exposed received the intermediate variable (Z).
intervention
can be fixed to any probability of interest, for example
if intervention=0.6
, then the estimated parameter would be the expected
outcome risk among the exposed (A=1) if all exposed had 60
intermediate variable (Z). Regardless of which intervention
is chosen,
the expected outcome risk under intervention is compared to the outcome risk
among the exposed when the distribution of the intermediate variable was set
to the observed level among the exposed. Importantly, for this estimator the
exposure, intermediate variable, and outcome must all be binary. The
underlying model for the exposure, intermediate, and outcome, which are needed
to estimate any of the parameters, can be modelled using Super learning. Super
learning can be used to produce a weighted combination of candidate algorithms
that optimize the cross-validated loss-function or to select the single best
perfoming algorithm among the candidate algorithms, also known as the discrete
Super learner. One must define a library of candidate algortihms which should
be considered by the Super learner. If the Super learner library contains only
one algorithm, results will be estimated based on this algorithm alone, and
thus, not using Super Learning.
tmle_exposed(data, intervention='unexposed', discrete.SL=TRUE,
exposure.A=NA, intermediate.Z=NA, outcome.Y=NA, cov.A, cov.Z, cov.Y,
SL.lib.A=FALSE, SL.lib.Z=FALSE, SL.lib.Y=FALSE, iterations=10)
data |
A data frame/data table with a binary exposure, a binary intermediate variable, a binary outcome, and covariates. |
intervention |
Either the character string |
discrete.SL |
If |
exposure.A |
Name of the binary exposure. |
intermediate.Z |
Name of the binary intermediate variable, which is the target of the hypothetical intervention. |
outcome.Y |
Name of the binary outcome. |
cov.A |
A vector containing names of possible confounders which should be included in models of the exposure. |
cov.Z |
A vector of confounders which should be included in models of the intermediate. Do not include the exposure as the function does this. |
cov.Y |
A vector of confounders which should be included in models of the outcome. Do not include the exposure and the intermediate as the function does this. |
SL.lib.A |
A vector of algorithms that should be considered by the super learner when modelling the exposure. All algorithms must be specified as Super Learner objects. |
SL.lib.Z |
A vector of algorithms for modelling the intermediate. All algorithms must be specified as Super Learner objects. |
SL.lib.Y |
A vector of algorithms for modelling the outcome. All algorithms must be specified as Super Learner objects. |
iterations |
Number of iterations for the updating step in TMLE. Defaults to 10. |
The structure of the data should be as follows: \item For the binary
exposure (exposure.A
) 1 = exposed and 0 = unexposed. \item For the
binary intermediate variable (intermediate.Z
) 1 = treatment and 0 = no
treatment. \item For the binary outcome (outcome.Y
) 1 = event and 0 =
no event.
The function outputs the absolute outcome risk among the exposed under a hypothetical intervention ('unexposed' or fixed chance of intermediate) (psi0 or psi0star), the absolute outcome risk among the exposed under no intervention, where the probability of the intermediate variable is as observed (psi1), and the absolute risk difference between the two (psi or psistar) along with the standard errors for psi0/psi0star, psi1, and psi/psistar.
Amalie Lykkemark Moller amalielykkemark@live.dk Helene Charlotte Wiese Rytgaard, Thomas Alexander Gerds, and Christian Torp-Pedersen
library(data.table)
require(tmleExposed)
n=5000
set.seed(1)
sex <- rbinom(n,1,0.4)
age <- rnorm(n,65,sd=5)
disease <- rbinom(n,1,0.6)
A <- rbinom(n, 1, plogis(-3+0.05*age+1*sex))
Z <- rbinom(n, 1, plogis(5-0.08*age+1*sex-1.2*disease-0.8*A+0.01*A*disease))
Y <- rbinom(n, 1, plogis(-9+0.09*age+0.5*sex+0.8*disease-1.2*Z+0.7*A))
d <- data.table(id=1:n, exposure=as.integer(A), intermediate=as.integer(Z),
outcome=as.integer(Y), age, sex, disease)
##### Define algorithms for the Super Learner library #####
lib = c('SL.glm','SL.step.interaction')
#intervention: changing probability of the intermediate (Z=1) among the exposed (A=1)
#to what it would have been had they been unexposed (A=0).
#target parameter: the change in outcome among the exposed (A=1) had their chance of
#the intermediate (Z=1) been as among the unexposed (A=0).
res<-tmle_exposed(data=d,
intervention = 'unexposed',
exposure.A='exposure',
intermediate.Z='intermediate',
outcome.Y='outcome',
cov.A=c('sex','age'),
cov.Z =c('sex','age','disease'),
cov.Y=c('sex','age','disease'),
SL.lib.A = lib,
SL.lib.Z = lib,
SL.lib.Y = lib,
discrete.SL = FALSE)
summary(res)
#intervention: all exposed (A=1) receives the intermediate (Z=1).
#target parameter: the change in outcome among the exposed had all
#exposed received the intermediate (Z=1).
tmle_exposed(data=d,
intervention = 1,
exposure.A='exposure',
intermediate.Z='intermediate',
outcome.Y='outcome',
cov.A=c('sex','age'),
cov.Z =c('sex','age','disease'),
cov.Y=c('sex','age','disease'),
SL.lib.A = lib,
SL.lib.Z = lib,
SL.lib.Y = lib,
discrete.SL = FALSE)
#intervention: all exposed (A=1) had 60% chance of reciving
#the intermediate (Z=1).
#target parameter: the change in outcome among the exposed had
#60% exposed received the intermediate (Z=1).
tmle_exposed(data=d,
intervention = 0.6,
exposure.A='exposure',
intermediate.Z='intermediate',
outcome.Y='outcome',
cov.A=c('sex','age'),
cov.Z =c('sex','age','disease'),
cov.Y=c('sex','age','disease'),
SL.lib.A = lib,
SL.lib.Z = lib,
SL.lib.Y = lib,
discrete.SL = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.