randtest {ade4}R Documentation

Class of the Permutation Tests (in C).

Description

randtest is a generic function. It proposes methods for the following objects between, discrimin, coinertia ...

Usage

    randtest(xtest, ...)
    ## S3 method for class 'randtest':
plot(x, nclass = 10, coeff = 1, ...)
    as.randtest (sim, obs,alter=c("greater", "less", "two-sided"), call = match.call())
    ## S3 method for class 'randtest':
print(x, ...)

Arguments

xtest an object used to select a method
x an object of class randtest
... ... further arguments passed to or from other methods; in plot.randtest to hist
nclass a number of intervals for the histogram
coeff to fit the magnitude of the graph
sim a numeric vector of simulated values
obs a numeric vector of an observed value
alter a character string specifying the alternative hypothesis, must be one of "greater" (default), "less" or "two-sided"
call a call order

Details

If the alternative hypothesis is "greater", a p-value is estimated as: (number of random values equal to or greater than the observed one + 1)/(number of permutations + 1). The null hypothesis is rejected if the p-value is less than the significance level. If the alternative hypothesis is "less", a p-value is estimated as: (number of random values equal to or less than the observed one + 1)/(number of permutations + 1). Again, the null hypothesis is rejected if the p-value is less than the significance level. Lastly, if the alternative hypothesis is "two-sided", the estimation of the p-value is equivalent to the one used for "greater" except that random and observed values are firstly centered (using the average of random values) and secondly transformed to their absolute values. Note that this is only suitable for symmetric random distribution.

Value

as.randtest returns a list of class randtest
plot.randtest draws the simulated values histograms and the position of the observed value

See Also

mantel.randtest, procuste.randtest, rtest

Examples

par(mfrow = c(2,2))
for (x0 in c(2.4,3.4,5.4,20.4)) {
    l0 <- as.randtest(sim = rnorm(200), obs = x0)
    print(l0)
    plot(l0,main=paste("p.value = ", round(l0$pvalue, dig = 5)))
}
par(mfrow = c(1,1))

Worked out examples


> library(ade4)
> ### Name: randtest
> ### Title: Class of the Permutation Tests (in C).
> ### Aliases: randtest as.randtest plot.randtest print.randtest
> ### Keywords: methods
> 
> ### ** Examples
> 
> par(mfrow = c(2,2))
> for (x0 in c(2.4,3.4,5.4,20.4)) {
+     l0 <- as.randtest(sim = rnorm(200), obs = x0)
+     print(l0)
+     plot(l0,main=paste("p.value = ", round(l0$pvalue, dig = 5)))
+ }
Monte-Carlo test
Call: as.randtest(sim = rnorm(200), obs = x0)

Observation: 2.4 

Based on 200 replicates
Simulated p-value: 0.01492537 
Alternative hypothesis: greater 

     Std.Obs  Expectation     Variance 
 2.306330555 -0.005205828  1.087580444 
Monte-Carlo test
Call: as.randtest(sim = rnorm(200), obs = x0)

Observation: 3.4 

Based on 200 replicates
Simulated p-value: 0.004975124 
Alternative hypothesis: greater 

    Std.Obs Expectation    Variance 
 3.66998433 -0.07243471  0.89524057 
Monte-Carlo test
Call: as.randtest(sim = rnorm(200), obs = x0)

Observation: 5.4 

Based on 200 replicates
Simulated p-value: 0.004975124 
Alternative hypothesis: greater 

    Std.Obs Expectation    Variance 
  5.4858195   0.1144712   0.9283118 
Monte-Carlo test
Call: as.randtest(sim = rnorm(200), obs = x0)

Observation: 20.4 

Based on 200 replicates
Simulated p-value: 0.004975124 
Alternative hypothesis: greater 

    Std.Obs Expectation    Variance 
 19.6450120   0.0271071   1.0754762 
> par(mfrow = c(1,1))
> 
> 
> 
> 

[Package ade4 Index]