permTS),
k-sample permutation tests (permKS), or trend permutation tests (permTREND).
The test function can be transformed to a linear function of the scores times the covariate, where the covariate
may be either a factor or character vector with two (permTS) or more (permKS) levels or a
numeric vector (permTREND). By using suitable scores one can create
for example, the permutation t-test (general scores), the Wilcoxon rank sum test (rank scores),
the logrank test (need to use other functions to create these scores). It performs either
exact (network algorithm, complete enumeration, or Monte Carlo) asymptotic calculations (using permutational
central limit theorem).permTS(x, ...)
## S3 method for class 'default':
permTS(x, y, alternative = c("two.sided", "less", "greater" ,"two.sidedAbs"),
exact = NULL, method = NULL, methodRule = methodRuleTS1,
control=permControl(), ...)
## S3 method for class 'formula':
permTS(formula, data, subset, na.action, \dots)
permKS(x,...)
## S3 method for class 'default':
permKS(x, g, exact = NULL, method = NULL, methodRule = methodRuleKS1, control=permControl(), ...)
## S3 method for class 'formula':
permKS(formula,data,subset, na.action,\dots)
permTREND(x,...)
## S3 method for class 'default':
permTREND(x, y, alternative = c("two.sided", "less", "greater","two.sidedAbs"), exact = NULL, method = NULL, methodRule = methodRuleTREND1, control=permControl(),...)
## S3 method for class 'formula':
permTREND(formula,data,subset,na.action,\dots)permControlhtest or for 'exact.mc' of class mchtest,
a list with the following elements:calcPvalsMC)permTS the test statistic
is equivalent to the mean of one group minus the mean of the other group. For permTREND the test
statistic is equivalent to the correlation between the response (x) and the trend scores (y).
For permKS only a twosided pvalue based on Pr[Ti>=T0] is allowed, where the test statistic, Ti, is the
weighted sum of the square of the mean within group, where the weights are the sample size for each group. This will
give for example, the usual Kruskal-Wallis test when the ranks are used on the responses.
Many standard statistical tests may be put into the form of the permutation test (see Graubard and Korn, 1987).
There is a choice of four different methods to calculate the p-values (the last two are only available for
permTS):
(1) pclt: using permutational central limit theorem (see e.g., Sen, 1985).
(2) exact.mc:exact using Monte Carlo.
(3) exact.network: exact method using a network algorithm (see e.g., Agresti, Mehta, and Patel, 1990). Currently the network
method does
not implement many of the time saving suggestions such as clubbing.
(4) exact.ce: exact using complete enumeration. This is good for very small sample sizes and when doing simulations, since the cm need only
be calculated once for the simulation.
These associated functions for the above methods (e.g., twosample.pclt, twosample.exact.network, etc),
are internal and are not to be called directly.
The methodRule is a function which takes the first two objects of the default implementation, and returns the
method. This function can be used to appropriately choose the method based on the size of the data.
For explanation of the default method rules see methodRuleTS1, methodRuleKS1, or
methodRuleTREND1.=t0],>## Example from StatExact manual
dBP<-c(94,108,110,90,80,94,85,90,90,90,108,94,78,105,88)
treatment<-c(rep("treated",4),rep("control",11))
permTS(dBP~treatment,alternative="less",method="pclt")
result<-permTS(dBP[treatment=="treated"],dBP[treatment=="control"],alternative="greater")
result
result$p.valuesRun the code above in your browser using DataLab