create.rm.ndx.ls {widals} | R Documentation |
Cross-Validation Indices
Description
Create a list of vectors of indices to remove for k-fold cross-validation
Usage
create.rm.ndx.ls(n, xincmnt = 10)
Arguments
n |
Number of sites. A scalar integer. |
xincmnt |
How many cv folds, i.e., k. |
Details
The name of the object produced by this function is commonly rm.ndx
in this documentation. See MSS.snow
for a reminder that this object is passed out-of-scope when using MSS.snow
.
In this package rm.ndx
is used by Hals.fastcv.snow
and widals.snow
; however, creating this object as a list using this function is only necessary when using widals.snow
with cv=2
(i.e., 'true' cross-validation).
Value
An unnamed list of integer (>0) vectors.
Examples
n <- 100
xincmnt <- 7
rm.ndx <- create.rm.ndx.ls(n=n, xincmnt=xincmnt)
rm.ndx
######## if we want randomization of indices:
n <- 100
xincmnt <- 7
rm.ndx <- create.rm.ndx.ls(n=n, xincmnt=xincmnt)
rnd.ndx <- sample(I(1:n))
for(i in 1:length(rm.ndx)) { rm.ndx[[i]] <- rnd.ndx[rm.ndx[[i]]] }
rm.ndx
## The function is currently defined as
function (n, xincmnt = 10)
{
rm.ndx.ls <- list()
for (i in 1:xincmnt) {
xrm.ndxs <- seq(i, n + xincmnt, by = xincmnt)
xrm.ndxs <- xrm.ndxs[xrm.ndxs <= n]
rm.ndx.ls[[i]] <- xrm.ndxs
}
return(rm.ndx.ls)
}
[Package widals version 0.6.1 Index]