Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (20.3%) to scientific vocabulary
Keywords
machine-learning
ml
r
statistics
Last synced: 10 months ago
·
JSON representation
Repository
Basis Expansions for Regression Modeling
Basic Info
- Host: GitHub
- Owner: CoryMcCartan
- License: other
- Language: R
- Default Branch: main
- Homepage: http://corymccartan.com/bases/
- Size: 4.39 MB
Statistics
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
machine-learning
ml
r
statistics
Created about 1 year ago
· Last pushed 11 months ago
Metadata Files
Readme
License
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
)
set.seed(16802)
```
# **bases**
[](https://github.com/CoryMcCartan/bases/actions/workflows/R-CMD-check.yaml)
[](https://CRAN.R-project.org/package=bases)
**bases** provides various basis expansions for flexible regression modeling,
including random Fourier features (`?b_rff`), exact kernel / Gaussian process
feature maps (`?b_ker`), Bayesian Additive Regression Trees prior features
(`?b_bart`), and a helpful interface for n-way interactions (`?b_inter`). The
provided functions may be used within any modeling formula, allowing the use of
kernel methods and other basis expansions in modeling functions that do not
otherwise support them.
Along with the basis expansions, a number of kernel functions (`?kernels`)
are also provided, which support kernel arithmetic to form new kernels. Basic
ridge regression functionality (`?ridge`) is included as well.
Finally, the package provides a
[recipes](https://recipes.tidymodels.org/)-friendly interface, so that these
basis expansions can be combined with other transformations and used within the
[tidymodels](https://www.tidymodels.org/) framework.
## Installation
You can install **bases** from CRAN:
``` r
install.packages("bases")
```
You can install the development version with
```r
remotes::install_github("CoryMcCartan/bases")
```
## Example: random Fourier features
The basis functions in **bases** all start with `b_` and are designed to work in
the same way as built-in basis expansions like `bs()` or `poly()`: simply
include the function in a model formula.
So fitting an approximate kernel regression with random Fourier features is as simple as wrapping the relevant variables in a call to the corresponding basis function, `b_rff()`.
The default kernel is a Gaussian/RBF kernel with length scale 1 which is applied to predictors after rescaling them to have unit variance.
```{r}
library(bases)
# Box & Jenkins (1976) sales data
x = 1:150
y = as.numeric(BJsales)
lm(y ~ b_rff(x, p = 5)) # 5 random features
```
You can provide a different `kernel = ` argument to switch kernels.
Many common kernels are provided with the package; see `?kernels`.
```r
b_rff(x, kernel = k_matern(scale = 0.1, nu = 5/2))
b_rff(x, kernel = k_rq(scale = 2, alpha = 2))
```
In practice, RFF are usually fit with penalization, such as via ridge regression.
Below, we visualize several RFF ridge regression fits versus a simple linear model, using the `ridge()` function provided in the package.
```{r rbf-plot}
k = k_rbf(scale = 0.2)
plot(x, y, xlab = "Month", ylab = "Sales")
lines(x, fitted(lm(y ~ x)), lty = "dashed", lwd = 1.5)
for (i in 1:20) {
m_rff = ridge(y ~ b_rff(x, kernel = k))
lines(x, fitted(m_rff), col = "#4584")
}
```
Owner
- Name: Cory McCartan
- Login: CoryMcCartan
- Kind: user
- Company: New York University
- Website: corymccartan.com
- Twitter: CoryMcCartan
- Repositories: 55
- Profile: https://github.com/CoryMcCartan
Faculty Fellow at NYU's Center for Data Science, working on computational social science problems and open-source R software.
GitHub Events
Total
- Issues event: 1
- Watch event: 1
- Push event: 22
- Create event: 3
Last Year
- Issues event: 1
- Watch event: 1
- Push event: 22
- Create event: 3
Packages
- Total packages: 1
-
Total downloads:
- cran 430 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
cran.r-project.org: bases
Basis Expansions for Regression Modeling
- Homepage: https://corymccartan.com/bases/
- Documentation: http://cran.r-project.org/web/packages/bases/bases.pdf
- License: MIT + file LICENSE
-
Latest release: 0.1.2
published about 1 year ago
Rankings
Dependent packages count: 26.4%
Forks count: 29.0%
Dependent repos count: 32.5%
Stargazers count: 37.3%
Average: 42.4%
Downloads: 86.7%
Maintainers (1)
Last synced:
10 months ago
Dependencies
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v4 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action v4.5.0 composite
- actions/checkout v4 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION
cran
- rlang * imports
- stats * imports
- testthat >= 3.0.0 suggests