pred_S3VS performs prediction using predictors selected by S3VS in linear models.

pred_S3VS_LM(y, X, method)

Arguments

y

Response. A numeric vector.

X

Predictor matrix. This should include predictors selected by S3VS. Can be a base matrix or something as.matrix() can coerce. No missing values are allowed.

method

Character string indicating the prediction method used. Available options are "NLP", "LASSO", "SCAD", "MCP"

Value

A list containing:

y.pred

Predicted response

coef

Coefficient estimates of the predictors used for prediction

Author

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

See also

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)
# Run S3VS for LM
res_lm <- S3VS(y = y, X = X, family = "normal",
               method_xy = "topk", param_xy = list(k=1),
               method_xx = "topk", param_xx = list(k=3),
               vsel_method = "LASSO", method_sel = "conservative", 
               method_rem = "conservative_begin", rem_regout = FALSE, 
               m = 100, nskip = 3, verbose = TRUE, seed = 123)
#> -------------
#> Iteration 1
#> -------------
#> input : V1 V119 V70 
#> selected : V1 
#> -------------
#> Iteration 2
#> -------------
#> input : V2 V43 V17 
#> selected : V2 
#> -------------
#> Iteration 3
#> -------------
#> input : V76 V3 V15 
#> selected :  
#> *** nskip= 1 *** 
#> -------------
#> Iteration 4
#> -------------
#> input : V14 V121 V11 
#> selected :  
#> *** nskip= 2 *** 
#> -------------
#> Iteration 5
#> -------------
#> input : V149 V70 V8 
#> selected :  
#> *** nskip= 3 *** 
#> =================================
#> Number of selected variables: 2
#> Time taken: 0.07 sec
#> =================================
pred_lm <- pred_S3VS_LM(y = y, X = X[,res_lm$selected], method = "LASSO")
pred_lm
#> $coef
#>        V1        V2 
#> 0.7497348 0.1261898 
#> 
#> $y.pred
#>   [1] -0.590945516 -0.221247351  1.056396407 -0.072085126 -0.104244430
#>   [6]  1.199070396  0.165426577 -1.240029008 -0.644029548 -0.299251666
#>  [11]  0.764042361  0.265392433  0.015220613 -0.005120064 -0.432280918
#>  [16]  1.296621970  0.305499673 -1.636383176  0.337515490 -0.564794138
#>  [21] -0.866830132 -0.364076383 -0.912225923 -0.659882696 -0.317028488
#>  [26] -1.427933405  0.576730056  0.043735631 -1.055768693  0.849938878
#>  [31]  0.420931231 -0.245341532  0.595218601  0.523961017  0.275777660
#>  [36]  0.577969349  0.149882059 -0.034134928 -0.069572850 -0.548548299
#>  [41] -0.513379336 -0.270060845 -1.228191555  1.353914680  0.622462185
#>  [46] -0.990119909 -0.567606785 -0.344151051  0.768687876 -0.306006184
#>  [51]  0.208234905 -0.005448604 -0.071312287  0.817750472 -0.265433443
#>  [56]  1.020476296 -1.171201659  0.310215887  0.135050510  0.033539229
#>  [61]  0.336378965 -0.590096168 -0.489927273 -0.435766598 -0.937253692
#>  [66]  0.184107859  0.335275653 -0.102400455  0.675587297  1.502487903
#>  [71] -0.476413341 -1.804116232  0.668646795 -0.344214946 -0.690464407
#>  [76]  0.549511567 -0.289827099 -0.957126381  0.109922937 -0.243064097
#>  [81] -0.210950683  0.367167791 -0.403110407  0.292801215 -0.276213897
#>  [86]  0.142775494  0.881307548  0.255872279 -0.230299736  0.717204051
#>  [91]  0.690833788  0.289088822  0.109829565 -0.664840112  0.773627265
#>  [96] -0.279098921  1.634631493  0.910062387 -0.334927040 -1.000230295
#>