Learn R Programming

doseSens (version 1.0.0)

max_expectation: A function to compute a conservative upper bound on the worst-case expectation under the sharp null

Description

A function to compute a conservative upper bound on the worst-case expectation under the sharp null

Usage

max_expectation(z, gamma, f_pi, with_variance = FALSE)

Value

a list containing the worst-case expectation, and/or variance and the solution to the optimization problem.

Arguments

z

vector of doses of length n

gamma

The nonnegative sensitivity parameter; gamma = 0 means no unmeasured confounding.

f_pi

a vector of length n! that contains the value of the test statistic under each of the n! permutations of z, with order of f_pi determined by first sorting z into increasing order and calling gtools::permutations on z.

with_variance

whether to return the variance along with the worst-case expectation, default is FALSE.

Examples

Run this code
# A vector of observed doses
doses <- c(0, 0.1, 0.4, 0.8)
# values of test statistic under 4! permutations
values <- c(1, 0.5, 0.3, 0.8, 1, 0.7)
upper_bound <- max_expectation(z = doses, gamma = 1, f_pi = values)

Run the code above in your browser using DataLab