knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-" ) library(sparseR)
sparseR
: Sift smartly through interactions & polynomials with ranked sparsityThe ranked sparsity methods such as the sparsity-ranked lasso (SRL) have been developed for model selection and estimation in the presence of interactions and polynomials (Peterson & Cavanaugh 2022)[https://doi.org/10.1007/s10182-021-00431-7]. The main idea is that an algorithm should be more skeptical of higher-order polynomials and interactions a priori compared to main effects, by a predetermined amount.
The sparseR
package has many features designed to streamline sifting through the high-dimensional space of interaction terms and polynomials, including functions for variable pre-processing, variable selection, post-selection inference, and post-fit model visualization under ranked sparsity. The package implements ranked-sparsity-based versions of the lasso, elastic net, MCP, and SCAD. We also provide a (preliminary) version of an sparsity-ranked extension to Bayesian Information Criterion (and corresponding stepwise approaches).
## Via GitHub: # install.packages("devtools") devtools::install_github("petersonR/sparseR") # or via CRAN install.packages("sparseR")
library(sparseR)
data(iris) srl <- sparseR(Sepal.Width ~ ., data = iris, k = 1, poly = 2, seed = 1) srl par(mfrow = c(2,1), mar = c(4, 4, 3, 1)) plot(srl, plot_type = "both") summary(srl, at = "cv1se")
effect_plot(srl, "Petal.Width", by = "Species", at = "cv1se", legend_location = "topright")
For more examples and a closer look at how to use this package, check out the package website.
Many thanks to the authors and maintainers of ncvreg
and recipes
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.