ClassicalTests            package:fBasics            R Documentation

_C_l_a_s_s_i_c_a_l _S_t_a_t_i_s_t_i_c_a_l _T_e_s_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     A collection and description of functions for  conventional
     statistical tests. Most tests are  selected from R's 'cTest' and
     'nortest' packages.  The tests may be of interest for many
     financial and  economic applications.  

     The functions are:

       'ansariTest'    Ansari-Bradley's test for differences in scale,
       'bartlettTest'  Bartlett's test for differences in variances,
       'corTest'       A test for association between paired samples,
       'flignerTest'   Fligner-Killeen's test for differences in variances,
       'ksTest'        One or two sample Kolmogorov-Smirnov tests,
       'moodTest'      Mood's test for differences in scale parameters,
       'shapiroTest'   Shapiro-Wilk's test for normality,
       'varTest'       F test for differences in variances,
       'dagoTest'      D'Agostino normality test,
       'normalTest'    S-Plus like Test for Shapiro-Wilk and Jarque-Bera tests,
       'runsTest'      Runs test for detecting non-randomness,
       'gofnorm'       Prints a report on 13 different tests of normality.

     The following tests are available from the '"nortest"' package: 

       'adTest'       Anderson-Darling normality test,
       'cvmTest'      Cramer-von Mises normality test,
       'lillieTest'   Lilliefors (Kolmogorov-Smirnov) normality test,
       'pearsonTest'  Pearson chi-square normality test,
       'sfTest'       Shapiro-Francia normality test.

_U_s_a_g_e:

     ansariTest(x, y, ...)
     bartlettTest(x, g, ...)
     corTest(x, y, alternative = <<see below>>, method = <<see below>>, ...)
     flignerTest(x, g, ...)
     ksTest(x, y, alternative = <<see below>>, ...)
     moodTest(x, y, alternative = <<see below>>, ...)
     shapiroTest(x)
     varTest(x, y, alternative = <<see below>>, ...)

     adTest(x)            
     cvmTest(x)      
     lillieTest(x) 
     pearsonTest(x, n.classes = <<see below>>, adjust = TRUE)    
     sfTest(x)   

     dagoTest(x, method = c("omnibus", "skewness", "kurtosis"))
     normalTest(x, method = <<see below>>) 

     runsTest(x)

     gofnorm(x, doprint = TRUE)

_A_r_g_u_m_e_n_t_s:

  adjust: 

alternative: indicates the alternative hypothesis; must be one of the 
          entries specified by the input vector 'c("two.sided", 
          "less", "greater")'. 

 doprint: if TRUE, an exhaustive report is printed. 

       g: a vector or factor object giving the group for the
          corresponding elements of 'x'. Ignored if 'x'  is a list. 

  method: [corTest] - 
           indicates the three different methods for the correlation
          test; must be one of the entries specified by the input 
          vector 'c("pearson", "kendall", "spearman")'. [dagoTest] - 
           selects the kind of test to be performed, either the
          '"omnibus"' (by default), the '"skewness"' or  the
          '"kurtosis"' test. A character string. [normalTest] - 
           indicates the two different methods for the normality test,
          Shapiro-Wilk or Jarque-Bera Test. Must be one of  the entries
          specified by the input vector 'c("sw", "jb")'. 

n.classes: [pearsonTest] - 
           the number of classes. The default is due to Moore (1986):
          'n.classes = ceiling(2 * (n^(2/5)))'. 

    x, y: a numeric vector of data values. 

     ...: arguments passed to the underlying function from R's 'ctest'
          package. Consult the appropriate manual pages. 

_D_e_t_a_i_l_s:

     *Report from gofnorm:* 

      The function reports the following goodness-of-fit tests for
     normality:

        1  Omnibus Moments Test for Normality
        2  Geary's Test of Normality
        3  Studentized Range for Testing Normality
        4  D'Agostino's D-Statistic Test of Normality
        5  Kuiper V-Statistic Modified to Test Normality
        6  Watson U-Squared-Statistic Modified to Test Normality
        7  Durbin's Exact Test (Normal Distribution
        8  Anderson-Darling Statistic Modified to Test Normality
        9  Cramer-Von Mises W-Squared-Statistic to Test Normality
       10  Kolmogorov-Smirnov D-Statistic to Test Normality
       11  Kolmogorov-Smirnov D-Statistic (Lilliefors Critical Values)
       12  Chi-Square Test of Normality (Equal Probability Classes)
       13  Shapiro-Francia W-Test of Normality for Large Samples

     The functions are implemented from the GRASS GIS software package
     an Open Source project avalaible under the GNU GPL license.

_V_a_l_u_e:

     The tests return a list with class '"htest"' containing  the
     following components:

statistic: the value of the test statistic. 

 p.value: the p-value of the test. 

alternative: a character string describing the alternative hypothesis. 

  method: a character string indicating what type of test was
          performed. 

data.name: a character string giving the name(s) of the data. 

_A_u_t_h_o_r(_s):

     R-core 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,
      Paul Johnson for the Fortran program producing the gofnorm
     report, 
      Diethelm Wuertz for the Rmetrics R-port.

_R_e_f_e_r_e_n_c_e_s:

     Anderson T.W., Darling D.A. (1954);  _A Test of Goodness of Fit_,
     JASA 49:765-69.

     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, 613-22.

     D'Agostino R.B., Rosman B. (1974);  _The Power of Geary's Test of
     Normality_, Biometrika 61, 181-84.

     Durbin J. (1961);  _Some Methods of Constructing Exact Tests_,
     Biometrika 48, 41-55. 

     Durbin,J. (1973); _Distribution Theory Based on the Sample
     Distribution Function_, SIAM, Philadelphia.

     Geary R.C. (1947);  _Testing for Normality_;  Biometrika 36,
     68-97.

     Kotz S. (1973);  _Normality versus Lognormality with
     Applications_, Communications in Statistics 1, 113-32.

     Lehmann E.L. (1986);  _Testing Statistical Hypotheses_,  John
     Wiley and Sons, New York.

     Linnet K. (1988);  _Testing Normality of Transformed Data_,
     Applied Statistics 32, 180-186. 

     Moore, D.S. (1986); _Tests of the chi-squared type_,  In:
     D'Agostino, R.B. and Stephens, M.A., eds.,  Goodness-of-Fit
     Techniques, Marcel Dekker, New York. 

     Shapiro S.S., Francia R.S. (1972);  _An Approximate Analysis of
     Variance Test for Normality_, JASA 67, 215-216.

     Shapiro S.S., Wilk M.B., Chen V. (1968);  _A Comparative Study of
     Various Tests for Normality_, JASA 63, 1343-72.

     Thode H.C. (2002); _Testing for Normality_,  Marcel Dekker, New
     York. 

     Weiss, M.S. (1978);  _Modification of the Kolmogorov-Smirnov 
     Statistic for Use with Correlated Data_,  JASA 73, 872-75.

_E_x_a_m_p_l_e_s:

     ## ansariTest - moodTest - varTest -
        xmpBasics("\nStart: Ansari/Mood/Var Test > ")
        # Differences in scale / variances:
        data(nyseres)
        x = nyseres[4001:5000, 1]
        y = nyseres[6001:7000, 1]
        p = c(
          ansariTest(x, y)$p.value,
          moodTest(x, y)$p.value,
          varTest(x, y)$p.value)
        test = c("ansari", "mood", "var") 
        data.frame(test, p)
        
     ## ansariTest - moodTest - varTest -
        xmpBasics("\nNext: Ansari/Mood/Var Test > ")
        # Differences in scale / variances:
        x = rnorm(1000)
        y = rnorm(1000)
        p = c(
          ansariTest(x, y)$p.value,
          moodTest(x, y)$p.value,
          varTest(x, y)$p.value)
        test = c("ansari", "mood", "var") 
        data.frame(test, p)
        
     ## gofnorm -
        xmpBasics("\nNext: Goodness-of-Fit Test for Normality > ")  
        x = nyseres[1:1000, 1]
        # Standardize the data:
        x = (x-mean(x))/sqrt(var(x))
        # Test:
        r = gofnorm(x, doprint = TRUE)
        
     ## ksTest -
        # unique: remove ties:
        xmpBasics("\nNext: Kolmogorov-Smirnov Goodness-of-Fit Test > ")
        nyseres = unique(nyseres[, 1])
        ksTest(nyseres, "pnorm")
        # Do x and y come from the same distribution?
        x = nyseres[1:(length(nyseres)/2)]
        y = nyseres[(length(nyseres)/2+1):length(nyseres)]
        ksTest(x, y)
        # Does x come from an alpha stable distribution?
        alpha = scalinglawPlot(nyseres, doplot = FALSE)$exponent
        ksTest(x = nyseres, y = "psymstb", alpha, alternative = "gr")
        
     ## runsTest -
        xmpBasics("\nNext: Runs Test > ")
        runsTest(nyseres)
        runsTest(rnorm(length(nyseres)))

