ridgetorus
PCA on the torus using density ridges. Software companion for "Toroidal PCA via density ridges"
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 9 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.9%) to scientific vocabulary
Keywords
circular-statistics
dimensionality-reduction
directional-statistics
r
Last synced: 6 months ago
·
JSON representation
Repository
PCA on the torus using density ridges. Software companion for "Toroidal PCA via density ridges"
Basic Info
Statistics
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
- Releases: 2
Topics
circular-statistics
dimensionality-reduction
directional-statistics
r
Created about 3 years ago
· Last pushed 7 months ago
Metadata Files
Readme
License
README.Rmd
---
output:
md_document:
variant: gfm
---
```{r, opts, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE, comment = "#>", fig.path = "README/README-",
message = FALSE, warning = FALSE, fig.asp = 1, fig.align = 'center'
)
```
ridgetorus
==========
[](https://www.gnu.org/licenses/gpl-3.0)
[](https://github.com/egarpor/ridgetorus/actions)
[](https://github.com/egarpor/ridgetorus/actions)
[](https://app.codecov.io/gh/egarpor/ridgetorus)
[](https://cran.r-project.org/package=ridgetorus)
[](https://cran.r-project.org/package=ridgetorus)
[](https://cran.r-project.org/package=ridgetorus)
## Overview
Implementation of principal component analysis on the two-dimensional torus $\mathbb{T}^2=[-\pi,\pi)^2$ via density ridges. Software companion for the paper "*Toroidal PCA via density ridges*" (García-Portugués and Prieto-Tirado, 2023).
## Installation
Get the latest version from GitHub:
```{r, install-devtools, eval = FALSE}
# Install the package
library(devtools)
install_github("egarpor/ridgetorus")
# Load package
library(ridgetorus)
```
```{r, load, echo = FALSE}
# Load package
library(ridgetorus)
```
## Usage
The main functionality of `ridgetorus` is the function `ridge_pca()`, which can be employed to do dimension reduction via the bivariate sine von Mises (Singh et al., 2002) and the bivariate wrapped Cauchy (Kato and Pewsey, 2015) models, as the following examples show.
### Bivariate sine von Mises
```{r, bvm}
# 1. Simulate data from r_bvm()
data <- r_bvm(n = 1000, mu = c(1, 2), kappa = c(5, 2, 1.5))
# 2. Do ridge_pca()
rpca <- ridge_pca(x = data, type = "bvm")
# 3. Plot simulated data with ridge fit using show_ridge_pca()
show_ridge_pca(rpca, col_data = "red")
# 4. Plot pairs plots of original data and scores with torus_pairs()
torus_pairs(data, col_data = "red", bwd = "EMI")
torus_pairs(rpca$scores, col_data = "red", bwd = "EMI", scales = rpca$scales)
```
### Bivariate wrapped Cauchy
```{r, bwc}
# 1. Simulate data from r_bwc()
data <- r_bwc(n = 1000, mu = c(-1, 2), xi = c(0.3, 0.6, 0.25))
# 2. Do ridge_pca()
rpca <- ridge_pca(x = data, type = "bwc")
# 3. Plot simulated data with ridge fit using show_ridge_pca()
show_ridge_pca(rpca, col_data = "red")
# 4. Plot pairs plots of original data and scores with torus_pairs()
torus_pairs(rpca$scores, col_data = "red", bwd = "EMI", scales = rpca$scales)
```
## Data application in oceanography
The data applications in García-Portugués and Prieto-Tirado (2023) can be reproduced through the script [data-application.R](https://github.com/egarpor/egarpor/blob/master/application/data-application.R). The code snippet below illustrates the toroidal PCA analysis onto currents of four zones at Santa Barbara strait. Zone A and B are on the northern coast of Santa Barbara Channel while zone C and D, are at the top and bottom ends of the interisland channel.
```{r, santabarbara}
# Load data
data("santabarbara")
# Example with zone A-B with automatic comparison between bvm and bwc
rpca_AB <- ridge_pca(x = santabarbara[c("A", "B")], type = "auto")
show_ridge_pca(fit = rpca_AB, col_data = "black", n_max = 1e3)
torus_pairs(santabarbara[c("A", "B")], col_data = "black")
torus_pairs(rpca_AB$scores, col_data = "black", scales = rpca_AB$scales)
rpca_AB$type
rpca_AB$var_exp
# Example with zone C-D with automatic comparison between bvm and bwc
rpca_CD <- ridge_pca(x = santabarbara[c("C", "D")], type = "auto")
show_ridge_pca(fit = rpca_CD, col_data = "black", n_max = 1e3)
torus_pairs(santabarbara[c("C", "D")], col_data = "black")
torus_pairs(rpca_CD$scores, col_data = "black", scales = rpca_CD$scales)
rpca_CD$type
rpca_CD$var_exp
```
It can be seen how the bivariate von Mises and the bivariate wrapped Cauchy are the most adequate fits for zones C--D and A--B, respectively. Toroidal PCA explains around 75% of the total variance in both cases, motivating its use for dimension reduction. The scores also transform the data distribution, reducing noise and allowing to check for groups or outliers, if any.
## References
García-Portugués, E. and Prieto-Tirado, A. (2023). Toroidal PCA via density ridges. *Statistics and Computing*, 33(5):107. [doi:10.1007/s11222-023-10273-9](https://doi.org/10.1007/s11222-023-10273-9).
Kato, S. and Pewsey, A. (2015). A Möbius transformation-induced distribution on the torus. *Biometrika*, 102(2):359--370. [doi:10.1093/biomet/asv003](https://doi.org/10.1093/biomet/asv003).
Singh, H., Hnizdo, V., and Demchuk, E. (2002). Probabilistic model for two dependent circular variables. *Biometrika*, 89(3):719--723. [doi:10.1093/biomet/89.3.719](https://doi.org/10.1093/biomet/89.3.719).
Owner
- Name: Eduardo García-Portugués
- Login: egarpor
- Kind: user
- Location: Madrid
- Company: Carlos III University of Madrid
- Website: egarpor.github.io
- Repositories: 9
- Profile: https://github.com/egarpor
GitHub Events
Total
- Push event: 2
- Create event: 1
Last Year
- Push event: 2
- Create event: 1
Issues and Pull Requests
Last synced: 7 months ago
All Time
- Total issues: 0
- Total pull requests: 3
- Average time to close issues: N/A
- Average time to close pull requests: 3 days
- Total issue authors: 0
- Total pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 1.0
- Merged pull requests: 3
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
- egarpor (2)
- apt345 (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 174 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 4
- Total maintainers: 1
cran.r-project.org: ridgetorus
PCA on the Torus via Density Ridges
- Homepage: https://github.com/egarpor/ridgetorus
- Documentation: http://cran.r-project.org/web/packages/ridgetorus/ridgetorus.pdf
- License: GPL-3
-
Latest release: 1.0.3
published 7 months ago
Rankings
Forks count: 28.8%
Dependent packages count: 29.8%
Stargazers count: 35.2%
Dependent repos count: 35.5%
Average: 41.8%
Downloads: 80.0%
Maintainers (1)
Last synced:
6 months ago
Dependencies
.github/workflows/check-standard.yaml
actions
- actions/checkout v3 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/test-coverage.yaml
actions
- actions/checkout v3 composite
- actions/upload-artifact v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION
cran
- R >= 3.5.0 depends
- Rcpp * depends
- circular * imports
- rootSolve * imports
- sdetorus * imports
- sphunif * imports
- BAMBI * suggests
- DirStats * suggests
- GGally * suggests
- covr * suggests
- ggplot2 * suggests
- knitr * suggests
- markdown * suggests
- mvtnorm * suggests
- numDeriv * suggests
- rmarkdown * suggests
- testthat * suggests
- viridisLite * suggests