We present *BOSO*, an R package to perform feature selection
in a linear regression problem. It implements a Bilevel Optimization
Selector Operator.

BOSO can be installed from CRAN repository:

`install.packages("BOSO")`

The package package has been prepared to work like ‘glmnet’ and
‘lasso’, presented in the *BestSubset* package.

```
library(BOSO)
## Load the data prepared for this test
data("sim.xy", package = "BOSO")
<- sim.xy[['high-5']]$x
Xtr <- sim.xy[['high-5']]$y
Ytr <- sim.xy[['high-5']]$xval
Xval <- sim.xy[['high-5']]$yval
Yval
## Perform BOSO
<- Sys.time()
time <- BOSO(x = Xtr, y = Ytr,
obj xval = Xval, yval = Yval,
IC = 'eBIC',
nlambda=100,
intercept= 0,
standardize = 0,
Threads=4, timeLimit = 60, verbose = 3,
seed = 2021)
<- as.numeric(Sys.time() - time) time
```

`obj`

is a BOSO object, which have the following
associated functions:

`coef(obj)`

returns the coefficients (betas) of the linear regression.

`predict(obj, xnew)`

returns the predicted outcome with a new X matrix.

```
<- coef(obj)
betas print(betas[betas!=0])
<- predict(obj, Xtr)
Ytr_predicted print(paste0("MSE for training set is ", round(mean((Ytr_predicted-Ytr)^2),5)))
<- predict(obj, Xval)
Yval_predicted print(paste0("MSE for validation set is ", round(mean((Yval_predicted-Yval)^2),5)))
```