\HeaderA{boot.resample}{Non-parametric bootstrap resampling function in package `multtest'}{boot.resample}
\keyword{manip}{boot.resample}
\keyword{internal}{boot.resample}
\begin{Description}\relax
Given a data set and a closure, which consists of a function for computing the test statistic and its enclosing environment, this function produces a non-parametric bootstrap estimated test statistics null distribution. The observations in the data are resampled using the ordinary non-parametric bootstrap and used to produce an estimated test statistics distribution. This distribution is then centered and scaled to produce the null distribution. This function is called by \code{MTP}.
\end{Description}
\begin{Usage}
\begin{verbatim}
boot.resample(X, stat.closure, W = NULL, B = 1000, theta0 = 0, tau0 = 1, alternative = "two.sided")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{X}] A matrix, data.frame or exprSet containing the raw data. In the case of an exprSet, \code{exprs(X)} is the data of interest and \code{pData(X)} may contain outcomes and covariates of interest. For currently implemented tests, one hypothesis is tested for each row of the data.
\item[\code{stat.closure}] A closure for test statistic computation, like those produced internally by the \code{MTP} function. The closure consists of a function for computing the test statistic and its enclosing environment, with bindings for relevant additional arguments (such as null values, outcomes, and covariates).
\item[\code{W}] A vector or matrix containing non-negative weights to be used in computing the test statistics. If a matrix, \code{W} must be the same dimension as \code{X} with one weight for each value in \code{X}. If a vector, \code{W} may contain one weight for each observation (i.e. column) of \code{X} or one weight for each variable (i.e. row) of \code{X}. In either case, the weights are duplicated appropriately. Weighted f-tests are not available. Default is 'NULL'.
\item[\code{B}] The number of bootstrap iterations (i.e. how many resampled data sets) or the number of permutations (if \code{nulldist} is 'perm'). Can be reduced to increase the speed of computation, at a cost to precision. Default is 1000.
\item[\code{theta0}] The value used to center the test statistics. For tests based on a form of t-statistics, this should be zero (default). For f-tests, this should be 1.
\item[\code{tau0}] The value used to scale the test statistics. For tests based on a form of t-statistics, this should be 1 (default). For f-tests, this should be 2/(K-1), where K is the number of groups.
\item[\code{alternative}] Character string indicating the alternative hypotheses, by default 'two.sided'. For one-sided tests, use 'less' or 'greater' for null hypotheses of 'greater than or equal' (i.e. alternative is 'less') and 'less than or equal', respectively.
\end{ldescription}
\end{Arguments}
\begin{Value}
A matrix of dimension number of hypotheses (\code{nrow(X)}) by number of bootstrap iterations (\code{B}). This is the estimated joint test statistics null distribution. Each column is a centered and scaled resampled vector of test statistics. Each row is the bootstrap estimated marginal null distribution for a single hypothesis. This object is returned in slot \code{nulldist} of an object of class \code{MTP} when the argument \code{keep.nulldist} to the \code{MTP} function is TRUE.
\end{Value}
\begin{Note}\relax
Thank you to Peter Dimitrov for suggestions about the code.
\end{Note}
\begin{Author}\relax
Katherine S. Pollard, \url{http://lowelab.ucsc.edu/katie/}\\
with design contributions from Sandrine Dudoit and Mark J. van der Laan.
\end{Author}
\begin{References}\relax
M.J. van der Laan, S. Dudoit, K.S. Pollard (2004), Augmentation Procedures for Control of the Generalized Family-Wise Error Rate and Tail Probabilities for the Proportion of False Positives, Statistical Applications in Genetics and Molecular Biology, 3(1). 
\url{http://www.bepress.com/sagmb/vol3/iss1/art15/}

M.J. van der Laan, S. Dudoit, K.S. Pollard (2004), Multiple Testing. Part II. Step-Down Procedures for Control of the Family-Wise Error Rate, Statistical Applications in Genetics and Molecular Biology, 3(1).
\url{http://www.bepress.com/sagmb/vol3/iss1/art14/}

S. Dudoit, M.J. van der Laan, K.S. Pollard (2004), Multiple Testing. Part I. Single-Step Procedures for Control of General Type I Error Rates, Statistical Applications in Genetics and Molecular Biology, 3(1).
\url{http://www.bepress.com/sagmb/vol3/iss1/art13/}

Katherine S. Pollard and Mark J. van der Laan, "Resampling-based Multiple Testing: Asymptotic Control of Type I Error and Applications to Gene Expression Data" (June 24, 2003). U.C. Berkeley Division of Biostatistics Working Paper Series. Working Paper 121.
\url{http://www.bepress.com/ucbbiostat/paper121}
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{MTP}{MTP}}, \code{\LinkA{MTP-class}{MTP.Rdash.class}}, \code{\LinkA{get.Tn}{get.Tn}}, \code{\LinkA{ss.maxT}{ss.maxT}}, \code{\LinkA{mt.sample.teststat}{mt.sample.teststat}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

#data example: ALL data set
set.seed(99)
data<-matrix(rnorm(90),nr=9)

#closure
ttest<-meanX(psi0=0,na.rm=TRUE,standardize=TRUE,alternative="two.sided",robust=FALSE)

#test statistics
obs<-get.Tn(X=data,stat.closure=ttest,W=NULL)

#bootstrap null distribution (B=100 for speed)
nulldistn<-boot.resample(X=data,W=NULL,stat.closure=ttest,B=100,theta0=0,tau0=1,alternative="two.sided")

#unadjusted p-values
rawp<-apply((obs[1,]/obs[2,])<=nulldistn,1,mean)
sum(rawp<=0.01)

\end{ExampleCode}
\end{Examples}

