coxsplit: Split Data for Cross-validation

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/coxsplit.R

Description

Specify which fold each observation is in to obtain foldid.

coxsplit randomly split data. coxsplity splits data by the ‘status’ of y, and within each status, data is randomly split. coxsplitw splits data in the order of w.

Usage

1
2
3
4
5
coxsplit(y, nfolds)

coxsplity(y, nfolds)

coxsplitw(w, nfolds)

Arguments

y

response variable. y should be a two-column matrix with columns named ‘time’ and ‘status’. The latter is a binary variable, with ‘1’ indicating event, and ‘0’ indicating right censored.

w

input vector, same length as y. The coefficients vary with w.

nfolds

number of folds.

Details

By default, coxsplit is incorporated in Coxnet and coxsplitw in loCoxnet. To use other data splitting method, generate foldid at the outset and supply it as an augment in Coxnet and loCoxnet.

Value

a vector of values between 1 and nfolds specifying which fold each observation is in.

Author(s)

Xiang Li, Donglin Zeng and Yuanjia Wang
Maintainer: Xiang Li <xl2473@columbia.edu>

See Also

Coxnet, loCoxnet, print.Coxnet

Examples

1
2
3
4
5
6
7
set.seed(1213)
N=100
xb=rnorm(N)
ty=rexp(N,exp(xb))
tcens=rbinom(n=N,prob=.3,size=1)  # censoring indicator
y=cbind(time=ty,status=1-tcens)
foldid=coxsplit(y,10)  # 10-fold

Example output

Loading required package: Matrix

Coxnet documentation built on May 29, 2017, 9:51 a.m.