crossval {bootstrap}  R Documentation 
See Efron and Tibshirani (1993) for details on this function.
crossval(x, y, theta.fit, theta.predict, ..., ngroup=n)
x 
a matrix containing the predictor (regressor) values. Each row corresponds to an observation. 
y 
a vector containing the response values 
theta.fit 
function to be crossvalidated. Takes 
theta.predict 
function producing predicted values for

... 
any additional arguments to be passed to theta.fit 
ngroup 
optional argument specifying the number of groups formed .
Default is 
list with the following components
cv.fit 
The crossvalidated fit for each observation. The
numbers 1 to n (the sample size) are partitioned into 
ngroup 
The number of groups 
leave.out 
The number of observations in each group 
groups 
A list of length ngroup containing the indices of the
observations
in each group. Only returned if 
call 
The deparsed call 
Stone, M. (1974). Crossvalidation choice and assessment of statistical predictions. Journal of the Royal Statistical Society, B36, 111–147.
Efron, B. and Tibshirani, R. (1993) An Introduction to the Bootstrap. Chapman and Hall, New York, London.
# crossvalidation of least squares regression # note that crossval is not very efficient, and being a # general purpose function, it does not use the # ShermanMorrison identity for this special case x < rnorm(85) y < 2*x +.5*rnorm(85) theta.fit < function(x,y){lsfit(x,y)} theta.predict < function(fit,x){ cbind(1,x)%*%fit$coef } results < crossval(x,y,theta.fit,theta.predict,ngroup=6)