-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
67 lines (47 loc) · 2.62 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
library(sparseR)
```
# `sparseR`: Sift smartly through interactions & polynomials with ranked sparsity
[![codecov](https://codecov.io/gh/petersonR/sparseR/branch/main/graph/badge.svg)](https://app.codecov.io/gh/petersonR/sparseR)
[![R-CMD-check](https://github.com/petersonR/sparseR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/petersonR/sparseR/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/sparseR)](https://CRAN.R-project.org/package=sparseR)
## What is ranked sparsity?
The 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.
## Package overview
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).
## Installation
```{r gh-installation, eval = FALSE}
## Via GitHub:
# install.packages("devtools")
devtools::install_github("petersonR/sparseR")
# or via CRAN
install.packages("sparseR")
```
## Example
```{r, eval = FALSE}
library(sparseR)
```
```{r example, fig.height=8, fig.width = 6}
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")
```
```{r example2}
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](https://petersonr.github.io/sparseR/).
Many thanks to the authors and maintainers of [`ncvreg`](https://github.com/pbreheny/ncvreg) and [`recipes`](https://recipes.tidymodels.org/).