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

rotasym

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:

# Install the package
install.packages("rotasym")

# Load package
library(rotasym)

Alternatively, get the latest version from GitHub:

# Install the package
library(devtools)
install_github("egarpor/rotasym")

# Load package
library(rotasym)
# 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.

# 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

# 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

# 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 (data gathering and preprocessing) and the code snippet below.

# 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.



egarpor/rotasym documentation built on Aug. 29, 2023, 8:20 a.m.