Learn R Programming

modelROC (version 1.0)

ggplot: Plot for ROC curve

Description

Plot for ROC curve

Usage

# S3 method for auc_coxph
ggplot(
  data,
  mapping,
  color = NULL,
  lwd = 1.05,
  grid.space = 2,
  ncol = NULL,
  ...,
  environment = parent.frame()
)

# S3 method for roc_coxph ggplot( data, mapping, color = NULL, lwd = 1.05, grid.space = 2, rank = FALSE, ncol = NULL, ..., environment = parent.frame() )

# S3 method for roc_logit ggplot( data, mapping, color = NULL, lwd = 1.05, grid.space = 2, rank = FALSE, ..., environment = parent.frame() )

Arguments

data

resultes of roc() function

mapping

ignore

color

one or more colors

lwd

logical or integers

grid.space

space between grids, default is 2

ncol

number of column for grid plot

...

ignore

environment

ignore

rank

rank by AUC

Value

a ggplot picture.

Examples

Run this code
# NOT RUN {
library(ggDCA)
library(rms)
library(modelROC)
###  COX ----------

fit <- cph(Surv(time,status)~ANLN+CENPA+GPR182,LIRI)

####        one model, one time ####
#----            auc for model

r <- auc(fit,
          model='This is model') # one model
unique(r)
ggplot(r)

r <- auc(fit,
          model=TRUE)            # all model
unique(r)
ggplot(r)


#----            auc for x
r <- auc(fit,
          x='ANLN')              # one x
unique(r)
ggplot(r)

r <- auc(fit,
          x=c('ANLN','CENPA'))   # more x
unique(r)
ggplot(r)

r <- auc(fit,
          x=TRUE)                # all x
unique(r)
ggplot(r)

r <- auc(fit,
          model=TRUE,            # one model
          x=TRUE)                # all x
unique(r)
ggplot(r)

r <- auc(fit,
          model='Three Genes',   # specify model names
          x=TRUE)                # all X
unique(r)
ggplot(r)



####        more models ####
fit2 <- cph(Surv(time,status)~ANLN+CENPA,LIRI)


r <- auc(fit,fit2,
          model=c('Three Genes','Two Genes'))            #
unique(r)
ggplot(r)



r <- auc(fit,fit2,
          model=TRUE,
          x=TRUE)
unique(r)
ggplot(r)
# }
# NOT RUN {
library(ggDCA)
library(rms)
fit <- lrm(status~ANLN+CENPA+GPR182,LIRI)
####        one model ####
pp <- roc(fit,
          model=TRUE) # one model
unique(pp)
ggplot(pp)

pp <- roc(fit,
          x='ANLN') # one x
unique(pp)
ggplot(pp)

# }
# NOT RUN {
pp <- roc(fit,
          x=c('ANLN','CENPA')) # more x
unique(pp)
ggplot(pp)


pp <- roc(fit,
          x=TRUE) # ALL x
unique(pp)
ggplot(pp)


pp <- roc(fit,
          model=TRUE, # one model
          x=TRUE) # ALL x
unique(pp)
ggplot(pp)

pp <- roc(fit,
          model='Three Genes', # specify model name
          x=TRUE) # ALL x
unique(pp)
ggplot(pp)

####        more model   ####

fit2 <- lrm(status~ANLN+CENPA,LIRI)
pp <- roc(fit,fit2,
          model=TRUE) # all model
unique(pp)
ggplot(pp)


pp <- roc(fit,fit2,
          model=c('Three Genes','Two Genes')) # specify model names
unique(pp)
ggplot(pp)

pp <- roc(fit,fit2,
          x=TRUE,                             # all x
          model=c('Three Genes','Two Genes')) # all model
unique(pp)
ggplot(pp)

###  COX ----------

fit <- cph(Surv(time,status)~ANLN+CENPA+GPR182,LIRI)
range(LIRI$time)
####        one model, one time ####
#----            roc for model

pp <- roc(fit, times=1,
          model='This is model') # one model
unique(pp)
ggplot(pp)

pp <- roc(fit, times=1,
          model=TRUE)            # all model
unique(pp)
ggplot(pp)

#----            roc for x
pp <- roc(fit, times=1,
          x='ANLN')              # one x
unique(pp)
ggplot(pp)

pp <- roc(fit, times=1,
          x=c('ANLN','CENPA'))   # more x
unique(pp)
ggplot(pp)

pp <- roc(fit, times=1,
          x=TRUE)                # all x
unique(pp)
ggplot(pp)

pp <- roc(fit, times=1,
          model=TRUE,            # one model
          x=TRUE)                # all x
unique(pp)
ggplot(pp)

pp <- roc(fit, times=1,
          model='Three Genes',   # specify model names
          x=TRUE)                # all X
unique(pp)
ggplot(pp)

####        one model, more time ####

pp <- roc(fit, times=c(1,2,3,4,5,6),
          model=TRUE)            # one model
unique(pp)
ggplot(pp)


pp <- roc(fit, times=c(1,2),
          x =  'ANLN')           # one x

unique(pp)
ggplot(pp)


pp <- roc(fit, times=c(1,2,3,4,5,6),
          x = c('ANLN','CENPA')) # more x
unique(pp)
ggplot(pp,ncol = 3)


pp <- roc(fit, times=c(1,2),
          model=TRUE,            # one model
          x = TRUE) # all x
unique(pp)
ggplot(pp)

####        more models, one time ####
fit2 <- cph(Surv(time,status)~ANLN+CENPA,LIRI)

pp <- roc(fit,fit2,times=1,
          x=TRUE,
          model=c('Three Genes','Two Genes'))            #
unique(pp)
ggplot(pp)
####        more models, more time ####
pp <- roc(fit,fit2,times=c(1,2),
          model=c('Three Genes','Two Genes'))            #
unique(pp)
ggplot(pp)

pp <- roc(fit,fit2,times=c(1,2),
          x=TRUE,
          model=c('Three Genes','Two Genes'))            #
unique(pp)
ggplot(pp)
# }

Run the code above in your browser using DataLab