Skip to contents

Performs the Shapiro-Francia test for normality, which is similar to the Shapiro-Wilk test but designed to handle larger sample sizes (up to 5000 observations).

Usage

sf.test(x)

Arguments

x

A numeric vector of data values. Missing values will be automatically removed.

Value

A list with class "htest" containing the following components:

  • statistic - The Shapiro-Francia test statistic (W)

  • p.value - The p-value for the test

  • method - The name of the method ("Shapiro-Francia normality test")

  • data.name - The name of the data used in the test

Details

The Shapiro-Francia test is a powerful test for normality that is particularly useful for larger sample sizes where the Shapiro-Wilk test may not be applicable. The test is based on the correlation between the ordered sample values and the corresponding normal quantiles.

The test procedure involves:

  1. Sorting the data and computing normal quantiles using qnorm with ppoints (Blom's method with a = 3/8)

  2. Calculating the squared correlation coefficient between the ordered data and the normal quantiles: \(W = [cor(x, y)]^2\)

  3. Transforming the statistic using: \(z = (\log(1 - W) - \mu) / \sigma\)

  4. Computing the p-value from the standard normal distribution

The parameters for the transformation are: $$\mu = -1.2725 + 1.0521 \times (\log(u) - u)$$ $$\sigma = 1.0308 - 0.26758 \times (\log(u) + 2/u)$$ where \(u = \log(n)\) and \(n\) is the sample size.

Note

The Shapiro-Francia test has the following limitations:

  • Sample size must be between 5 and 5000

  • The test may be less powerful than the Shapiro-Wilk test for small samples

  • For sample sizes > 5000, consider using other tests like Anderson-Darling or Cramer-von Mises

References

This implementation is based on the nortest package:

Shapiro, S.S. and Francia, R.S. (1972). An Approximate Analysis of Variance Test for Normality. Journal of the American Statistical Association, 67(337), 215-216.

Royston, P. (1993). A Pocket-Calculator Algorithm for the Shapiro-Francia Test for Non-Normality: An Application to Medicine. Statistics in Medicine, 12(2), 181-184.

Thode, H.C. (2002). Testing for Normality. Marcel Dekker, New York.

See also

shapiro.test for the Shapiro-Wilk normality test (limited to 5000 observations). ad.test for the Anderson-Darling normality test. cvm.test for the Cramer-von Mises normality test. pearson.test for the Pearson chi-square normality test. ppoints for the generation of probability points. qnorm for the normal quantile function.

Other normality_test: ad.test(), cvm.test(), dagostino.test(), jb.test.modified(), pearson.test()

Examples

if (FALSE) { # \dontrun{
# Test a sample from normal distribution
set.seed(123)
normal_data <- stats::rnorm(100)
sf.test(normal_data)

# Test a sample from non-normal distribution
exponential_data <- stats::rexp(50)
sf.test(exponential_data)

# Test with real data
if (require("datasets")) {
  sf.test(iris$Sepal.Length)
}
} # }