update_y_GLM.Rdupdate_y_LM updates the response accounting for the selected predictors in generalized linear models.
update_y_GLM(y, X, vars, update_y_thresh)Predictor matrix. Can be a base matrix or something as.matrix() can coerce. No missing values are allowed.
Returns the updated (binary) response vector.
# Simulate binary data
set.seed(123)
n <- 100
p <- 150
X <- matrix(rnorm(n * p), n, p)
colnames(X) <- paste0("V", 1:p)
eta <- X[,1] + 0.5 * X[,2]
prob <- 1 / (1 + exp(-eta))
y <- rbinom(n, size = 1, prob = prob)
update_y(family = "binomial", y = y, X = X, vars = c("V1","V4"), update_y_thresh = 0.8)
#> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#> 0 1 1 1 1 1 1 0 0 0 1 1 1 1 0 1 1 0 1 0
#> 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
#> 0 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 1 0 0
#> 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
#> 0 0 0 1 1 0 0 0 1 1 1 1 1 1 1 1 0 1 1 1
#> 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
#> 1 0 0 0 0 1 1 1 1 1 0 1 1 0 0 1 1 0 1 1
#> 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
#> 1 1 0 1 0 1 1 1 0 1 1 1 1 0 1 0 1 1 1 0