R/support.code.r

Defines functions perm.index boot.index boot2.index

#' @name chatham.bio532-package
#' @docType package
#' @aliases chatham.bio532
#' @title Statistical analyses especially designed for BIO532, Biostatistics, at Chatham University
#' @author Michael Collyer
#' 
#' @description Functions in this package allow one to employ the panoply of common statistical analyses, 
#' but with a twist.  Every inferential test also uses a resampling procedure to generate empirical probability 
#' distributions for null hypotheses.  Simulated and theoretical probability distributions can be compared, 
#' diagnostics for tests are available, and results/output are presented in a logical style, consistent with 
#' developing appropriate interpretations.  This package is designed to help BIO532 students navigate the BIO532
#' course, but it should also have general appeal.
#' 
#' @section chatham.bio532 TOC:
#' chatham.bio532-package
#' @import geomorph
NULL

#' actions data from Pagano and Gauvreau 
#'
#' @name actions
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' africa data from Pagano and Gauvreau 
#'
#' @name africa
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' alcohol data from Pagano and Gauvreau 
#'
#' @name alcohol
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' angio data from Pagano and Gauvreau 
#'
#' @name angio
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' bed data from Pagano and Gauvreau 
#'
#' @name bed
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' bed2 data from Pagano and Gauvreau 
#'
#' @name bed2
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' bladder data from Pagano and Gauvreau 
#'
#' @name bladder
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' brate data from Pagano and Gauvreau 
#'
#' @name brate
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' cad data from Pagano and Gauvreau 
#'
#' @name cad
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' cigarett data from Pagano and Gauvreau 
#'
#' @name cigarett
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' cyto data from Pagano and Gauvreau 
#'
#' @name cyto
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' detroit data from Pagano and Gauvreau 
#'
#' @name detroit
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' diabetes data from Pagano and Gauvreau 
#'
#' @name diabetes
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' dialysis data from Pagano and Gauvreau 
#'
#' @name dialysis
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' dthrate data from Pagano and Gauvreau 
#'
#' @name dthrate
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' heart data from Pagano and Gauvreau 
#'
#' @name heart
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' hospital data from Pagano and Gauvreau 
#'
#' @name hospital
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' insure data from Pagano and Gauvreau 
#'
#' @name insure
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' ischemic data from Pagano and Gauvreau 
#'
#' @name ischemic
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' lifeexp data from Pagano and Gauvreau 
#'
#' @name lifeexp
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' liferace data from Pagano and Gauvreau 
#'
#' @name liferace
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' lowbwt data from Pagano and Gauvreau 
#'
#' @name lowbwt
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL


#' miner data from Pagano and Gauvreau 
#'
#' @name miner
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' nurshome data from Pagano and Gauvreau 
#'
#' @name nurshome
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' prison data from Pagano and Gauvreau 
#'
#' @name prison
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' program data from Pagano and Gauvreau 
#'
#' @name program
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' serzinc data from Pagano and Gauvreau 
#'
#' @name serzinc
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' stenosis data from Pagano and Gauvreau 
#'
#' @name stenosis
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' twenty data from Pagano and Gauvreau 
#'
#' @name twenty
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' unicef data from Pagano and Gauvreau 
#'
#' @name unicef
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' us1940 data from Pagano and Gauvreau 
#'
#' @name us1940
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#' water data from Pagano and Gauvreau 
#'
#' @name water
#' @docType data
#' @references Principles of Biostatistics, 2nd ed., 
#' by Marcello Pagano and Kimberlee Gauvreau (2000) 
#' Pacific Grove, PA: Duxbury publishers. ISBN: 0-534-22902-6 
#' U.S.A. 97:4106-4111
#' @keywords datasets
NULL

#----------------------------------------------------------------------------------

# support functions

# perm.index

perm.index <- function(n, iter, seed=NULL){
  if(is.null(seed)) seed = iter else
    if(seed == "random") seed = sample(1:iter,1) else
      if(!is.numeric(seed)) seed = iter
      set.seed(seed)
      ind <- c(list(1:n),(Map(function(x) sample.int(n,n), 1:iter)))
      rm(.Random.seed, envir=globalenv())
      ind
}

boot.index <- function(n, iter, seed=NULL){
  if(is.null(seed)) seed = iter else
    if(seed == "random") seed = sample(1:iter,1) else
      if(!is.numeric(seed)) seed = iter
      set.seed(seed)
      ind <- c(list(1:n),(Map(function(x) sample.int(n, n, replace = TRUE), 1:iter)))
      rm(.Random.seed, envir=globalenv())
      ind
}

boot2.index <- function(n1,n2, iter, seed=NULL){
  if(is.null(seed)) seed = iter else
    if(seed == "random") seed = sample(1:iter,1) else
      if(!is.numeric(seed)) seed = iter
      set.seed(seed)
      ind <- c(list(1:n1),(Map(function(x) sample.int(n1, n1, replace = TRUE), 1:iter)))
      ind2 <- c(list(1:n2),(Map(function(x) sample.int(n2, n2, replace = TRUE), 1:iter)))
      ind2 <- Map(function(x) x+n1, ind2)
      ind <- Map(function(x,y) c(x,y), ind, ind2)
      rm(.Random.seed, envir=globalenv())
      ind
}
mlcollyer/chatham.bio532 documentation built on May 23, 2019, 2:08 a.m.