rBNR function

Simulate Bivariate Normal Data with Missingness

Simulate Bivariate Normal Data with Missingness

Function to simulate from a bivariate normal regression model with outcomes missing completely at random.

rBNR( X, Z, b, a, t_miss = 0, s_miss = 0, sigma = NULL, include_residuals = TRUE )

Arguments

  • X: Target design matrix.
  • Z: Surrogate design matrix.
  • b: Target regression coefficient.
  • a: Surrogate regression coefficient.
  • t_miss: Target missingness in [0,1].
  • s_miss: Surrogate missingness in [0,1].
  • sigma: 2x2 target-surrogate covariance matrix.
  • include_residuals: Include the residual? Default: TRUE.

Returns

Numeric Nx2 matrix. The first column contains the target outcome, the second contains the surrogate outcome.

Examples

set.seed(100) # Observations. n <- 1e3 # Target design. X <- cbind(1, matrix(rnorm(3 * n), nrow = n)) # Surrogate design. Z <- cbind(1, matrix(rnorm(3 * n), nrow = n)) # Target coefficient. b <- c(-1, 0.1, -0.1, 0.1) # Surrogate coefficient. a <- c(1, -0.1, 0.1, -0.1) # Covariance structure. sigma <- matrix(c(1, 0.5, 0.5, 1), nrow = 2) # Data generation, target and surrogate subject to 10% missingness. y <- rBNR(X, Z, b, a, t_miss = 0.1, s_miss = 0.1, sigma = sigma)
  • Maintainer: Zachary McCaw
  • License: GPL-3
  • Last published: 2023-10-01

Useful links