predict.npc: Predicting the outcome of a set of new observations using the... In nproc: Neyman-Pearson (NP) Classification Algorithms and NP Receiver Operating Characteristic (NP-ROC) Curves

Description

Predicting the outcome of a set of new observations using the fitted npc object.

Usage

 ```1 2``` ```## S3 method for class 'npc' predict(object, newx = NULL, ...) ```

Arguments

 `object` fitted npc object using `npc`. `newx` a set of new observations. `...` additional arguments.

Value

A list containing the predicted label and score.

 `pred.label` Predicted label vector. `pred.score` Predicted score vector.

`npc` and `nproc`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24``` ```n = 1000 x = matrix(rnorm(n*2),n,2) c = 1+3*x[,1] y = rbinom(n,1,1/(1+exp(-c))) xtest = matrix(rnorm(n*2),n,2) ctest = 1+3*xtest[,1] ytest = rbinom(n,1,1/(1+exp(-ctest))) ## Not run: ##Use logistic classifier and the default type I error control with alpha=0.05 fit = npc(x, y, method = 'logistic') pred = predict(fit,xtest) fit.score = predict(fit,x) accuracy = mean(pred\$pred.label==ytest) cat('Overall Accuracy: ', accuracy,'\n') ind0 = which(ytest==0) ind1 = which(ytest==1) typeI = mean(pred\$pred.label[ind0]!=ytest[ind0]) #type I error on test set cat('Type I error: ', typeI, '\n') typeII = mean(pred\$pred.label[ind1]!=ytest[ind1]) #type II error on test set cat('Type II error: ', typeII, '\n') ## End(Not run) ```