Tests for normality
testnormalityTests.Rd
A collection of functions of one sample tests for testing normality
of financial return series.
The functions for testing normality are:
ksnormTest  KolmogorovSmirnov normality test, 
shapiroTest  ShapiroWilk's test for normality, 
jarqueberaTest  JarqueBera test for normality, 
dagoTest  D'Agostino normality test. 
Functions for high precision Jarque Bera LM and ALM tests:
jbTest  Performs finite sample adjusted JB, LM and ALM test. 
Additional functions for testing normality from the 'nortest' package:
adTest  AndersonDarling normality test, 
cvmTest  Cramervon Mises normality test, 
lillieTest  Lilliefors (KolmogorovSmirnov) normality test, 
pchiTest  Pearson chisquare normality test, 
sfTest  ShapiroFrancia normality test. 
For SPlus/Finmetrics Compatibility:
normalTest  test suite for some normality tests. 
Usage
ksnormTest(x, title = NULL, description = NULL)
jbTest(x, title = NULL, description = NULL)
shapiroTest(x, title = NULL, description = NULL)
normalTest(x, method = c("sw", "jb"), na.rm = FALSE)
jarqueberaTest(x, title = NULL, description = NULL)
dagoTest(x, title = NULL, description = NULL)
adTest(x, title = NULL, description = NULL)
cvmTest(x, title = NULL, description = NULL)
lillieTest(x, title = NULL, description = NULL)
pchiTest(x, title = NULL, description = NULL)
sfTest(x, title = NULL, description = NULL)
Arguments
 x
a numeric vector of data values or an S4 object of class
"timeSeries"
. title

an optional character string, if not specified the inputs data name is deparsed.
 description

optional description string, or a vector of character strings.
 method

for
normalTest
only, indicates one of four different methods for the normality test, one of"ks"
(KolmogorovSmirnov onesample test, the the default),"sw"
(ShapiroWilk test),"jb"
(JarqueBera Test), and"da"
(D'Agostino Test).  na.rm

for
normalTest
only, a logical value. Should missing values removed before computing the tests? The default value isFALSE
.
Details
The hypothesis tests may be of interest for many financial and economic applications, especially for the investigation of univariate time series returns.
Several tests for testing if the records from a data set are normally
distributed are available. The input to all these functions may be
just a vector x
or a univariate time series object x
of class timeSeries
.
First, there exists a wrapper function which allows to call one from two normal tests either the ShapiroWilks test or the JarqueBera test. This wrapper was introduced for compatibility with SPlus' FinMetrics package.
Also available are the KolmogorovSmirnov one sample test and the D'Agostino normality test.
The remaining five normal tests are the AndersonDarling test,
the Cramervon Mises test, the Lilliefors (KolmogorovSmirnov)
test, the Pearson chisquare test, and the ShapiroFrancia test.
They are calling functions from R's contributed package nortest
.
The difference to the original test functions implemented in R and
from contributed R packages is that the Rmetrics functions accept
time series objects as input and give a more detailed output report.
The AndersonDarling test is used to test if a sample of data came
from a population with a specific distribution, here the normal
distribution. The adTest
goodnessoffit test can be
considered as a modification of the KolmogorovSmirnov test which
gives more weight to the tails than does the ksnormTest
.
Note that jarqueBeraTest
computes the asymptotic statistic
and pvalue, while jbTesT
gives final sample approximations.
Value
an object from class fHTEST
Slot test
is a list containing the following (optionally empty)
elements (in addition to those described in fHTEST
):
 ksnormTest

the 'D' statistic and pvalues for the three alternatives 'twosided, 'less' and 'greater'.
 shapiroTest

the 'W' statistic and the pvalue.
 jarqueberaTest
no additional elements.
 jbTest

the 'Chisquared' statistic with 2 degrees of freedom and the asymptotic pvalue.
jbTest
is the finite sample version of the Jarque Bera Lagrange multiplier, LM, and adjusted Lagrange multiplier test, ALM.  dagoTest

the 'Chisquared', the 'Z3' (Skewness) and 'Z4' (Kurtosis) statistic together with the corresponding p values.
 adTest

the 'A' statistic and the pvalue.
 cvmTest

the 'W' statistic and the pvalue.
 lillieTest
the 'D' statistic and the pvalue.
 pchiTest

the value for the 'P' statistic and the pvalues for the adjusted and not adjusted test cases. In addition the number of classes is printed, taking the default value due to Moore (1986) computed from the expression
n.classes = ceiling(2 * (n^(2/5)))
, wheren
is the number of observations.  sfTest
the 'W' statistic and the pvalue.
References
Anderson T.W., Darling D.A. (1954); A Test of Goodness of Fit, JASA 49:76569.
Conover, W. J. (1971); Practical nonparametric statistics, New York: John Wiley & Sons.
D'Agostino R.B., Pearson E.S. (1973); Tests for Departure from Normality, Biometrika 60, 61322.
D'Agostino R.B., Rosman B. (1974); The Power of Geary's Test of Normality, Biometrika 61, 18184.
Durbin J. (1961); Some Methods of Constructing Exact Tests, Biometrika 48, 4155.
Durbin,J. (1973); Distribution Theory Based on the Sample Distribution Function, SIAM, Philadelphia.
Geary R.C. (1947); Testing for Normality; Biometrika 36, 6897.
Lehmann E.L. (1986); Testing Statistical Hypotheses, John Wiley and Sons, New York.
Linnet K. (1988); Testing Normality of Transformed Data, Applied Statistics 32, 180186.
Moore, D.S. (1986); Tests of the chisquared type, In: D'Agostino, R.B. and Stephens, M.A., eds., GoodnessofFit Techniques, Marcel Dekker, New York.
Shapiro S.S., Francia R.S. (1972); An Approximate Analysis of Variance Test for Normality, JASA 67, 215216.
Shapiro S.S., Wilk M.B., Chen V. (1968); A Comparative Study of Various Tests for Normality, JASA 63, 134372.
Thode H.C. (2002); Testing for Normality, Marcel Dekker, New York.
Weiss M.S. (1978); Modification of the KolmogorovSmirnov Statistic for Use with Correlated Data, JASA 73, 87275.
Wuertz D., Katzgraber H.G. (2005); Precise finitesample quantiles of the JarqueBera adjusted Lagrange multiplier test, ETHZ Preprint.
Author
Rcore team for the tests from R's ctest package,
Adrian Trapletti for the runs test from R's tseries package,
Juergen Gross for the normal tests from R's nortest package,
James Filliben for the Fortran program producing the runs report,
Diethelm Wuertz and Helmut Katzgraber for the finite sample JB tests,
Diethelm Wuertz for the Rmetrics Rport.
Earlier versions of theses functions were based on Fortran code of Paul Johnson.
Examples
set.seed(1234)
## Series:
x = rnorm(100)
## ksnormTests 
# Kolmogorov  Smirnov OneSampel Test
ksnormTest(x)
#>
#> Title:
#> Asymptotic onesample KolmogorovSmirnov test
#>
#> Test Results:
#> STATISTIC:
#> D: 0.055
#> P VALUE:
#> Alternative TwoSided: 0.9224
#> Alternative Less: 0.6972
#> Alternative Greater: 0.5456
#>
## shapiroTest  ShapiroWilk Test
shapiroTest(x)
#>
#> Title:
#> Shapiro  Wilk Normality Test
#>
#> Test Results:
#> STATISTIC:
#> W: 0.9905
#> P VALUE:
#> 0.7034
#>
## jarqueberaTest 
# Jarque  Bera Test
# jarqueberaTest(x)
# jbTest(x)