The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Package {symtests}


Type: Package
Title: Symmetry Tests for Univariate Data
Version: 0.1.0
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.
License: MIT + file LICENSE
Encoding: UTF-8
Language: en-US
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
Config/roxygen2/version: 8.0.0
NeedsCompilation: no
Packaged: 2026-09-29 15:08:50 UTC; Isabel
Author: Isabel Parra-Frutos [aut, cre], Lourdes Molera [aut]
Maintainer: Isabel Parra-Frutos <ipf@um.es>
Repository: CRAN
Date/Publication: 2026-10-10 10:40:02 UTC

Kernel used in the triple test

Description

Internal helper for triples_test().

Usage

.triples_test_fstar(x)

Arguments

x

A numeric vector of length 3.

Value

A numeric value.


Validate input for the triple test

Description

Internal helper for triples_test().

Usage

.triples_test_validate_input(x)

Arguments

x

An input object.

Value

A cleaned numeric vector.


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)} \le \cdots \le x_{(n)} denote the ordered sample, and let D_i = x_{(i+1)} - x_{(i)} be the successive spacings.

The test uses

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 = \frac{S}{\hat{\sigma}},

where \hat{\sigma}^2 is an estimator of the asymptotic variance of S. The p-value is computed using a Student’s t approximation.

Value

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

statistic

The value of the test statistic.

p.value

The p-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

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

where m_r = \frac{1}{n} \sum_{i=1}^n (x_i - \bar{x})^r.

The test statistic is

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

where

\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 p-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 b, 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 b ⁠= 0.27⁠, which performs reasonably well for significance levels between 0.05 and 0.1. When alpha=0.05 or 0.1, calibrated values b ⁠= 0.26⁠ and b ⁠= 0.28⁠ are used, respectively.

Details

Let x_{(1)} \le \cdots \le x_{(n)} denote the ordered sample, and define the spacings D_i = x_{(i+1)} - x_{(i)}, i = 1, \ldots, n - 1. For a tuning value b, let 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= \dfrac{\sum_{i=1}^{k}D_{n-i}-\sum_{i=1}^{k}D_i}{s_D\sqrt{2k}}

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

For a nominal significance level of alpha=0.05, the value b ⁠= 0.26⁠ provides the best calibration, whereas for alpha=0.10, b ⁠= 0.28⁠ is preferred. The default choice b ⁠= 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 p-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 \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 p-value is computed using a Student’s t 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 t approximation.

p.value

The two-sided p-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)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.