mctest {gsse401} | R Documentation |
Performs Monte Carlo tests for paired or two-sample analysis.
A graphical display of the results is produced by plot.mctest
.
mctest(x, y, paired = TRUE, nsim, plot = TRUE) plot(x) print(x)
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. |
Paired data
(mean(d))/(sqrt(Var(d)/n))
mbox{}
Two-sample
For two-sample test a randomization test is performed as follows:
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))
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.
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 |
mbox{}
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.
Peter J. Diggle p.diggle@lancaster.ac.uk
Paulo Justiniano Ribeiro Jr. p.ribeiro@lancaster.ac.uk.
## ## A two-sample test ## data(mandible) mctest(mandible$female, mandible$male, paired = FALSE) # # For an interactive input type: mctest()