hROC {movieROC} | R Documentation |
This is one of the main functions of the movieROC package.
It builds a univariate ROC curve for a transformed marker h(X)
and returns a ‘hroc’ object, a list of class ‘hroc’.
This object can be print
ed, plot
ted, or predict
ed
for a particular point. It may be also passed to
plot.funregions
and plot.regions
functions.
hROC(X, D, ...)
## Default S3 method:
hROC(X, D, type = c("lrm", "h.fun", "overfitting"),
formula.lrm = "D ~ pol(X,3)", h.fun = function(x) {x},
plot.h = FALSE, plot.roc = FALSE, new.window = FALSE,
main = NULL, xlab = "x", ylab = "h(x)", xaxis = TRUE, ...)
X |
Vector of marker values. |
D |
Vector of response values. Two levels; if more, the two first ones are used. |
type |
Type of transformation considered. One of |
formula.lrm |
If |
h.fun |
If |
plot.h |
If TRUE, the transformation employed is illustrated. |
plot.roc |
If TRUE, the resulting ROC curve is illustrated. |
new.window |
If TRUE, two previous graphics are plotted separately in different windows. |
main |
A main title for the plot used if |
xlab , ylab |
A label for the x and y axis of the plot used if |
xaxis |
Graphical parameter used if |
... |
Other parameters to be passed. Not used. |
A list of class ‘hroc’ with the following fields:
levels |
Levels of response values. |
X , Y |
Original and transformed marker values, respectively. |
Sp , Se |
Vector of true-negtive and true-positive rates, respectively. |
auc |
Area under the curve estimate. |
model |
If |
data(HCC)
# ROC curve for gene 18384097 to identify tumor by considering 4 different transformations:
X <- HCC$cg18384097; D <- HCC$tumor
## 1. Ordinary cubic polynomial formula for binary logistic regression
hROC(X, D)
## 2. Linear tail-restricted cubic splines for binary logistic regression
hROC(X, D, formula.lrm = "D ~ rcs(X,8)")
## 3. Overfitting transformation for this particular sample
hROC(X, D, type = "overfitting")
## 4. Optimal transformation in terms of likelihood ratio
## by kernel density estimation with bandwidth h=3
EstDensTransf_FUN <- function(X, D, h = 1){
D <- as.factor(D)
controls <- X[D == levels(D)[1]]; dens_controls <- density(controls, adjust = h)
cases <- X[D == levels(D)[2]]; dens_cases <- density(cases, adjust = h)
dens_controls_FUN <- approxfun(dens_controls$x, dens_controls$y, rule = 0)
dens_cases_FUN <- approxfun(dens_cases$x, dens_cases$y, rule = 0)
function(x) dens_cases_FUN(x)/(dens_controls_FUN(x) + dens_cases_FUN(x))
}
hROC(X, D, type = "h.fun", h.fun = function(x) EstDensTransf_FUN(X, D, h = 3)(x))