Learn R Programming

SurrogateRegression (version 0.5.0)

Wald.BNLS: Wald Test via Least Squares.

Description

Performs a Wald test of the null hypothesis that a subset of the regression parameters for the target outcome are zero.

Usage

Wald.BNLS(t, s, X, is_zero)

Value

A numeric vector containing the Wald statistic, the degrees of freedom, and a p-value.

Arguments

t

Target outcome vector.

s

Surrogate outcome vector.

X

Model matrix.

is_zero

Logical vector, with as many entires as columns in the target model matrix, indicating which columns have coefficient zero under the null.

Examples

Run this code
# \donttest{
# Generate data.
set.seed(100)
n <- 1e3
X <- cbind(1, rnorm(n))
data <- rBNR(X = X, Z = X, b = c(1, 0), a = c(-1, 0), t_miss = 0.1, s_miss = 0.0)

# Test 1st coefficient.
wald_test1 <- Wald.BNLS(
  t = data[, 1], 
  s = data[, 2], 
  X = X, 
  is_zero = c(TRUE, FALSE)
)

# Test 2nd coefficient.
wald_test2 <- Wald.BNLS(
  t = data[, 1], 
  s = data[, 2], 
  X = X, 
  is_zero = c(FALSE, TRUE)
)
# }

Run the code above in your browser using DataLab