- Notifications
You must be signed in to change notification settings - Fork0
Variable Selection Using Shrinkage Priors
License
nilson01/VsusP-variable-selection-using-shrinkage-priors
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
In the context of Gaussian linear models, the package proposes a solution of the variable selection problem using Shrinkage priors. First obtain a posterior distribution of the number of significant variables by clustering the significant variables and the noise coefficients and obtaining samples from this distribution using MCMC. Then, the significant variables are estimated from the posterior median of absolute beta. This approach requires only one tuning parameters and is applicable to continuous shrinkage priors as well.
These instructions will install the package to your computer.
In order to install the package directly from Github, you need to have thedevtools package:
install.packages("devtools")To install the package from Github, first loaddevtools:
library(devtools)Next, installVsusP as follows:
devtools::install_github("nilson01/VsusP")
The package can now be loaded into R and used:
library(VsusP)To provide an example of theVsusP package, we will first simulate some data:
# install.packages("MASS") # if not yet installedlibrary(MASS)set.seed(20221208)sim.XY <- function(n, p, beta) { X <- matrix(rnorm(n * p), n, p) Y <- as.vector(X %*% beta + rnorm(n, 0, 1)) return(list(X = X, Y = Y, beta = beta))}n <- 100p <- 20beta <- exp(rnorm(p))data <- sim.XY(n, p, beta)The functionSequential2Means is used get the samples ofBeta andH.b.i.Beta can be calculated using different shrinkage priors and gibbs sampling technique, whereas H.b.i is the estimated number of signals corresponding to each tuning parameterb.i that is computed using S2M algorithm. If theBeta matrix is available prior, then H.b.i is recommended to be computed usingSequential2MeansBeta.
b.i <- seq(0, 1, 0.05)S2M <- Sequential2Means(X = data$X, Y = data$Y, b.i = b.i, prior = "horseshoe+", n.samples = 5000, burnin = 2000)Beta <- S2M$BetaH.b.i <- S2M$H.b.iThen, using the result fromSequential2Means orSequential2MeansBeta, appropriate tuning parameter can be estimated using b.i Vs H.b.i plot fromOptimalHbi function.
OptimalHbi(bi = b.i, Hbi = H.b.i)Finally, the indices of important subset of variables can be obtained usingS2MVarSelection function. The input parameterH is the optimal H.b.i value from the selected tuning parameter inOptimalHbi function. Also,Beta is the user defined matrix or the matrix derived fromSequential2Means function.
H <- 17impVariablesGLM <- S2MVarSelection(Beta, H)impVariablesGLMThere are several other variants of these functions as per input cases. For example: Sequential2MeansBeta and S2MVarSelectionV1.Check the documentation for the different functions on options and details, using e.g.,?Sequential2Means.
R Core Team (2022). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URLhttps://www.R-project.org/.
**Li, H., & Pati, D. (2020) ** "Variable Selection Using Shrinkage Priors." Computational Statistics & Data Analysis, 107, pp.107-119. doi:10.1016/j.csda.2020.106839.
About
Variable Selection Using Shrinkage Priors
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.