normalTest test suite for some normality tests,
ksnormTest Kolmogorov-Smirnov normality test,
shapiroTest Shapiro-Wilk's test for normality,
jarqueberaTest Jarque--Bera test for normality,
dagoTest D'Agostino normality test. }
Additional functions for testing normality from the 'nortest' package:
adTest Anderson--Darling normality test,
cvmTest Cramer--von Mises normality test,
lillieTest Lilliefors (Kolmogorov-Smirnov) normality test,
pchiTest Pearson chi--square normality test,
sfTest Shapiro--Francia normality test. }
More tests ...
runsTest Runs test for detecting non-randomness,
gofnorm Prints a report on 13 different tests of normality. }normalTest(x, method = c("ks", "sw", "jb", "da"))
ksnormTest(x, title = NULL, description = NULL)
shapiroTest(x, title = NULL, description = NULL)
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)
runsTest(x)
gofnorm(x, doprint = TRUE)"ks" for the Kolmogorov-Smirnov one--sample test,
"sw" for the Shapiro-Wilk test,
"jb" for the Jarque-Bera Test, atimeSeries."htest"
a different output report is produced. The tests here return an S4
object of class "fHTEST". The object contains the following slots:@test returns an object of class "list"
containing the following (otionally empty) elements:@test slot is the following:
ksnormTest
returns the values for the 'D' statistic and p-values for the three
alternatives 'two-sided, 'less' and 'greater'.
shapiroTest
returns the values for the 'W' statistic and the p-value.
jarqueberaTest
returns the values for the 'Chi-squared' statistic with 2 degress of
freedom, and the asymptotic p-value.
dagoTest
returns the values for the 'Chi-squared', the 'Z3' (Skewness) and 'Z4'
(Kurtosis) statistic together with the corresponding p values.
adTest
returns the value for the 'A' statistic and the p-value.
cvmTest
returns the value for the 'W' statistic and the p-value.
lillieTest
returns the value for the 'D' statistic and the p-value.
pchiTest
returns the value for the 'P' statistic and the p-values 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))),
where n is the number of observations.
sfTest
returns the value for the 'W' statistic and the p-value.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 Shapiro--Wilks test or the Jarque--Bera
test. This wrapper was introduced for compatibility with S-Plus'
FinMetrics package.
Also available are the Kolmogorov--Smirnov one sample test and the
D'Agostino normality test.
The remaining five normal tests are the Anderson--Darling test,
the Cramer--von Mises test, the Lilliefors (Kolmogorov--Smirnov)
test, the Pearson chi--square test, and the Shapiro--Francia 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 Anderson-Darling test is used to test if a sample of data came
from a population with a specific distribution, here the normal
distribution. The adTest goodness-of-fit test can be
considered as a modification of the Kolmogorov--Smirnov test which
gives more weight to the tails than does the ksnormTest.
Runs Test:
The runs test can be used to decide if a data set is from a random
process. A run is defined as a series of increasing values or a
series of decreasing values. The number of increasing, or decreasing,
values is the length of the run. In a random data set, the probability
that the (i+1)-th value is larger or smaller than the i-th
value follows a binomial distribution, which forms the basis of the
runs test.
Report from gofnorm Tests:
The function reports about the following goodness-of-fit tests
for normality:
## SOURCE("fBasics.A0-SPlusCompatibility")
## SOURCE("fBasics.C1-TestsClass")
## SOURCE("fBasics.C2-OneSampleTests")
## Series:
xmpBasics("Start: Create Series > ")
x = rnorm(100)
## ksnormTests -
xmpBasics("Next: Kolmogorov - Smirnov One-Sampel Test > ")
ksnormTest(x)
## shapiroTest -
xmpBasics("Next: Shapiro - Wilk Test > ")
shapiroTest(x)
## jarqueberaTest -
xmpBasics("Next: Jarque - Bera Test > ")
jarqueberaTest(x)
## dagoTest -
xmpBasics("Next: D'Agostino Test > ")
dagoTest(x)
## adTest -
xmpBasics("Next: Anderson - Darling Test > ")
adTest(x)
## cvmTest -
xmpBasics("Next: Cramer - von Mises Test > ")
cvmTest(x)
## lillieTest -
xmpBasics("Next: Lillifors (KS) Test > ")
lillieTest(x)
## pchiTest -
xmpBasics("Next: Pearson Chi-Squared Test > ")
pchiTest(x)
## sfTest -
xmpBasics("Next: Shapiro - Franca Test > ")
sfTest(x)
## gofnorm -
xmpBasics("Next: Goodness-of-Fit Test for Normality > ")
gofnorm(x, doprint = TRUE)
## runsTest -
xmpBasics("Next: Runs Test > ")
runsTest(x)Run the code above in your browser using DataLab