Description Usage Arguments Details Value Examples
View source: R/create.rm.ndx.ls.R
Create a list of vectors of indices to remove for k-fold cross-validation
1 | create.rm.ndx.ls(n, xincmnt = 10)
|
n |
Number of sites. A scalar integer. |
xincmnt |
How many cv folds, i.e., k. |
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).
An unnamed list of integer (>0) vectors.
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 | 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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.