kfold: k-fold partition of data at random

Description Usage Arguments Details Value Author(s) Examples

View source: R/extlasso.R

Description

The function partitions a data set into k folds of equal sizes at random.

Usage

1
kfold(data1,k)

Arguments

data1

A matrix.

k

Number of folds

Details

This function is internal and used by cross validation routines.

Value

A matrix with fold identification in first column.

Author(s)

B N Mandal and Jun Ma

Examples

1
2
data=matrix(rnorm(10*4),10,4)
kfold(data,3)

Example output

      [,1]        [,2]        [,3]       [,4]        [,5]
 [1,]    2  1.14136051  0.30709990 -0.2199721  0.14201532
 [2,]    3 -1.58084791  0.28651265  0.8016795  1.56096188
 [3,]    1  0.74300390 -0.08717788 -0.9819784 -1.90186889
 [4,]    2 -0.31132909  0.39365662  1.6942907  0.02018745
 [5,]    3 -0.52634154  2.33322352  0.3584720 -0.37709311
 [6,]    3 -0.81415494  0.09209422  1.4582477  0.75897025
 [7,]    1  1.24428409  0.35233139  0.9787181  1.78901091
 [8,]    1 -2.04344924  0.49890030 -0.8033460 -0.35172651
 [9,]    3  0.05267639 -2.94204068 -1.2589182 -0.60562633
[10,]    2  2.12890372 -0.54004494  0.1823106 -0.60302967

extlasso documentation built on May 2, 2019, 11:39 a.m.

Related to kfold in extlasso...