update_y_LM updates the response accounting for the selected predictors in generalized linear models.

update_y_GLM(y, X, vars, update_y_thresh)

Arguments

y

Response. A numeric/integer/logical vector with values in {0,1}.

X

Predictor matrix. Can be a base matrix or something as.matrix() can coerce. No missing values are allowed.

vars

Character vector containing the names of predictors that need to be accounted for. They must appear in X.

update_y_thresh

Numeric scalar threshold. When \(|y - fitted\_y| > update\_y\_thresh\), y is kept, else y replaced by the rounded value of fitted_y, which is the fitted probability from the logistic model. The default value is 0.5.

Value

Returns the updated (binary) response vector.

Author

Nilotpal Sanyal <nsanyal@utep.edu>, Padmore N. Prempeh <pprempeh@albany.edu>

Examples

# 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