mctest                  package:pad                  R Documentation

_P_A_D  -  _P_a_i_r_e_d _a_n_d _t_w_o-_s_a_m_p_l_e _M_o_n_t_e _C_a_r_l_o _t_e_s_t_s

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

     Performs Monte Carlo tests for paired or two-sample analysis.
      A graphical display of the results is produced by 'plot.mctest'.

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

     mctest(x, y, paired = TRUE, nsim, plot = TRUE)

     ## S3 method for class 'mctest':
     plot(x, tcurve = TRUE, ...)

     ## S3 method for class 'mctest':
     print(x, ...)

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

       x: a numeric vector with data on first variable

       y: a numeric vector with data on the second variable

  paired: logical indicating whether a paired test should be performed.
          Defualts to 'FALSE' which implies the two-sample analysis.  

    nsim: an integer with the number of Monte Carlo samples. Defaults
          to 1000.  

    plot: logical. If 'TRUE' plot is automaticaly produced.  

  tcurve: logical indicating whether the curve of the t distribution
          should be added to the plot.  

     ...: unused.  

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

     *Paired data*

   _1 For the n pairs of data (x_i, y_i) compute the differences d_i =
        x_i - y_i and then the test statistic:

                      (mean(d))/(sqrt(Var(d)/n))


   _2 For each pair re-allocate the two data to the two groups randomly.
         Then re-compute the test statistics above. 

   _3 repeat the previous step nsim times. This generates an empirical
        distribution for the test statistics.  

   _4 compare the statistics computed for the data with the empirical
        distribution.

     *Two-sample*

     For two-sample test a randomization test is performed as follows:

   _1 For two independent samples x and y of sizes n_x and n_y define

       S^2 = ((n_x-1) Var(x) + (n_y -1) Var(y))/(n_x + n_y - 2)

        and compute the  following statistics:

           (mean(x) - mean(y))/sqrt(S^2 * (1/n_x + 1/n_y))


   _2 Pool n_x + n_y data together and re-allocate to the two groups of
        sizes n_x and n_y randomly.

   _3 repeat the previous step nsim times. This generates an empirical
        distribution for the test statistics.  

   _4 compare the statistics computed for the data with the empirical
        distribution.

     For both cases the test statistic for the original data is
     compared against the empirical distribution in order to produce
     _P-values_. Upper and lower tail probabilities are computed by
     counting how many values of the statistic computed for the
     simulated data are above and below the value obtained for the
     original data.

     Additionally, _P-values_ based on the 't' distribution are also
     reported.

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

     The function 'mctest' returns an object of the class 'mctest'
     which is a list with components: 

       p: a numerical vector with upper and lower tail probabilities
          based on the empirical distribution.  

      pt: a numerical vector with upper and lower tail probabilities
          based on the 't' distribution.  

data.statistic: the statistics above computed for the original data.  

sim.statistic: the statistics above computed for each simulations.  

     The function 'plot.mctest' produces a histogram of the empirical
     distribution with an indication to the value of the data
     statistics. A 't' distribution can be added to the plot.

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

     Peter J. Diggle p.diggle@lancaster.ac.uk 
      Paulo Justiniano Ribeiro Jr. p.ribeiro@lancaster.ac.uk.

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

     ##
     ## A two-sample test
     ##
     data(mandible)
     mctest(mandible$female, mandible$male, paired = FALSE)
     #
     # For an interactive input type:
     ## Not run: 
     mctest()
     ## End(Not run)

