home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Educational / R-0.49-MI / R-0.49-I / help / bootstrap / crossval < prev    next >
Encoding:
Text File  |  1997-09-13  |  2.7 KB  |  75 lines

  1.     
  2.     _K-_f_o_l_d _c_r_o_s_s-_v_a_l_i_d_a_t_i_o_n
  3.     
  4.          crossval(x,y,theta.fit,theta.predict,...,ngroup=n)
  5.     
  6.     _A_r_g_u_m_e_n_t_s:
  7.     
  8.                 x: a matrix containing the predictor (regressor)
  9.                    values. Each row corresponds to an observa-
  10.                    tion.
  11.     
  12.                 y: a vector containing the response values
  13.     
  14.         theta.fit: function to be cross-validated. Takes x and y
  15.                    as an argument.  See example below.
  16.     
  17.     theta.predict: function producing predicted values for
  18.                    theta.fit.  Arguments are a matrix x of pred-
  19.                    ictors and fit object produced by theta.fit.
  20.                    See example below.
  21.     
  22.            ngroup: optional argument specifying the number of
  23.                    groups formed .  Default is ngroup=sample
  24.                    size, corresponding to leave-one out cross-
  25.                    validation.
  26.     
  27.     _V_a_l_u_e_s:
  28.     
  29.          list with the following components
  30.     
  31.       cv.fit: The  cross-validated fit for each observation.
  32.               The numbers 1 to n (the sample size) are  parti-
  33.               tioned into ngroup  mutually disjoint groups  of
  34.               size "leave.out".  leave.out, the number of obser-
  35.               vations in each group, is the integer part of
  36.               n/ngroup.  The groups are chosen at random if
  37.               ngroup < n.  (If n/leave.out is not an integer,
  38.               the last group will contain > leave.out observa-
  39.               tions).  Then theta.fit is applied with the kth
  40.               group of observations deleted, for k=1, 2, ngroup.
  41.               Finally, the fitted value is computed for the kth
  42.               group using theta.predict.
  43.     
  44.       ngroup: The number of groups
  45.     
  46.     leave.out: The number of observations in each group
  47.     
  48.       groups: A list of length ngroup containing the indices of
  49.               the observations in each group. Only returned if
  50.               leave.out > 1.
  51.     
  52.     _R_e_f_e_r_e_n_c_e_s:
  53.     
  54.          Stone, M. (1974).  Cross-validation choice and assess-
  55.          ment of statistical predictions. Journal of the Royal
  56.          Statistical Society, B-36, 111--147.
  57.     
  58.          Efron, B. and Tibshirani, R. (1993) An Introduction to
  59.          the Bootstrap.  Chapman and Hall, New York, London.
  60.     
  61.     _E_x_a_m_p_l_e_s:
  62.     
  63.          # cross-validation of least squares regression
  64.          # note that crossval is not very efficient, and being a
  65.          #  general purpose function, it does not use the
  66.          # Sherman-Morrison identity for this special case
  67.          x <- rnorm(85)
  68.          y <- 2*x +.5*rnorm(85)
  69.          theta.fit <- function(x,y)lsfit(x,y)
  70.          theta.predict <- function(fit,x)
  71.                         cbind(1,x)%*%fitoef
  72.     
  73.          results <- crossval(x,y,theta.fit,theta.predict,ngroup=6)
  74.     
  75.