Calculate the CV score for determining regularisation parameter

Description

Evaluates the cross-validation criterion (11) of Hazelton and Turlach (2009).

Usage

1
2
cv.score(y, sigma, h, gamma,
         METHOD=c("exact", "svm"), K=5, verb=FALSE)

Arguments

y

the observed values.

sigma

the standard deviation of the contaminating (normal) distribution.

h

the smoothing parameter to be used.

gamma

vector of values from which a suitable value is to be selected

METHOD

method to be used to solve the quadratic programming problem involved in calculating the weights; if "exact" then solveqp is used, otherwise the routine ipop from the kernlab package is used.

K

number of folds to be used if gamma is chosen by cross-validation; defaults to 5.

verb

logical; if TRUE some progress report will be printed during cross-validation.

Value

A vector containing the cross-validation criterion evaluated at the values given in gamma.

Author(s)

Berwin A Turlach Berwin.Turlach@gmail.com

References

Hazelton, M.L. and Turlach, B.A. (2009). Nonparametric density deconvolution by weighted kernel estimators, Statistics and Computing 19(3): 217–228. http://dx.doi.org/10.1007/s11222-008-9086-7.

See Also

w.hat

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  set.seed(100719)
  sig <- sqrt(29/40)  # Var(Z)/Var(X) = 0.1
  y <- rden(100, DEN=3, sigma=sig)
  h <- bw.SJ(y, method="dpi")
  gamma.ridge <- exp(seq(from=0, to=6, length=17))

  save.seed <- .Random.seed
  cv1 <- cv.score(y, sigma=sig, h=h, gamma=gamma.ridge,
                  METHOD="exact", verb=TRUE)
  plot(log(gamma.ridge), cv1, type="b")
  tmp <- getmin(log(gamma.ridge), cv1, which="r")
  abline(v=tmp$xmin)

  .Random.seed <- save.seed
  cv2 <- cv.score(y, sigma=sig, h=h, gamma=gamma.ridge,
                  METHOD="svm", verb=TRUE)
  plot(log(gamma.ridge), cv2, type="b")
  tmp <- getmin(log(gamma.ridge), cv2, which="r")
  abline(v=tmp$xmin)

  .Random.seed <- save.seed
  cv1 <- cv.score(y, sigma=sig, h=h, gamma=gamma.ridge,
                  METHOD="exact", K=10, verb=TRUE)
  plot(log(gamma.ridge), cv1, type="b")
  tmp <- getmin(log(gamma.ridge), cv1, which="r")
  abline(v=tmp$xmin)

  .Random.seed <- save.seed
  cv2 <- cv.score(y, sigma=sig, h=h, gamma=gamma.ridge,
                  METHOD="svm", K=10, verb=TRUE)
  plot(log(gamma.ridge), cv2, type="b")
  tmp <- getmin(log(gamma.ridge), cv2, which="r")
  abline(v=tmp$xmin)