rrLASSO.S5: Bayesian Reciprocal Regularization

View source: R/rrLASSO.S5.R

rrLASSO.S5R Documentation

Bayesian Reciprocal Regularization

Description

Simplified Shotgun Stochastic Search with Screening (S5) algorithm to solve the reduced reciprocal LASSO, based on a source code adapted from 'BayesS5' by Minsuk Shin.

Usage

rrLASSO.S5(
  X,
  y,
  S = 30,
  lam = 1,
  intercept = TRUE,
  verbose = FALSE,
  seed = 1234
)

Arguments

X

A numeric matrix with standardized predictors in columns and samples in rows.

y

A mean-centered continuous response variable with matching rows with X.

S

A screening size of variables. Default is 30.

lam

A tuning parameter for the rrLASSO objective function. Default is 1.

intercept

If TRUE, intercept is included in the final OLS fit. The default is TRUE.

verbose

If TRUE, the function prints the current status of the S5 in each temperature. The default is FALSE.

seed

Seed value for reproducibility. Default is 1234.

Value

A list containing the following components is returned:

hppm

Index of the highest posterior probablity model.

marg.prob

Marginal posterior probablities of the coefficients.

beta

OLS coefficients from the final rLASSO model.

time

Computation time in seconds.

Examples

## Not run: 

#########################
# Load Prostate dataset #
#########################

library(ElemStatLearn)
prost<-prostate

###########################################
# Scale data and prepare train/test split #
###########################################

prost.std <- data.frame(cbind(scale(prost[,1:8]),prost$lpsa))
names(prost.std)[9] <- 'lpsa'
data.train <- prost.std[prost$train,]
data.test <- prost.std[!prost$train,]

##################################
# Extract standardized variables #
##################################

y.train   = data.train$lpsa - mean(data.train$lpsa)
y.test <- data.test$lpsa - mean(data.test$lpsa)
x.train = scale(as.matrix(data.train[,1:8], ncol=8))
x.test = scale(as.matrix(data.test[,1:8], ncol=8))

#################################
# Reduced Reciprocal LASSO (S5) #
#################################

rrLasso<- rrLASSO.S5(x.train, y.train)
y.pred.rrLasso<-x.test%*%rrLasso$beta[-1]
mean((y.pred.rrLasso - y.test)^2) # Performance on test data


## End(Not run)


himelmallick/BayesRecipe documentation built on Aug. 4, 2024, 7:21 a.m.