Description Usage Arguments Details Value Author(s) References Examples
estfun
computes the estimating function H(ψ)
for a "ivmod"
object, fitted with estmethod="g"
,
for a range of values of ψ. The estfun
is not implemented
for "ivah"
objects, since G-estimation in additive hazards models
is based on a recursive estimation technique, and not standard estimating equations.
1 |
object |
an object of class |
lower |
an optional vector of lower values for ψ. Defaults to ψ-0.5. |
upper |
an optional vector of upper values for ψ. Defaults to ψ+0.5. |
step |
an optional vector of steps between |
estfun
may be useful for visual inspection of the estimating
function, to make sure that a solution to the estimating equation
H(ψ)=0
was found, see ‘Examples’. For the i:th element of ψ, the estimating
function sum is computed for a range of values within (lower[i]
, upper[i]
), at the
G-estimate of the remaining elements of ψ.
An object of class "estfun"
is a list containing
f |
a named list of matricies; one matrix for each element of ψ. The first column of the i:th matrix contains the values for the i:th element of ψ at which the estimating function sum is computed, the second column contains the values of the estimating function sum. |
est |
the G-estimate of ψ. |
Arvid Sjolander.
Burgess S, Granell R, Palmer TM, Sterne JA, Didelez V. (2014). Lack of identification in semiparametric instrumental variable models with binary outcomes. American Journal of Epidemiology 180(1), 111-119.
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 | 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)
#G-estimation
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)
H <- estfun(fitIV)
plot(H)
##---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)
#G-estimation
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)
H <- estfun(fitIV)
plot(H)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.