This function computes a permutation test of comparison of the means of two paired vectors (related samples). For each object, permutations are restricted to the two related observations.

tpaired.randtest(
  vec1,
  vec2,
  nperm = 99,
  alternative = "two.sided",
  silent = FALSE
)

Arguments

vec1, vec2

The two data vectors to be compared.

nperm

Number of permutations. Use 999, 9999, or more.

alternative

c("two.sided", "less", "greater"). Default value: "two.sided".

silent

If FALSE, calculation results are printed to the R console. If TRUE calculation results are not printed to R console (for simulations).

Value

A list containing the following results:

  • estim: mean of the differences

  • t.ref: reference value of the t-statistic

  • p.param: parametric p-value

  • p.perm: permutational p-value

  • nperm: number of permutations

References

Zar, J. H. 1999. Biostatistical analysis. 4th edition. Prentice Hall, New Jersey.

See also

Author

- Pierre Legendre pierre.legendre@umontreal.ca Permutation code improved by Guillaume Blanchet.

Examples


## Deer leg length, data from Zar (1999, p. 162).

deer <- matrix(c(142,140,144,144,142,146,149,150,142,148,138,136,147,139,143,141,143,
145,136,146),10,2)

rownames(deer) <- paste("Deer",1:10,sep=".")

colnames(deer) <- c('Hind.leg', 'Fore.leg')

res <- tpaired.randtest(deer[,1], deer[,2])   # Two-tailed test by default
#> 
#> t-test comparing the means of two related samples 
#>  
#> Number of objects: 10 
#> Mean of the differences: 3.3 
#> t statistic (paired observations): 3.413793 
#> 95 percent confidence interval of t: 1.113248 5.486752 
#> Degrees of freedom: 9 
#> Alternative hypothesis: two.sided 
#> Prob (parametric): 0.007703223 
#> Prob ( 99 permutations): 0.03000 

## Compare the results to:  res2 = t.test(deer[,1], deer[,2], paired=TRUE)