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

update_y_LM(y, X, vars)

Arguments

y

Response. A numeric vector of length \(n\).

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.

Value

Returns the updated response vector.

Author

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

Examples

# Simulate continuous data
set.seed(123)
n <- 100
p <- 150
X <- matrix(rnorm(n * p), n, p)
colnames(X) <- paste0("V", 1:p)
y <- X[,1] + 0.5 * X[,2] + rnorm(n)
update_y(family = "normal", y = y, X = X, vars = c("V1","V4"))
#>           1           2           3           4           5           6 
#> -1.59862166 -0.33644302 -0.84792451  0.91750191  0.26170677  1.49935928 
#>           7           8           9          10          11          12 
#> -1.75492925 -0.09430317  0.29054672  0.93731582  0.47309448 -1.08727736 
#>          13          14          15          16          17          18 
#> -0.11190232 -0.09686395  0.52997059 -0.08881610  0.89866451  0.73425980 
#>          19          20          21          22          23          24 
#> -0.50852445 -0.14688709  1.80022226 -2.48579611 -0.05175838  1.74883938 
#>          25          26          27          28          29          30 
#>  0.63209248 -1.04741718  0.45238278 -0.68760999 -2.02531954 -0.40485644 
#>          31          32          33          34          35          36 
#> -1.47729999 -0.58445736  0.51910850  0.65578067 -0.90410896  0.60663777 
#>          37          38          39          40          41          42 
#> -0.69638978  1.01918253 -0.46919980 -0.94121368  1.30826006 -0.57818400 
#>          43          44          45          46          47          48 
#> -1.79119259 -0.44887340 -0.22290510  0.13157632  0.00347607 -0.57949953 
#>          49          50          51          52          53          54 
#>  2.04821867  0.16114766  0.78927157  1.00553923 -1.18679206  1.58930587 
#>          55          56          57          58          59          60 
#> -0.57605265  1.15647333  1.60202371 -1.43408889  0.14526039 -0.10207504 
#>          61          62          63          64          65          66 
#> -0.26228995 -0.05982090 -0.64578051  1.16864863 -0.87074835  1.15271169 
#>          67          68          69          70          71          72 
#>  0.77931919 -1.36751043  2.04792441  1.45383582 -0.01324524  2.09113996 
#>          73          74          75          76          77          78 
#> -1.03193597 -0.46872210 -2.77089039 -1.06448436 -0.44336872  1.16287738 
#>          79          80          81          82          83          84 
#>  1.59798127  0.04755143 -0.66022489  0.23181967  0.84349509 -1.04422504 
#>          85          86          87          88          89          90 
#> -0.16946596 -0.53139685  0.16640201  0.10477904  0.66961606  0.25861698 
#>          91          92          93          94          95          96 
#> -0.43119447 -1.47147398  1.98506800  0.30713562  0.45539893  0.17870718 
#>          97          98          99         100 
#> -0.71970294 -0.28267033 -1.14786871  0.20435594