/in.progress/auteur/man/randomization.test.Rd

http://github.com/eastman/auteur · Unknown · 43 lines · 40 code · 3 blank · 0 comment · 0 complexity · da14a29b9657aefb8c5a3fb8026b6d24 MD5 · raw file

  1. \name{randomization.test}
  2. \alias{randomization.test}
  3. \title{statistical comparison of sets of values by randomization}
  4. \description{Compares means by bootstrap resampling of differences between empirical distributions}
  5. \usage{
  6. randomization.test(obs = obs, exp = exp, mu = 0, iter = 10000, two.tailed = FALSE)
  7. }
  8. %- maybe also 'usage' for other objects documented here.
  9. \arguments{
  10. \item{obs}{a vector of numeric values}
  11. \item{exp}{a vector of numeric values}
  12. \item{mu}{the true difference in means}
  13. \item{iter}{number of randomization comparisons to perform}
  14. \item{two.tailed}{as default, the test is performed under a one-tailed assumption; if \code{two.tailed=FALSE}, probability values associated with either tail of the comparison distribution are returned,
  15. otherwise, a two-tailed result is returned}
  16. }
  17. \details{
  18. If a single value is supplied for \code{obs}, this test equates to finding the quantile in \code{exp} in which \code{obs} would be found (under a one-tailed test);
  19. see \bold{Examples} and also \code{\link[stats]{ecdf}}}
  20. \value{
  21. A list, whose contents are determined by the above argument:
  22. \item{unnamed value}{if \code{two.tailed=TRUE}, this is the two-tailed p-value}
  23. \item{diffs}{the full resampling distribution of differences between \code{obs} and \code{exp}, given \code{mu} }
  24. \item{greater}{if \code{two.tailed=FALSE}, this is the p-value associated with the righthand tail}
  25. \item{lesser}{if \code{two.tailed=FALSE}, this is the p-value associated with the lefthand tail}
  26. }
  27. \author{JM Eastman}
  28. \examples{
  29. # a comparison between two distributions
  30. a=rnorm(n=1000, mean=1, sd=0.5)
  31. b=rnorm(n=1000, mean=0, sd=1)
  32. randomization.test(obs=a, exp=b, two.tailed=FALSE)
  33. # a comparison of a single value to a normal distribution
  34. a=3
  35. b=rnorm(n=1000, mean=0, sd=1)
  36. randomization.test(obs=a, exp=b, two.tailed=FALSE)
  37. # compare above result with ecdf(), in which we compute an empirical
  38. f=ecdf(b)
  39. print(1-f(a)) # analogous to a one-tailed test as above
  40. }