Learn R Programming

doseSens (version 1.0.0)

weak_null_test: Asymptotic sensitivity analysis for weak nulls with continuous exposures.

Description

Asymptotic sensitivity analysis for weak nulls with continuous exposures.

Usage

weak_null_test(
  Z,
  R,
  index,
  gamma = 0,
  theta = 0,
  X = NA,
  estimand_function = extract_OLS,
  gamma_star_vec = NULL,
  kappa_inv_vec = NULL
)

Value

A list containing the deviate, one-sided p-value, observed value of the test statistic in each matched set, and conservative standard deviation estimate.

Arguments

Z

A length N vector of observed doses.

R

A length N vector of observed outcomes.

index

A length N vector of indices indicating matched set membership.

gamma

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

theta

The value at which to test the weak null.

X

A matrix with I rows and less than I columns that contains covariate information.

estimand_function

A function that takes in values z and r and outputs a scalar; this function governs the causal estimand to estimate

gamma_star_vec

A vector that contains the minimum probability of a permutation for each matched set; default is NULL.

kappa_inv_vec

A vector that contains the ratio of the maximum probability and minimum probability of a permutation for each matched set; default is NULL

Examples

Run this code
# Load the data
data <- lead_bmd
# prepare data
threshold <- log(0.74675)
match_info = data |> dplyr::group_by(matched_sets) |>
dplyr::summarise(below = sum(log_lead < threshold) > 0, disc = var(log_lead) > 0,
above = sum(log_lead > threshold) > 0)
below_indices <- match_info$matched_sets[match_info$below]
disc_indices <- match_info$matched_sets[match_info$disc]
above_indices <- match_info$matched_sets[match_info$above]
# outcome analysis using the stochastic intervention statistic, weak null
below_nbp <- data |> dplyr::filter(matched_sets %in% below_indices & matched_sets
%in% disc_indices)
above_below <- below_nbp |> dplyr::filter(matched_sets %in% above_indices)
extract_below_threshold_vs_baseline_function <- function(z, r) {
  extract_below_threshold_vs_baseline(z, r, threshold)
}
# one-sided test that estimand defined by estimand_function is 0 at gamma = 0
result <- weak_null_test(Z = above_below$log_lead,
R = above_below$lumbar_spine_bmd,
index = above_below$matched_sets, gamma = 0, theta = 0,
estimand_function = extract_below_threshold_vs_baseline_function)

Run the code above in your browser using DataLab