wald_test.drtmle: Wald tests for drtmle objects

View source: R/test.R

wald_test.drtmleR Documentation

Wald tests for drtmle objects

Description

Wald tests for drtmle objects

Usage

## S3 method for class 'drtmle'
wald_test(object, est = c("drtmle"), null = 0, contrast = NULL, ...)

Arguments

object

An object of class "drtmle"

est

A vector indicating for which estimators to return a confidence interval. Possible estimators include the TMLE with doubly robust inference ("drtmle", recommended), the AIPTW with additional correction for misspecification ("aiptw_c", not recommended), the standard TMLE ("tmle", recommended only for comparison to "drtmle"), the standard AIPTW ("aiptw", recommended only for comparison to "drtmle"), and G-computation ("gcomp", not recommended).

null

The null hypothesis value.

contrast

This option specifies what parameter to return confidence intervals for. If contrast=NULL, then test the null hypothesis that the covariate-adjusted marginal means equal the value(s) specified in null. contrast can also be a numeric vector of ones, negative ones, and zeros to define linear combinations of the various means (e.g., to estimate an average treatment effect, see examples). In this case, we test the null hypothesis that the linear combination of means equals the value specified in null. contrast can also be a list with named functions f, h, and fh_grad. The function f takes as input argument eff and specifies which transformation of the effect measure to test. The function h defines the contrast to be estimated and should take as input est, a vector of the same length as object$a_0, and output the desired contrast. The function fh_grad is the gradient of the function h(f()). The function computes a test of the null hypothesis that h(f(object$est)) = null. See examples.

...

Other options (not currently used).

Value

An object of class "ci.drtmle" with point estimates and confidence intervals of the specified level.

Examples

# load super learner
library(SuperLearner)
# simulate data
set.seed(123456)
n <- 100
W <- data.frame(W1 = runif(n), W2 = rnorm(n))
A <- rbinom(n, 1, plogis(W$W1 - W$W2))
Y <- rbinom(n, 1, plogis(W$W1 * W$W2 * A))
# fit drtmle with maxIter = 1 so runs fast
fit1 <- drtmle(
  W = W, A = A, Y = Y, a_0 = c(1, 0),
  family = binomial(),
  stratify = FALSE,
  SL_Q = c("SL.glm", "SL.mean", "SL.glm.interaction"),
  SL_g = c("SL.glm", "SL.mean", "SL.glm.interaction"),
  SL_Qr = "SL.glm",
  SL_gr = "SL.glm", maxIter = 1
)
# get hypothesis test that each mean = 0.5
test_mean <- wald_test(fit1, null = 0.5)

# get test that ATE = 0
test_ATE <- wald_test(fit1, null = 0, contrast = c(1, -1))

# get test that risk ratio = 1, computing test on log scale
myContrast <- list(
  f = function(eff) {
    log(eff)
  },
  f_inv = function(eff) {
    exp(eff)
  },
  h = function(est) {
    est[1] / est[2]
  },
  fh_grad = function(est) {
    c(1 / est[1], -1 / est[2])
  }
)
test_RR <- wald_test(fit1, contrast = myContrast, null = 1)
#

benkeser/drtmle documentation built on Jan. 6, 2023, 11:40 a.m.