Package 'symtests'

Title: Symmetry Tests for Univariate Data
Description: Implements statistical tests for detecting departures from symmetry in univariate data, including procedures based on moments, spacings, order statistics, and triples. The functions provide straightforward tools for assessing symmetry in empirical distributions.
Authors: Isabel Parra-Frutos [aut, cre], Lourdes Molera [aut]
Maintainer: Isabel Parra-Frutos <ipf@um.es>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-10-10 14:13:00 UTC
Source: https://github.com/cran/symtests

Help Index


ES symmetry test

Description

Performs the ES symmetry test by Ekström & Jammalamadaka (2007).

Usage

es_symtest(x)

Arguments

x

A numeric vector.

Details

Let x(1)≤⋯≤x(n)x_{(1)} \le \cdots \le x_{(n)} denote the ordered sample, and let Di=x(i+1)−x(i)D_i = x_{(i+1)} - x_{(i)} be the successive spacings.

The test uses

S=n−1/2∑i=1[(n−1)/2](I(Di−Dn−i≤0)−12),S = n^{-1/2} \sum_{i=1}^{[(n-1)/2]} \left( I(D_i - D_{n-i} \le 0) - \frac{1}{2} \right),

together with a variance estimate based on spacings of order ⁠2m-1⁠, where m = 3 if n < 200 and m = 4 otherwise.

The resulting test statistic is

T=Sσ^,T = \frac{S}{\hat{\sigma}},

where σ^2\hat{\sigma}^2 is an estimator of the asymptotic variance of SS. The pp-value is computed using a Student’s tt approximation.

Value

An object of class "htest" with the following components:

statistic

The value of the test statistic.

p.value

The pp-value of the test.

References

Ekström, M., & Jammalamadaka, R. S. (2007). An asymptotically distribution-free test of symmetry. Journal of Statistical Planning and Inference, 137(3), 799–810. doi:10.1016/j.jspi.2006.06.009

See Also

triples_symtest(), tail_symtest(), gupta_symtest(),

lawstat::symmetry.test(), symmetry::symmetry_test()

Examples

set.seed(123)
es_symtest(rnorm(100))

set.seed(123)
es_symtest(rexp(100))

Gupta symmetry test

Description

Performs the test of symmetry by Gupta (1967) based on the standardized third central moment and its asymptotic variance.

Usage

gupta_symtest(x)

Arguments

x

A numeric vector.

Details

The test is based on the sample skewness measure

b1=m3m23/2,b_1 = \dfrac{m_3}{m_2^{3/2}},

where mr=1n∑i=1n(xi−xˉ)rm_r = \frac{1}{n} \sum_{i=1}^n (x_i - \bar{x})^r.

The test statistic is

Z=nb1σ,Z = \sqrt{n}\dfrac{b_1}{\sigma},

where

σ=m6−6m2m4+9m23m23.\sigma = \sqrt{\dfrac{m_6 - 6m_2m_4 + 9m_2^3}{m_2^3}}.

For distributions with zero skewness and finite moments up to order six, the test statistic converges in distribution to a standard normal distribution, N(0,1).

Value

An object of class "htest" with the following components:

statistic

The value of the test statistic.

p.value

The two-sided pp-value.

References

Gupta, M. K. (1967). An asymptotically nonparametric test of symmetry. The Annals of Mathematical Statistics, 38(3), 849–866.

See Also

triples_symtest(), tail_symtest(), es_symtest(),

lawstat::symmetry.test(), symmetry::symmetry_test()

Examples

x <- c(-3, -2, -1, 0, 1, 2, 3)
gupta_symtest(x)

y <- c(1, 2, 2, 3, 4, 10, 25)
gupta_symtest(y)

Tail-based symmetry test

Description

Performs a tail-based symmetry test by comparing spacings in the lower and upper tails of the ordered sample.

Usage

tail_symtest(x, alpha = NULL)

Arguments

x

A numeric vector.

alpha

Optional significance level used to select the tuning value bb, which determines the number of spacings averaged in each tail. Allowed values are NULL, 0.05, or 0.10. By default (alpha=NULL), the generalized version of the test is used with bb ⁠= 0.27⁠, which performs reasonably well for significance levels between 0.05 and 0.1. When alpha=0.05 or 0.1, calibrated values bb ⁠= 0.26⁠ and bb ⁠= 0.28⁠ are used, respectively.

Details

Let x(1)≤⋯≤x(n)x_{(1)} \le \cdots \le x_{(n)} denote the ordered sample, and define the spacings Di=x(i+1)−x(i)D_i = x_{(i+1)} - x_{(i)}, i=1,…,n−1i = 1, \ldots, n - 1. For a tuning value bb, let k=⌈bn⌉k = \lceil bn \rceil denote the number of spacings averaged in each tail, where ⌈⋅⌉\lceil · \rceil is the ceiling function. The test statistic is defined as a standardized difference between the average lower- and upper-tail spacings,

T=∑i=1kDn−i−∑i=1kDisD2kT= \dfrac{\sum_{i=1}^{k}D_{n-i}-\sum_{i=1}^{k}D_i}{s_D\sqrt{2k}}

where sDs_D is the sample standard deviation of spacings. The two-sided pp-value is computed using the standard normal approximation.

For a nominal significance level of alpha=0.05, the value bb ⁠= 0.26⁠ provides the best calibration, whereas for alpha=0.10, bb ⁠= 0.28⁠ is preferred. The default choice bb ⁠= 0.27⁠ provides reasonably good performance across significance levels between 0.05 and 0.10, avoiding the need to recalibrate the tuning value for each significance level. Because the test is based on tail spacings, it may have low power against alternatives where departures from symmetry are confined to the center of the distribution.

Value

An object of class htest containing:

statistic

the test statistic

p.value

the two-sided pp-value

n

the number of observations in the sample

b

the tuning value used in the test

k

the number of spacings averaged in each tail, computed as ⌈bn⌉\lceil bn \rceil

References

Molera, L., and Parra-Frutos, I. (2026). A Symmetry Test based on Tail Spacings. Manuscript submitted for publication.

See Also

triples_symtest(), es_symtest(), gupta_symtest(), lawstat::symmetry.test(), symmetry::symmetry_test()

Examples

set.seed(123)
x <- rnorm(100)
tail_symtest(x)
tail_symtest(x, alpha = 0.10)
tail_symtest(rexp(60, 1))

Triples symmetry test

Description

Performs the test of symmetry by Randles et al. (1980).

Usage

triples_symtest(x)

Arguments

x

A numeric vector of observations.

Details

The test is based on a standardized U-statistic that compares the numbers of sample triples skewed to the right and to the left. The pp-value is computed using a Student’s tt approximation with n degrees of freedom, where n is the sample size. Since all possible triples are considered, computation may be slow for large samples.

Value

An object of class "htest" with the following components:

statistic

The value of the test statistic.

parameter

The degrees of freedom used in the tt approximation.

p.value

The two-sided pp-value for the null hypothesis of symmetry.

References

Randles, R. H., Fligner, M. A., Policello, G. E., and Wolfe, D. A. (1980). "An asymptotically distribution-free test for symmetry versus asymmetry." Journal of the American Statistical Association, 75, 168–172.

See Also

tail_symtest(), es_symtest(), gupta_symtest(),

lawstat::symmetry.test(), symmetry::symmetry_test()

Examples

set.seed(123)
x <- rnorm(20)
triples_symtest(x)

y <- rexp(20) - 1
triples_symtest(y)