-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
executable file
·124 lines (95 loc) · 3.94 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
---
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")
)
```
<!-- <img src="" alt="rotasym hexlogo" align="right" width="200" style="padding: 0 15px; float: right;"/> -->
## 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).