Learn R Programming

nproc (version 0.1)

nproc: Calculate the Neyman-Pearson ROC

Description

nproc calculate the Neyman-Pearson ROC curve for a given sequence of type I error values.

Usage

nproc(x = NULL, y, method = c("logistic", "penlog", "svm", "randomforest",
  "lda", "nb", "ada", "custom"), score = NULL, alphalist = seq(from = 0.01,
  to = 0.99, by = 0.01), delta = 0.05, split = TRUE, cv = FALSE,
  fold = 5, loc.prob = NULL, n.cores = 1)

Arguments

x
n * p observation matrix. n observations, p covariates.
y
n 0/1 observatons.
method
classification method.
  • logistic:glmfunction with family = 'binomial'
  • penlog:glmnetinglmnetpackage
  • svm:
score
score vector corresponding to y. Required when method = 'custom'.
alphalist
the sequence of type I error values. Default = seq(from=0,to=1,by=0.01).
delta
the violation rate of the type I error. Default = 0.05.
split
whether the class 0 sample is split into two parts.
cv
whether cross-validation is performed for calculating the roc curve.
fold
number of folds for the cross-validation. Default = 5.
loc.prob
the precalculated threshold locations in probability. Default = NULL.
n.cores
number of cores used for parallel computing. Default = 1.

See Also

npc

Examples

Run this code
n = 1000
x = matrix(rnorm(n*2),n,2)
c = 1+3*x[,1]
y = rbinom(n,1,1/(1+exp(-c)))
#fit = nproc(x, y, method = 'svm')
#fit2 = nproc(x, y, method = 'svm', cv = TRUE)
fit3 = nproc(x, y, method = 'penlog')
#fit3 = nproc(x, y, method = 'penlog',  n.cores = 2)
#In practice, replace 2 by the number of cores available 'detectCores()'
#fit4 = nproc(x, y, method = 'penlog', n.cores = detectCores())

#Testing the custom method for nproc.
#fit = npc(x, y, method = 'lda', split = FALSE,  n.cores = 2) #use npc to get score list.
#obj = nproc(x = NULL, y = fit$y, method = 'custom', split = FALSE,
#score = fit$score,  n.cores = 2)

Run the code above in your browser using DataLab