Package {normality}


Title: Tests for Departure from Normality
Version: 0.0.1
Description: A toolkit for assessing data normality using a comprehensive collection of statistical methods. It includes descriptive measures and formal hypothesis tests, such as skewness and kurtosis tests, the Anderson–Darling test, the Shapiro–Wilk test, and the D'Agostino–Pearson K2 omnibus test.
License: MIT + file LICENSE
URL: https://github.com/P10911004-NPUST/normality
BugReports: https://github.com/P10911004-NPUST/normality/issues
Encoding: UTF-8
RoxygenNote: 7.3.3
Depends: R (≥ 3.5)
LazyData: true
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2026-06-05 07:11:20 UTC; ABRC
Author: Joon-Keat Lai ORCID iD [aut, cre, cph]
Maintainer: Joon-Keat Lai <p10911004@gmail.com>
Repository: CRAN
Date/Publication: 2026-06-09 16:10:13 UTC

Shapiro-Francia Normality Test

Description

Performs the Shapiro-Francia test of normality.

Usage

.Shapiro_Francia(x)

Arguments

x

Numeric vector.

Value

A list.

References

Shapiro, S.S., Francia, R.S., 1972. An Approximate Analysis of Variance Test for Normality. Journal of the American Statistical Association 67, 215–216. https://doi.org/10.1080/01621459.1972.10481232

Royston, P., 1993. A pocket‐calculator algorithm for the shapiro‐francia test for non‐normality: An application to medicine. Statistics in Medicine 12, 181–184. https://doi.org/10.1002/sim.4780120209


Anderson-Darling Normality Test

Description

Anderson-Darling Normality Test

Usage

Anderson_Darling_test(x, alpha = 0.05, min_n = 8, verbose = FALSE)

Arguments

x

A numeric vector.

alpha

Numeric (default: 0.05). Significance threshold, range from 0 to 1.

min_n

Integer. The minimum observations required (default: 8).

verbose

Logical (default: FALSE). Show messages.

Value

A list:

References

D’Agostino, RalphB., 2017. Goodness-of-Fit Techniques, page 123-128 & 372-373. 1st ed. Routledge. https://doi.org/10.1201/9780203753064

Examples

Anderson_Darling_test(leghorn_chick)


D'Agostino-Pearson K2 Normality Test

Description

The D'Agostino–Pearson Chi-square (K2) test is a statistical test for assessing whether a sample comes from a normal distribution. It combines information from skewness (asymmetry) and kurtosis (tail heaviness) into a single omnibus test statistic.

Usage

D.Agostino_Pearson_test(
  x,
  alpha = 0.05,
  alternative = c("two.sided", "less", "greater"),
  min_n = 20
)

Arguments

x

A numeric vector.

alpha

Significance threshold (default: 0.05).

alternative

Character (default: "two.sided). The alternative hypothesis (H1) to test. Available options are c("two.sided", "less", "greater"). Note that, this is only applied on skewness and kurtosis test.

min_n

Integer. The minimum observations required (default: 20).

Value

A list:

References

D’agostino, R.B., Belanger, A., D’agostino, R.B., 1990. A Suggestion for Using Powerful and Informative Tests of Normality. The American Statistician 44, 316–321. https://doi.org/10.1080/00031305.1990.10475751

Examples

D.Agostino_Pearson_test(cholesterol)


Cholesterol data

Description

A numeric vector, the cholesterol values from a sample of 62 subjects from the Framingham Heart Study (FHS). This dataset was obtained from D'Agostino paper.

Usage

cholesterol

Format

A numeric vector length of 62.

References

D’agostino, R.B., Belanger, A., D’agostino, R.B., 1990. A Suggestion for Using Powerful and Informative Tests of Normality. The American Statistician 44, 316–321. https://doi.org/10.1080/00031305.1990.10475751


Kurtosis test

Description

Kurtosis test

Usage

kurtosis(
  x,
  alpha = 0.05,
  alternative = c("two.sided", "less", "greater"),
  method = c("G2", "b2", "g2")
)

Arguments

x

Numeric vector. The input data.

alpha

Numeric (default: 0.05). Significance threshold (0 - 1).

alternative

Character (default: "two.sided). The alternative hypothesis (H1) to test. Available options are c("two.sided", "less", "greater").

method

Character (default: "G2"). Different skewness formula. Available options are c("G2", "b2", "g2"). The "g2" is the original one. The "G2" and "b2" are the unbiased estimate version of "g2".

Value

A list: is_normal: Is the input data normally distributed? method: The name of the test. alpha: Significance threshold (default: 0.05). alternative: The alternative hypothesis (H1) to test. summary_table: Statistic summary, if any. statistic: The value used to calculate p-value. pvalue: p-value. confidence_interval: The lower and upper bound of CI.

References

Joanes, D.N., Gill, C.A., 1998. Comparing measures of sample skewness and kurtosis. J Royal Statistical Soc D 47, 183–189. https://doi.org/10.1111/1467-9884.00122

Wright, D.B., Herrington, J.A., 2011. Problematic standard errors and confidence intervals for skewness and kurtosis. Behav Res 43, 8–17. https://doi.org/10.3758/s13428-010-0044-x

Examples

x <- c(10:17, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 15, 15)
kurtosis(x)

Leghorn chicken data

Description

A numeric vector

Usage

leghorn_chick

Format

A numeric vector length of 20.

References

D’Agostino, RalphB., 2017. Goodness-of-Fit Techniques, page 98 (Table 4.1). 1st ed. Routledge. https://doi.org/10.1201/9780203753064


Standard output format

Description

The standard output format for normality package.

Usage

normality_standard_output(
  method = "what test?",
  is_normal = NA,
  alpha = NA_real_,
  alternative = c("two.sided", "less", "greater"),
  summary_table = NULL,
  statistic = NA_real_,
  pvalue = NA_real_,
  confidence_interval = c(lower = NA_real_, upper = NA_real_)
)

Arguments

method

Character. The name of the test.

is_normal

Logical. Is the input data normally distributed?

alpha

Numeric (default: 0.05). Significance threshold.

alternative

Character. The alternative hypothesis (H1) to test. Available options are c("two.sided", "less", "greater").

summary_table

Statistic summary, if any.

statistic

Numeric. The value used to calculate p-value.

pvalue

Numeric. The p-value of the test.

confidence_interval

Numeric vector of length 2. The lower and upper bound of CI.

Value

A list contains 8 vectors.


Skewness test

Description

Skewness test

Usage

skewness(
  x,
  alpha = 0.05,
  alternative = c("two.sided", "less", "greater"),
  method = c("G1", "b1", "g1")
)

Arguments

x

Numeric vector. The input data.

alpha

Numeric (default: 0.05). Significance threshold (0 - 1).

alternative

Character (default: "two.sided). The alternative hypothesis (H1) to test. Available options are c("two.sided", "less", "greater").

method

Character (default: "G1"). Different skewness formula. Available options are c("G1", "b1", "g1"). The "g1" is the original one. The "G1" and "b1" are the unbiased estimate version of "g1".

Value

A list: is_normal: Is the input data normally distributed? method: The name of the test. alpha: Significance threshold (default: 0.05). alternative: The alternative hypothesis (H1) to test. summary_table: Statistic summary, if any. statistic: The value used to calculate p-value. pvalue: p-value. confidence_interval: The lower and upper bound of CI.

References

Joanes, D.N., Gill, C.A., 1998. Comparing measures of sample skewness and kurtosis. J Royal Statistical Soc D 47, 183–189. https://doi.org/10.1111/1467-9884.00122

Wright, D.B., Herrington, J.A., 2011. Problematic standard errors and confidence intervals for skewness and kurtosis. Behav Res 43, 8–17. https://doi.org/10.3758/s13428-010-0044-x

Examples

skewness(cholesterol)