Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/egarpor/rotasym

Tests for rotational symmetry on the hypersphere. Software companion for "On optimal tests for rotational symmetry against new classes of hyperspherical distributions"
https://github.com/egarpor/rotasym

circular-statistics directional-statistics goodness-of-fit r semiparametric statistics

Last synced: 7 days ago
JSON representation

Tests for rotational symmetry on the hypersphere. Software companion for "On optimal tests for rotational symmetry against new classes of hyperspherical distributions"

Awesome Lists containing this project

README

        

---
output:
md_document:
variant: gfm
---

```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE, comment = "#>", fig.path = "README/README-",
message = FALSE, warning = FALSE, fig.asp = 1, fig.align = 'center'
)
```

rotasym
=======

```{r, echo = FALSE, results = 'asis'}
cat(
badger::badge_license(license = "GPLv3", color = "blue",
url = "https://www.gnu.org/licenses/gpl-3.0"),
badger::badge_github_actions(action = "R-CMD-check"),
badger::badge_cran_release(color = "green"),
badger::badge_cran_download(pkg = NULL, type = "grand-total"),
badger::badge_cran_download(pkg = NULL, type = "last-month")
)
```

## Overview

Software companion for the paper "*On optimal tests for rotational symmetry against new classes of hyperspherical distributions*" (García-Portugués, Paindaveine and Verdebout, 2020). It implements the proposed tests for rotational symmetry of hyperspherical data and allows to replicate the data application presented.

## Installation

Get the released version from CRAN:

```{r, install-CRAN, eval = FALSE}
# Install the package
install.packages("rotasym")

# Load package
library(rotasym)
```

Alternatively, get the latest version from GitHub:

```{r, install-GitHub, eval = FALSE}
# Install the package
library(devtools)
install_github("egarpor/rotasym")

# Load package
library(rotasym)
```

```{r, load, echo = FALSE}
# Load package
library(rotasym)
```

## Tests usage

The following are some simple examples of the usage of the main function of the package, `test_rotasym`, with simulated data. More examples are available in `?test_rotasym`.

```{r, sample}
# Sample data from a vMF (rotational symmetric distribution about mu)
n <- 200
p <- 10
theta <- c(1, rep(0, p - 1))
set.seed(123456789)
data_0 <- r_vMF(n = n, mu = theta, kappa = 1)
```

### Specified-θ case

```{r, specified}
# theta known
test_rotasym(data = data_0, theta = theta, type = "sc")
test_rotasym(data = data_0, theta = theta, type = "loc_vMF")
test_rotasym(data = data_0, theta = theta, type = "hyb_vMF")
```

### Unspecified-θ case

```{r, unspecified}
# theta unknown (employs the spherical mean as estimator)
test_rotasym(data = data_0, type = "sc")
test_rotasym(data = data_0, type = "loc_vMF")
test_rotasym(data = data_0, type = "hyb_vMF")
```

## Data application: test for the rotational symmetry of sunspots

The data application in García-Portugués, Paindaveine and Verdebout (2020) can
be replicated through the script [sunspots-births.R](https://github.com/egarpor/rotasym/blob/master/data-raw/sunspots-births.R) (data gathering and preprocessing) and the code snippet below.

```{r, sunspots_births, fig.show = 'hold'}
# Load data
data("sunspots_births")
sunspots_births$X <-
cbind(cos(sunspots_births$phi) * cos(sunspots_births$theta),
cos(sunspots_births$phi) * sin(sunspots_births$theta),
sin(sunspots_births$phi))

# Test rotational symmetry for the 23rd cycle
sunspots_23 <- subset(sunspots_births, cycle == 23)
test_rotasym(data = sunspots_23$X, type = "sc", theta = c(0, 0, 1))
test_rotasym(data = sunspots_23$X, type = "loc", theta = c(0, 0, 1))
test_rotasym(data = sunspots_23$X, type = "hyb", theta = c(0, 0, 1))

# Test rotational symmetry for the 22nd cycle
sunspots_22 <- subset(sunspots_births, cycle == 22)
test_rotasym(data = sunspots_22$X, type = "sc", theta = c(0, 0, 1))
test_rotasym(data = sunspots_22$X, type = "loc", theta = c(0, 0, 1))
test_rotasym(data = sunspots_22$X, type = "hyb", theta = c(0, 0, 1))

# More analyses in ?sunspots_births
example("sunspots_births")
```

## References

García-Portugués, E., Paindaveine, D., and Verdebout, T. (2020). On optimal tests for rotational symmetry against new classes of hyperspherical distributions. *Journal of the American Statistical Association*, 115(532):1873--1887. [doi:10.1080/01621459.2019.1665527](https://doi.org/10.1080/01621459.2019.1665527).