medlateweight {causalweight} | R Documentation |
Causal mediation analysis with instruments for treatment and mediator based on weighting
Description
Causal mediation analysis (evaluation of natural direct and indirect effects) with instruments for a binary treatment and a continuous mediator based on weighting as suggested in Frölich and Huber (2017), Theorem 1.
Usage
medlateweight(
y,
d,
m,
zd,
zm,
x,
trim = 0.1,
csquared = FALSE,
boot = 1999,
cminobs = 40,
bwreg = NULL,
bwm = NULL,
logit = FALSE,
cluster = NULL
)
Arguments
y |
Dependent variable, must not contain missings. |
d |
Treatment, must be binary (either 1 or 0), must not contain missings. |
m |
Mediator(s),must be a continuous scalar, must not contain missings. |
zd |
Instrument for the treatment, must be binary (either 1 or 0), must not contain missings. |
zm |
Instrument for the mediator, must contain at least one continuous element, may be a scalar or a vector, must not contain missings. If no user-specified bandwidth is provided for the regressors when estimating the conditional cumulative distribution function F(M|Z2,X), i.e. if |
x |
Pre-treatment confounders, may be a scalar or a vector, must not contain missings. If no user-specified bandwidth is provided for the regressors when estimating the conditional cumulative distribution function F(M|Z2,X), i.e. if |
trim |
Trimming rule for discarding observations with extreme weights. Discards observations whose relative weight would exceed the value in |
csquared |
If TRUE, then not only the control function C, but also its square is used as regressor in any estimated function that conditions on C. Default is FALSE. |
boot |
Number of bootstrap replications for estimating standard errors. Default is 1999. |
cminobs |
Minimum number of observations to compute the control function C, see the numerator of equation (7) in Frölich and Huber (2017). A larger value increases boundary bias when estimating the control function for lower values of M, but reduces the variance. Default is 40, but should be adapted to sample size and the number of variables in Z2 and X. |
bwreg |
Bandwidths for |
bwm |
Bandwidth for |
logit |
If FALSE, probit regression is used for any propensity score estimation. If TRUE, logit regression is used. Default is FALSE. |
cluster |
A cluster ID for block or cluster bootstrapping when units are clustered rather than iid. Must be numerical. Default is NULL (standard bootstrap without clustering). |
Details
Estimation of causal mechanisms (natural direct and indirect effects) of a binary treatment among treatment compliers based on distinct instruments for the treatment and the mediator. The treatment and its instrument are assumed to be binary, while the mediator and its instrument are assumed to be continuous, see Theorem 1 in Frölich and Huber (2017). The instruments are assumed to be conditionally valid given a set of observed confounders. A control function is used to tackle mediator endogeneity. Standard errors are obtained by bootstrapping the effects.
Value
A medlateweight object contains two components, results
and ntrimmed
:
results
: a 3x7 matrix containing the effect estimates in the first row ("effects"), standard errors in the second row ("se"), and p-values in the third row ("p-value").
The first column provides the total effect, namely the local average treatment effect (LATE) on the compliers.
The second and third columns provide the direct effects under treatment and control, respectively ("dir.treat", "dir.control").
The fourth and fifth columns provide the indirect effects under treatment and control, respectively ("indir.treat", "indir.control").
The sixth and seventh columns provide the parametric direct and indirect effect estimates ("dir.para", "indir.para") without intercation terms, respectively. For the parametric estimates, probit or logit specifications are used for the treatment model and OLS specifications for the mediator and outcome models.
ntrimmed
: number of discarded (trimmed) observations due to large weights.
References
Frölich, M. and Huber, M. (2017): "Direct and indirect treatment effects: Causal chains and mediation analysis with instrumental variables", Journal of the Royal Statistical Society Series B, 79, 1645–1666.
Examples
# A little example with simulated data (3000 observations)
## Not run:
n=3000; sigma=matrix(c(1,0.5,0.5,0.5,1,0.5,0.5,0.5,1),3,3)
e=(rmvnorm(n,rep(0,3),sigma))
x=rnorm(n)
zd=(0.5*x+rnorm(n)>0)*1
d=(-1+0.5*x+2*zd+e[,3]>0)
zm=0.5*x+rnorm(n)
m=(0.5*x+2*zm+0.5*d+e[,2])
y=0.5*x+d+m+e[,1]
# The true direct and indirect effects on compliers are equal to 1 and 0.5, respectively
medlateweight(y,d,m,zd,zm,x,trim=0.1,csquared=FALSE,boot=19,cminobs=40,
bwreg=NULL,bwm=NULL,logit=FALSE)
## End(Not run)