causalNullTest: Nonparametric test of flatness of a causal dose-response...

View source: R/causal.null.test.R

causalNullTestR Documentation

Nonparametric test of flatness of a causal dose-response curve under exogeneity

Description

This function performs a hypothesis test that the causal dose-response curve theta(a) is flat on the support of the observed exposure A. The exposure may be discrete, continuous, or an arbitrary mixture of discrete and continuous components. See the accompanying paper Westling (2020) for details.

Usage

causalNullTest(Y, A, W, p = 2, control = list())

Arguments

Y

n x 1 numeric vector of observed outcome values.

A

n x 1 numeric vector of exposure values.

W

n x p data.frame of potential confounders.

p

vector of exponents to use in the norm of Omega. Defaults to 2.

control

Optional list of control parameters. See causalNullTest.control for details.

Value

causalNullTest returns a named list with the following elements:

test

A data.frame containing columns p (the exponent in the Lp norm used in the test), obs.stat (the observed Lp norm of the primitive Omega), p.val (the p-value corresponding to the test), ci.ll (the lower confidence limit corresponding to the Lp norm of the primitive), and ci.ul (the upper confidence limit corresponding to the Lp norm of the primitive).

control

Controls used in fitting.

If If control$return.Omega == TRUE, the following elements are also included in the output: list(Omega.hat = data.frame(a=a.vals, Omega.hat), IF.vals = IF.vals, paths = paths))

Omega.hat

A data.frame with values of a and the corresponding estimated function Omega.hat(a).

IF.vals

n x m matrix of influence function values of Omega.hat at every unique sorted value of the exposure. Each column is the influence function for a separate value of a, the values of which can be found in Omega.hat.

paths

control$n.sim x m matrix of simulated paths from the limiting Gaussian process. Each row is an independent simulated path along the values of a.

If save.nuis.fits = TRUE, then the following elements are also included in the output:

mu.hat

The estimated outcome regression function, as a list of fits if control$cross.fit = TRUE.

g.hat

The estimated propensity, possibly as a list of fits if control$cross.fit = TRUE.

Examples

# Sample data
n <- 1000
W <- data.frame(W1 = runif(n))
Z <- rbinom(n, size = 1, prob = 1/(1 + exp(2-W$W1)))
A <- (1-Z) * rnorm(n, mean = W$W1, sd = abs(1 + W$W1))
Y <- rexp(n, rate = 1+abs(W$W1 * A))
causalNullTest(Y, A, W, p = c(1,2,Inf), control = list(cross.fit = FALSE, verbose=TRUE, g.n.bins = 2:5))

tedwestling/ctsCausal documentation built on Dec. 7, 2022, 3:33 p.m.