## Stata 15 help for sfrancia

[R] swilk -- Shapiro-Wilk and Shapiro-Francia tests for normality

Syntax

Shapiro-Wilk normality test

swilk varlist [if] [in] [, swilk_options]

Shapiro-Francia normality test

sfrancia varlist [if] [in] [, sfrancia_options]

swilk_options Description ------------------------------------------------------------------------- Main generate(newvar) create newvar containing W test coefficients lnnormal test for three-parameter lognormality noties do not use average ranks for tied values -------------------------------------------------------------------------

sfrancia_options Description ------------------------------------------------------------------------- Main boxcox use the Box-Cox transformation for W'; the default is to use the log transformation noties do not use average ranks for tied values -------------------------------------------------------------------------

by is allowed with swilk and sfrancia; see [D] by.

swilk

Statistics > Summaries, tables, and tests > Distributional plots and tests > Shapiro-Wilk normality test

sfrancia

Statistics > Summaries, tables, and tests > Distributional plots and tests > Shapiro-Francia normality test

Description

swilk performs the Shapiro-Wilk W test for normality for each variable in the specified varlist. Likewise, sfrancia performs the Shapiro-Francia W' test for normality. See [MV] mvtest normality for multivariate tests of normality.

Options for swilk

+------+ ----+ Main +-------------------------------------------------------------

generate(newvar) creates new variable newvar containing the W test coefficients.

lnnormal specifies that the test be for three-parameter lognormality, meaning that ln(X-k) is tested for normality, where k is calculated from the data as the value that makes the skewness coefficient zero. When simply testing ln(X) for normality, do not specify this option. See [R] lnskew0 for estimation of k.

noties suppresses use of averaged ranks for tied values when calculating the W test coefficients.

Options for sfrancia

+------+ ----+ Main +-------------------------------------------------------------

boxcox specifies that the Box-Cox transformation of Royston (1983) for calculating W' test coefficients be used instead of the default log transformation (Royston 1993). Under the Box-Cox transformation, the normal approximation to the sampling distribution of W', used by sfrancia, is valid for 5<=n<=1000. Under the log transformation, it is valid for 10<=n<=5000.

noties suppresses use of averaged ranks for tied values when calculating the W' test coefficients.

Remarks

swilk can be used with 4<=n<=2000 observations. sfrancia can be used with 10<=n<=5000 observations; however, if the boxcox option is specified, it can be used with 5<=n<=1000 observations.

Examples

--------------------------------------------------------------------------- Setup . sysuse auto

Test whether mpg and trunk are normally distributed . swilk mpg trunk

--------------------------------------------------------------------------- Setup . sysuse cancer . generate lnstudytime = ln(studytime)

Test that studytime is distributed lognormally . swilk lnstudytime

Test that ln(studytime - k) is normally distributed, where k is chosen so that the resulting skewness is zero . lnskew0 lnstudytimek = studytime, level(95) . swilk lnstudytimek, lnnormal

--------------------------------------------------------------------------- Setup . webuse lbw, clear

Perform Shapiro-Francia normality test using default log transformation . sfrancia bwt

Perform Shapiro-Francia normality test using Box-Cox transformation . sfrancia bwt, boxcox

---------------------------------------------------------------------------

Stored results

swilk and sfrancia store the following in r():

Scalars r(N) number of observations r(p) p-value r(z) z statistic r(W) W or W' r(V) V or V'

References

Royston, P. 1983. A simple method for evaluating the Shapiro-Francia W' test for non-normality. Statistician 32: 297-300.

------. 1993. A pocket-calculator algorithm for the Shapiro-Francia test for non-normality: An application to medicine. Statistics in Medicine 12: 181-184.