Description Usage Arguments Details Value Note Author(s) References Examples
ivglm performs instrumental variable estimation of the causal exposure effect in
generalized linear models with individual-level data. Below, Z, X, and
Y are the instrument, the exposure, and the outcome, respectively.
L is a vector of covariates that we wish to control for in the analysis;
these would typically be confounders for the instrument and the outcome.
1 2 3 |
estmethod |
a string specifying the desired estimation method; either |
X |
a string specifying the name of the exposure X in |
Y |
a string specifying the name of the outcome Y in |
fitZ.L |
an object of class |
fitX.LZ |
an object of class |
fitX.L |
an object of class |
fitY.LX |
an object of class |
fitY.LZX |
an object of class |
data |
a data frame containing the variables in the model. The covariates, instrument,
exposure and outcome can have arbitrary names, e.g. they don't need to
be called |
formula |
an object of class |
ctrl |
logical. Should the control function R=X-\hat{X} be used when re-fitting
|
clusterid |
an optional string containing the name of a cluster identification variable when
data are clustered. Specifying |
link |
a string specifying the link function for the causal generalized linear model;
see ‘Details’. Either |
vcov.fit |
logical. Should the variance-covariance matrix be computed? |
... |
optional arguments passed on to the |
ivglm estimates the parameter ψ in the causal generalized linear model
η\{E(Y|L,Z,X)\}-η\{E(Y_0|L,Z,X)\}=m^T(L)Xψ.
Here, E(Y_0|L,Z,X) is counterfactual mean of the outcome,
had the exposure been set to 0. The link function
η is either the identity, log or logit link, as specified by
the link argument. The vector function m(L) contains interaction terms
between L and X. If estmethod="ts", then these are specified
implicitly through the model fitY.LX. If estmethod="g", then these
are specified explicitly through the formula argument.
If estmethod="ts", then two-stage estimation of ψ is performed.
In this case, the model fitX.LZ is used to construct predictions
\hat{X}=\hat{E}(X|L,Z). These predictions are subsequently used to re-fit
the model fitY.LX, with X replaced with \hat{X}. The obtained
coefficient(s) for \hat{X} in the re-fitted model is the two-stage estimator of ψ.
If estmethod="g", then G-estimation of ψ is performed. In this case,
the estimator is obtained as the solution to the estimating equation
H(ψ)=∑_{i=1}^n\hat{d}(L_i,Z_i)h_i(ψ)=0.
The function h_i(ψ) is defined as
h_i(ψ)=Y_i-m^T(L_i)ψ X_i
when link="identity",
h_i(ψ)=Y_i\textrm{exp}\{-m^T(L_i)ψ X_i\}
when link="log", and
h_i(ψ)=\textrm{expit}[\textrm{logit}\{\hat{E}(Y|L_i,Z_i,X_i)\}-m^T(L_i)ψ X_i]
when link="logit". In the latter, \hat{E}(Y|L_i,Z_i,X_i) is
an estimate of E(Y|L_i,Z_i,X_i) obtained from the model fitY.LZX.
The estimated function \hat{d}(L,Z) is chosen so that the true function
has conditional mean 0, given L; E\{d(L,Z)|L\}=0.
The specific form of \hat{d}(L,Z) is determined by the user-specified models.
If fitX.LZ and fitX.L are specified, then \hat{d}(L,Z)=m(L)\{\hat{E}(X|L,Z)-\hat{E}(X|L)\},
where \hat{E}(X|L,Z) and \hat{E}(X|L) are obtained from fitX.LZ
and fitX.L, respectively. If these are not specified, then \hat{d}(L,Z)=m(L)\{Z-\hat{E}(Z|L)\},
where \hat{E}(Z|L) is obtained from fitZ.L, which then must be specified.
ivglm returns an object of class "ivglm", which inherits from
class "ivmod". An object of class "ivglm" is a list containing
call |
the matched call. |
input |
|
est |
a vector containing the estimate of ψ. |
vcov |
the variance-covariance matrix for the estimate of ψ, obtained with the sandwich formula. |
estfunall |
a matrix of all subject-specific contributions to the estimating functions used in the estimation process.
One row for each subject, one column for each parameter. If |
d.estfun |
the jacobian matrix of |
converged |
logical. Was a solution found to the estimating equations? |
fitY.LX |
the re-fitted model |
ivglm allows for weights. However, these are defined implicitly
through the input models. Thus, when models are used as input to ivglm,
these models have to be fitted with the same weights. When estmethod="g"
the weights are taken from fitX.LZ, if specified by the user. If fitX.LZ is not
specified then the weights are taken from fitZ.L. Hence, if weights are used,
then either fitX.LZ or fitZ.L must be specified.
Arvid Sjolander.
Bowden J., Vansteelandt S. (2011). Mendelian randomization analysis of case-control data using structural mean models. Statistics in Medicine 30(6), 678-694.
Sjolander A., Martinussen T. (2019). Instrumental variable estimation with the R package ivtools. Epidemiologic Methods 8(1), 1-20.
Vansteelandt S., Bowden J., Babanezhad M., Goetghebeur E. (2011). On instrumental variables estimation of causal odds ratios. Statistical Science 26(3), 403-422.
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 | set.seed(9)
##Note: the parameter values in the examples below are chosen to make
##Y0 independent of Z, which is necessary for Z to be a valid instrument.
n <- 1000
psi0 <- 0.5
psi1 <- 0.2
##---Example 1: linear model and interaction between X and L---
L <- rnorm(n)
Z <- rnorm(n, mean=L)
X <- rnorm(n, mean=Z)
m0 <- X-Z+L
Y <- rnorm(n, mean=psi0*X+psi1*X*L+m0)
data <- data.frame(L, Z, X, Y)
#two-stage estimation
fitX.LZ <- glm(formula=X~Z, data=data)
fitY.LX <- glm(formula=Y~X+L+X*L, data=data)
fitIV <- ivglm(estmethod="ts", fitX.LZ=fitX.LZ, fitY.LX=fitY.LX, data=data,
ctrl=TRUE)
summary(fitIV)
#G-estimation with model for Z
fitZ.L <- glm(formula=Z~L, data=data)
fitIV <- ivglm(estmethod="g", X="X", Y="Y", fitZ.L=fitZ.L, data=data,
formula=~L, link="identity")
summary(fitIV)
#G-estimation with model for X
fitX.LZ <- glm(formula=X~L+Z, data=data)
fitX.L <- glm(formula=X~L, data=data)
fitIV <- ivglm(estmethod="g", Y="Y", fitX.LZ=fitX.LZ, fitX.L=fitX.L, data=data,
formula=~L, link="identity")
summary(fitIV)
##---Example 2: logistic model and no covariates---
Z <- rbinom(n, 1, 0.5)
X <- rbinom(n, 1, 0.7*Z+0.2*(1-Z))
m0 <- plogis(1+0.8*X-0.39*Z)
Y <- rbinom(n, 1, plogis(psi0*X+log(m0/(1-m0))))
data <- data.frame(Z, X, Y)
#two-stage estimation
fitX.LZ <- glm(formula=X~Z, family="binomial", data=data)
fitY.LX <- glm(formula=Y~X, family="binomial", data=data)
fitIV <- ivglm(estmethod="ts", fitX.LZ=fitX.LZ, fitY.LX=fitY.LX, data=data,
ctrl=TRUE)
summary(fitIV)
#G-estimation with model for Z
fitZ.L <- glm(formula=Z~1, data=data)
fitY.LZX <- glm(formula=Y~X+Z+X*Z, family="binomial", data=data)
fitIV <- ivglm(estmethod="g", X="X", fitZ.L=fitZ.L, fitY.LZX=fitY.LZX,
data=data, link="logit")
summary(fitIV)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.