[Diagnosismed-commits] r15 - in pkg/DiagnosisMed: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue May 26 20:03:35 CEST 2009
Author: pedrobrasil
Date: 2009-05-26 20:03:34 +0200 (Tue, 26 May 2009)
New Revision: 15
Added:
pkg/DiagnosisMed/R/plot.ROC.r
Modified:
pkg/DiagnosisMed/DESCRIPTION
pkg/DiagnosisMed/R/ROC.r
pkg/DiagnosisMed/R/print.ROC.r
pkg/DiagnosisMed/man/ROC.Rd
pkg/DiagnosisMed/man/TGROC.Rd
Log:
Modified: pkg/DiagnosisMed/DESCRIPTION
===================================================================
--- pkg/DiagnosisMed/DESCRIPTION 2009-05-21 05:39:45 UTC (rev 14)
+++ pkg/DiagnosisMed/DESCRIPTION 2009-05-26 18:03:34 UTC (rev 15)
@@ -1,6 +1,6 @@
Package: DiagnosisMed
-Version: 0.2.1
-Date: 2009-05-21
+Version: 0.2.2
+Date: 2009-05-26
Author: Pedro Brasil <pedro.brasil at ipec.fiocruz.br>
Maintainer: Pedro Brasil <pedro.brasil at ipec.fiocruz.br>
Depends: R (>= 2.7.2),epitools,epicalc, TeachingDemos, tcltk, AMORE
Modified: pkg/DiagnosisMed/R/ROC.r
===================================================================
--- pkg/DiagnosisMed/R/ROC.r 2009-05-21 05:39:45 UTC (rev 14)
+++ pkg/DiagnosisMed/R/ROC.r 2009-05-26 18:03:34 UTC (rev 15)
@@ -5,6 +5,10 @@
Prevalence=0,
Plot=TRUE,
Plot.point="Min.ROC.Dist",
+ cex.sub=.85,
+ cex=1,
+ lwd=1,
+ p.cex=1,
Print.full=FALSE,
Print=TRUE
){
@@ -14,6 +18,7 @@
stop("It seems that your gold standard has more than 2 categories")
}
CL<-CL
+ cost<-Cost
# Sample size
sample.size<-sum(test.table)
# Sample prevalence, replace by pop prevalence if adequate
@@ -104,7 +109,7 @@
test.cutoff.table<-as.data.frame(test.values)
for(i in 1:nrow(test.cutoff.table)) {
#Accuracy is (TP+TN)/sample.size
- test.cutoff.table$Accuracy[i]<-sum(test.table[i:nrow(test.table),2])+sum(test.table[1:i-1,1])/sample.size
+ test.cutoff.table$Accuracy[i]<-(sum(test.table[i:nrow(test.table),2])+sum(test.table[1:i-1,1]))/sample.size
test.cutoff.table$DOR[i]<-(((sum(test.table[i:nrow(test.table),2])*(sum(test.table[1:i-1,1])))/
((sum(test.table[i:nrow(test.table),1]))*(sum(test.table[1:i-1,2])))))
test.cutoff.table$Error.rate[i]<-((sum(test.table[1:i-1,2]))+(sum(test.table[i:nrow(test.table),1])))/sample.size
@@ -150,156 +155,6 @@
"Max. Efficiency", "Min. MCT")
rm(best.cutoff)
- # the plot commands
- if(Plot==TRUE){
- plot(1-test.diag.table$Specificity,test.diag.table$Sensitivity,type="l",
- col=1,xlab="1-Specificity",ylab="Sensitivity",xlim=c(0,1),ylim=c(0,1))
- grid()
- segments(0,0,1,1,col="lightgray")
- if(Plot.point=="Max.Accuracy")
- {points(1-test.diag.table$Specificity[which.max(test.cutoff.table$Accuracy)],
- test.diag.table$Sensitivity[which.max(test.cutoff.table$Accuracy)],
- col=1,pch=19)
- title(sub="Cut-off estimated by maximazing accuracy",cex.sub=0.85)
- legend("bottomright",legend=(c(
- paste("cut off:",formatC(test.cutoff.table$test.values[which.max
- (test.cutoff.table$Accuracy)],digits=4)),
- paste("Sensitivity:",formatC(test.diag.table$Sensitivity[which.max
- (test.cutoff.table$Accuracy)],digits=4)),
- paste("Specificity:",formatC(test.diag.table$Specificity[which.max
- (test.cutoff.table$Accuracy)],digits=4)),
- paste("AUC:",formatC(AUC,digits=4))
- )),bty="n")}
- if(Plot.point=="Max.DOR")
- {points(1-test.diag.table$Specificity[which.max(test.cutoff.table$DOR)],
- test.diag.table$Sensitivity[which.max(test.cutoff.table$DOR)],
- col=1,pch=19)
- title(sub="Cut-off estimated by maximazing diagnostic odds ratio",cex.sub=0.85)
- legend("bottomright",legend=(c(
- paste("cut off:",formatC(test.cutoff.table$test.values[which.max
- (test.cutoff.table$DOR)],digits=4)),
- paste("Sensitivity:",formatC(test.diag.table$Sensitivity[which.max
- (test.cutoff.table$DOR)],digits=4)),
- paste("Specificity:",formatC(test.diag.table$Specificity[which.max
- (test.cutoff.table$DOR)],digits=4)),
- paste("AUC:",formatC(AUC,digits=4))
- )),bty="n")}
- if(Plot.point=="Error.rate")
- {points(1-test.diag.table$Specificity[which.min(test.cutoff.table$Error.rate)],
- test.diag.table$Sensitivity[which.min(test.cutoff.table$Error.rate)],
- col=1,pch=19)
- title(sub="Cut-off estimated by minimizing error rate",cex.sub=0.85)
- legend("bottomright",legend=(c(
- paste("cut off:",formatC(test.cutoff.table$test.values[which.min
- (test.cutoff.table$Error.rate)],digits=4)),
- paste("Sensitivity:",formatC(test.diag.table$Sensitivity[which.min
- (test.cutoff.table$Error.rate)],digits=4)),
- paste("Specificity:",formatC(test.diag.table$Specificity[which.min
- (test.cutoff.table$Error.rate)],digits=4)),
- paste("AUC:",formatC(AUC,digits=4))
- )),bty="n")}
- if(Plot.point=="Max.Accuracy.area")
- {points(1-test.diag.table$Specificity[which.max(test.cutoff.table$Accuracy.area)],
- test.diag.table$Sensitivity[which.max(test.cutoff.table$Accuracy.area)],
- col=1,pch=19)
- title(sub="Cut-off estimated by maximazing the area related to accuracy",cex.sub=0.85)
- legend("bottomright",legend=(c(
- paste("cut off:",formatC(test.cutoff.table$test.values[which.max
- (test.cutoff.table$Accuracy.area)],digits=4)),
- paste("Sensitivity:",formatC(test.diag.table$Sensitivity[which.max
- (test.cutoff.table$Accuracy.area)],digits=4)),
- paste("Specificity:",formatC(test.diag.table$Specificity[which.max
- (test.cutoff.table$Accuracy.area)],digits=4)),
- paste("AUC:",formatC(AUC,digits=4))
- )),bty="n")}
- if(Plot.point=="Max.Sens+Spec")
- {points(1-test.diag.table$Specificity[which.max(test.cutoff.table$Max.Se.Sp)],
- test.diag.table$Sensitivity[which.max(test.cutoff.table$Max.Se.Sp)],
- col=1,pch=19)
- title(sub="Cut-off value where the sum Se + Sp is maximized",cex.sub=0.85)
- legend("bottomright",legend=(c(
- paste("cut off:",formatC(test.cutoff.table$test.values[which.max
- (test.cutoff.table$Max.Se.Sp)],digits=4)),
- paste("Sensitivity:",formatC(test.diag.table$Sensitivity[which.max
- (test.cutoff.table$Max.Se.Sp)],digits=4)),
- paste("Specificity:",formatC(test.diag.table$Specificity[which.max
- (test.cutoff.table$Max.Se.Sp)],digits=4)),
- paste("AUC:",formatC(AUC,digits=4))
- )),bty="n")}
- if(Plot.point=="Max.Youden")
- {points(1-test.diag.table$Specificity[which.max(test.cutoff.table$Youden)],
- test.diag.table$Sensitivity[which.max(test.cutoff.table$Youden)],
- col=1,pch=19)
- title(sub="Cut-off estimated by maximazing Youden Index",cex.sub=0.85)
- legend("bottomright",legend=(c(
- paste("cut off:",formatC(test.cutoff.table$test.values[which.max
- (test.cutoff.table$Youden)],digits=4)),
- paste("Sensitivity:",formatC(test.diag.table$Sensitivity[which.max
- (test.cutoff.table$Youden)],digits=4)),
- paste("Specificity:",formatC(test.diag.table$Specificity[which.max
- (test.cutoff.table$Youden)],digits=4)),
- paste("AUC:",formatC(AUC,digits=4))
- )),bty="n")}
- if(Plot.point=="Se=Sp")
- {points(1-test.diag.table$Specificity[which.min(test.cutoff.table$Se.equals.Sp)],
- test.diag.table$Sensitivity[which.min(test.cutoff.table$Se.equals.Sp)],
- col=1,pch=19)
- title(sub="Cut-off value where Se is the closest to Sp",cex.sub=0.85)
- legend("bottomright",legend=(c(
- paste("cut off:",formatC(test.cutoff.table$test.values[which.min
- (test.cutoff.table$Se.equals.SP)],digits=4)),
- paste("Sensitivity:",formatC(test.diag.table$Sensitivity[which.min
- (test.cutoff.table$Se.equals.SP)],digits=4)),
- paste("Specificity:",formatC(test.diag.table$Specificity[which.min
- (test.cutoff.table$Se.equals.SP)],digits=4)),
- paste("AUC:",formatC(AUC,digits=4))
- )),bty="n")}
- if(Plot.point=="Min.ROC.Dist")
- {points(1-test.diag.table$Specificity[which.min(test.cutoff.table$MinRocDist)],
- test.diag.table$Sensitivity[which.min(test.cutoff.table$MinRocDist)],
- col=1,pch=19)
- title(sub="Cut-off that minimizes the distance between the curve and upper left corner",cex.sub=0.85)
- legend("bottomright",legend=(c(
- paste("cut off:",formatC(test.cutoff.table$test.values[which.min
- (test.cutoff.table$MinRocDist)],digits=4)),
- paste("Sensitivity:",formatC(test.diag.table$Sensitivity[which.min
- (test.cutoff.table$MinRocDist)],digits=4)),
- paste("Specificity:",formatC(test.diag.table$Specificity[which.min
- (test.cutoff.table$MinRocDist)],digits=4)),
- paste("AUC:",formatC(AUC,digits=4))
- )),bty="n")}
- if(Plot.point=="Max.Efficiency")
- {points(1-test.diag.table$Specificity[which.max(test.cutoff.table$Efficiency)],
- test.diag.table$Sensitivity[which.max(test.cutoff.table$Efficiency)],
- col=1,pch=19)
- title(sub=paste("Cut-off maximizing efficiency: population prevalence =",
- formatC(pop.prevalence,digits=2)),cex.sub=0.85)
- legend("bottomright",legend=(c(
- paste("cut off:",formatC(test.cutoff.table$test.values[which.max
- (test.cutoff.table$Efficiency)],digits=4)),
- paste("Sensitivity:",formatC(test.diag.table$Sensitivity[which.max
- (test.cutoff.table$Efficiency)],digits=4)),
- paste("Specificity:",formatC(test.diag.table$Specificity[which.max
- (test.cutoff.table$Efficiency)],digits=4)),
- paste("AUC:",formatC(AUC,digits=4))
- )),bty="n")}
- if(Plot.point=="Min.MCT")
- {points(1-test.diag.table$Specificity[which.min(test.cutoff.table$MCT)],
- test.diag.table$Sensitivity[which.min(test.cutoff.table$MCT)],
- col=1,pch=19)
- title(sub=paste("Cut-off minimazing MCT: population prevalence =",
- formatC(pop.prevalence,digits=2),"; cost(FN)/cost(FP)=",
- formatC(Cost,digits=2)),cex.sub=0.85)
- legend("bottomright",legend=(c(
- paste("cut off:",formatC(test.cutoff.table$test.values[which.min
- (test.cutoff.table$MCT)],digits=4)),
- paste("Sensitivity:",formatC(test.diag.table$Sensitivity[which.min
- (test.cutoff.table$MCT)],digits=4)),
- paste("Specificity:",formatC(test.diag.table$Specificity[which.min
- (test.cutoff.table$MCT)],digits=4)),
- paste("AUC:",formatC(AUC,digits=4))
- )),bty="n")}
- }
#names(pop.prevalence)<-c("Informed disease prevalence - same as sample prevalence if not informed")
#names(sample.prevalence)<-c("Observed prevalence by gold standard")
reteval<-list(pop.prevalence=pop.prevalence,
@@ -311,6 +166,7 @@
test.best.cutoff=test.best.cutoff,
test.diag.table=test.diag.table,
CL=CL,
+ cost=cost,
test.cutoff.table=test.cutoff.table)
class(reteval)<-"ROC"
@@ -318,5 +174,9 @@
if(Print.full==TRUE){ print(reteval,Full=TRUE) }
else{ print(reteval) }
}
+ # the plot commands
+ if(Plot==TRUE){
+ plot(reteval,Plot.point=Plot.point,cex.sub=cex.sub,cex=cex,lwd=lwd,p.cex=p.cex)
+ }
invisible(reteval)
}
\ No newline at end of file
Added: pkg/DiagnosisMed/R/plot.ROC.r
===================================================================
--- pkg/DiagnosisMed/R/plot.ROC.r (rev 0)
+++ pkg/DiagnosisMed/R/plot.ROC.r 2009-05-26 18:03:34 UTC (rev 15)
@@ -0,0 +1,122 @@
+ # the plot commands
+plot.ROC<-function(x,...,Plot.point="Min.ROC.Dist",cex.sub=.85,cex=1,lwd=1,p.cex=1){
+
+ if(Plot.point!="None" & Plot.point!="Min.ROC.Dist" & Plot.point!="Max.Accuracy" &
+ Plot.point!="Max.DOR" & Plot.point!="Error.rate" & Plot.point!="Max.Accuracy.area" &
+ Plot.point!="Max.Sens+Spec" & Plot.point!="Max.Youden" & Plot.point!="Se=Sp" &
+ Plot.point!="Min.ROC.Dist" & Plot.point!="Max.Efficiency" & Plot.point!="Min.MCT")
+ stop("The Plot.point option is not correctly set! Type '?ROC' to check possible options.")
+
+ plot(1-x$test.diag.table$Specificity,x$test.diag.table$Sensitivity,type="l",
+ col=1,lwd=lwd,xlab="1-Specificity",ylab="Sensitivity",xlim=c(0,1),ylim=c(0,1))
+ grid()
+ segments(0,0,1,1,col="lightgray")
+
+ if(Plot.point=="None"){
+ legend("bottomright",legend=(
+ paste("AUC:",formatC(x$AUC.summary[2],digits=4,format="f"))
+ ),bty="n",cex=cex)}
+
+ if(Plot.point=="Max.Accuracy")
+ {points(1-x$test.best.cutoff[1,5],x$test.best.cutoff[1,2],col=1,pch=19,cex=p.cex)
+ title(sub="Cut-off estimated by maximazing accuracy.",cex.sub=cex.sub)
+ legend("bottomright",legend=(c(paste("cut off:",formatC(x$test.best.cutoff[1,1],digits=4)),
+ paste("Sensitivity:",formatC(x$test.best.cutoff[1,2],digits=4,format="f")),
+ paste("Specificity:",formatC(x$test.best.cutoff[1,5],digits=4,format="f")),
+ paste("AUC:",formatC(x$AUC.summary[2],digits=4,format="f"))
+ )),bty="n",cex=cex)}
+
+ if(Plot.point=="Max.DOR")
+ {points(1-x$test.best.cutoff[2,5],x$test.best.cutoff[2,2],col=1,pch=19,cex=p.cex)
+ title(sub="Cut-off estimated by maximazing diagnostic odds ratio.",cex.sub=cex.sub)
+ legend("bottomright",legend=(c(
+ paste("cut off:",formatC(x$test.best.cutoff[2,1],digits=4)),
+ paste("Sensitivity:",formatC(x$test.best.cutoff[2,2],digits=4,format="f")),
+ paste("Specificity:",formatC(x$test.best.cutoff[2,5],digits=4,format="f")),
+ paste("AUC:",formatC(x$AUC.summary[2],digits=4,format="f"))
+ )),bty="n",cex=cex)}
+
+ if(Plot.point=="Error.rate")
+ {points(1-x$test.best.cutoff[3,5],x$test.best.cutoff[3,2],col=1,pch=19,cex=p.cex)
+ title(sub="Cut-off estimated by minimizing error rate.",cex.sub=cex.sub)
+ legend("bottomright",legend=(c(
+ paste("cut off:",formatC(x$test.best.cutoff[3,1],digits=4)),
+ paste("Sensitivity:",formatC(x$test.best.cutoff[3,2],digits=4,format="f")),
+ paste("Specificity:",formatC(x$test.best.cutoff[3,5],digits=4,format="f")),
+ paste("AUC:",formatC(x$AUC.summary[2],digits=4,format="f"))
+ )),bty="n",cex=cex)}
+
+ if(Plot.point=="Max.Accuracy.area")
+ {points(1-x$test.best.cutoff[4,5],x$test.best.cutoff[4,2],col=1,pch=19,cex=p.cex)
+ title(sub="Cut-off estimated by maximazing the area related to accuracy.",cex.sub=cex.sub)
+ legend("bottomright",legend=(c(
+ paste("cut off:",formatC(x$test.best.cutoff[4,1],digits=4)),
+ paste("Sensitivity:",formatC(x$test.best.cutoff[4,2],digits=4,format="f")),
+ paste("Specificity:",formatC(x$test.best.cutoff[4,5],digits=4,format="f")),
+ paste("AUC:",formatC(x$AUC.summary[2],digits=4,format="f"))
+ )),bty="n",cex=cex)}
+
+ if(Plot.point=="Max.Sens+Spec")
+ {points(1-x$test.best.cutoff[5,5],x$test.best.cutoff[4,2],col=1,pch=19,cex=p.cex)
+ title(sub="Cut-off value where the sum Se + Sp is maximized.",cex.sub=cex.sub)
+ legend("bottomright",legend=(c(
+ paste("cut off:",formatC(x$test.best.cutoff[5,1],digits=4)),
+ paste("Sensitivity:",formatC(x$test.best.cutoff[5,2],digits=4,format="f")),
+ paste("Specificity:",formatC(x$test.best.cutoff[5,5],digits=4,format="f")),
+ paste("AUC:",formatC(x$AUC.summary[2],digits=4,format="f"))
+ )),bty="n",cex=cex)}
+
+ if(Plot.point=="Max.Youden")
+ {points(1-x$test.best.cutoff[6,5],x$test.best.cutoff[6,2],
+ col=1,pch=19,cex=p.cex)
+ title(sub="Cut-off estimated by maximazing Youden Index.",cex.sub=cex.sub)
+ legend("bottomright",legend=(c(
+ paste("cut off:",formatC(x$test.best.cutoff[6,1],digits=4)),
+ paste("Sensitivity:",formatC(x$test.best.cutoff[6,2],digits=4,format="f")),
+ paste("Specificity:",formatC(x$test.best.cutoff[6,5],digits=4,format="f")),
+ paste("AUC:",formatC(x$AUC.summary[2],digits=4,format="f"))
+ )),bty="n",cex=cex)}
+
+ if(Plot.point=="Se=Sp")
+ {points(1-x$test.best.cutoff[7,5],x$test.best.cutoff[7,2],col=1,pch=19,cex=p.cex)
+ title(sub="Cut-off value where Se is the closest to Sp.",cex.sub=cex.sub)
+ legend("bottomright",legend=(c(
+ paste("cut off:",formatC(x$test.best.cutoff[7,1],digits=4)),
+ paste("Sensitivity:",formatC(x$test.best.cutoff[7,2],digits=4,format="f")),
+ paste("Specificity:",formatC(x$test.best.cutoff[7,5],digits=4,format="f")),
+ paste("AUC:",formatC(x$AUC.summary[2],digits=4,format="f"))
+ )),bty="n",cex=cex)}
+# REINICAIR REVISAO DAQUI..............
+ if(Plot.point=="Min.ROC.Dist")
+ {points(1-x$test.best.cutoff[8,5],x$test.best.cutoff[8,2],col=1,pch=19,cex=p.cex)
+ title(sub="Cut-off that minimizes the distance between the curve and upper left corner.",cex.sub=cex.sub)
+ legend("bottomright",legend=(c(
+ paste("cut off:",formatC(x$test.best.cutoff[8,1],digits=4)),
+ paste("Sensitivity:",formatC(x$test.best.cutoff[8,2],digits=4,format="f")),
+ paste("Specificity:",formatC(x$test.best.cutoff[8,5],digits=4,format="f")),
+ paste("AUC:",formatC(x$AUC.summary[2],digits=4,format="f"))
+ )),bty="n",cex=cex)}
+
+ if(Plot.point=="Max.Efficiency")
+ {points(1-x$test.best.cutoff[9,5],x$test.best.cutoff[9,2],col=1,pch=19,cex=p.cex)
+ title(sub=paste("Cut-off maximizing efficiency: population prevalence =",
+ formatC(x$pop.prevalence,digits=2)),cex.sub=cex.sub)
+ legend("bottomright",legend=(c(
+ paste("cut off:",formatC(x$test.best.cutoff[9,1],digits=4)),
+ paste("Sensitivity:",formatC(x$test.best.cutoff[9,2],digits=4,format="f")),
+ paste("Specificity:",formatC(x$test.best.cutoff[9,5],digits=4,format="f")),
+ paste("AUC:",formatC(x$AUC.summary[2],digits=4,format="f"))
+ )),bty="n",cex=cex)}
+
+ if(Plot.point=="Min.MCT")
+ {points(1-x$test.best.cutoff[10,5],x$test.best.cutoff[10,2],col=1,pch=19,cex=p.cex)
+ title(sub=paste("Cut-off minimazing MCT: population prevalence =",
+ formatC(x$pop.prevalence,digits=2,format="f"),"; cost(FN)/cost(FP) =",
+ formatC(x$cost,digits=2)),cex.sub=cex.sub)
+ legend("bottomright",legend=(c(
+ paste("cut off:",formatC(x$test.best.cutoff[10,1],digits=4)),
+ paste("Sensitivity:",formatC(x$test.best.cutoff[10,2],digits=4,format="f")),
+ paste("Specificity:",formatC(x$test.best.cutoff[10,5],digits=4,format="f")),
+ paste("AUC:",formatC(x$AUC.summary[2],digits=4,format="f"))
+ )),bty="n",cex=cex)}
+}
\ No newline at end of file
Modified: pkg/DiagnosisMed/R/print.ROC.r
===================================================================
--- pkg/DiagnosisMed/R/print.ROC.r 2009-05-21 05:39:45 UTC (rev 14)
+++ pkg/DiagnosisMed/R/print.ROC.r 2009-05-26 18:03:34 UTC (rev 15)
@@ -1,10 +1,11 @@
print.ROC<-function(x,Full=FALSE,...){
if (Full==TRUE){ page(x$test.diag.table,method="print")}
- cat(" Sample size:",paste(x$sample.size),"\n")
- cat(" Sample prevalence:",paste(round(x$sample.prevalence,digits = 4)),"\n")
- cat("Population prevalence:",paste(round(x$pop.prevalence,digits = 4))," - same as sample prevalence if not informed\n")
+ cat(" Sample size:",x$sample.size,"\n")
+ cat(" Sample prevalence:",round(x$sample.prevalence,digits = 4),"\n")
+ cat("Population prevalence:",round(x$pop.prevalence,digits = 4)," - same as sample prevalence if not informed\n")
+ cat("Informed Cost - cost(FN)/cost(FP):",x$cost,"\n")
cat("\n\n")
- cat("Non-parametric AUC (trapezoidal method) and its confidence",x$CL," limits (DeLong method)\n")
+ cat("Non-parametric AUC (trapezoidal method) and its",x$CL,"confidence limits (DeLong method)\n")
cat(" Area under ROC curve:",paste(round(x$AUC.summary[2],digits = 4)),"[",paste(round(x$AUC.summary[1],digits = 4)),"-",
paste(round(x$AUC.summary[3],digits = 4)),"]\n")
cat("\n\n")
Modified: pkg/DiagnosisMed/man/ROC.Rd
===================================================================
--- pkg/DiagnosisMed/man/ROC.Rd 2009-05-21 05:39:45 UTC (rev 14)
+++ pkg/DiagnosisMed/man/ROC.Rd 2009-05-26 18:03:34 UTC (rev 15)
@@ -1,6 +1,7 @@
\name{ROC}
\alias{ROC}
\alias{print.ROC}
+\alias{plot.ROC}
\title{Draw a ROC curve, estimate good cut-offs and compute validity measures for each cut-off}
\description{
Draw a non-parametric (empirical) ROC curve and compute test sensitivity, specificity, predictive values and likelihood ratios (and respective confidence limits) for each decision threshold. Estimate good decision threshold by a variety of methods.}
@@ -12,6 +13,10 @@
Prevalence = 0,
Plot = TRUE,
Plot.point = "Min.ROC.Dist",
+ cex.sub=.85,
+ cex=1,
+ lwd=1,
+ p.cex=1,
Print.full = FALSE,
Print = TRUE)
}
@@ -24,6 +29,8 @@
\item{Plot}{If FALSE, the ROC curve plot will not be displayed. Default is TRUE.}
\item{Plot.point}{The method of best cut-off estimation which will be displayed at ROC curve as a dot. Default is "Min.ROC.Dist". Possible options are:
+ "None" - only the AUC in the legend will appear;
+
"Max.Accuracy" - the cut-off which maximize the accuracy;
"Max.DOR" - the cut-off which maximize the diagnostic odds ratio;
@@ -44,6 +51,10 @@
"Min.MCT" - the cut-off which minimize the misclassification cost term.
}
+ \item{cex.sub}{The magnification to be used for sub-titles relative to the current setting of cex. See \link[graphics]{par}}
+ \item{cex}{Character expansion factor relative to current par("cex") for legend text. See \link[graphics]{legend}}
+ \item{lwd}{The line width, a positive number. See \link[graphics]{par}}
+ \item{p.cex}{Symbol expansion - a numerical vector - passed to points. See \link[graphics]{points}}
\item{Print.full}{If TRUE, a table with sensitivity, specificity, predictive values and likelihood ratios (and respective confidence limits) for each decision threshold will be displayed.}
\item{Print}{If FALSE, no results (detailed below in vlaues section) will be displayed on the output window. Default is TRUE}
}
@@ -105,10 +116,11 @@
par(mfrow=c(3,3))
# Running ROC analysis with the full table option
# and storing ROC objects into 'x' from which there are tables to draw the graphs below.
-x<-ROC(Gold2,Test_B,Print.full=FALSE)
+x<-DiagnosisMed::ROC(Gold2,Test_B,Print.full=TRUE) # There is no need to stick the package name before the function if it is loaded!
# Adding a title to the graph.
title(main="ROC graph")
-plot(x$test.cutoff.table$test.values,x$test.cutoff.table$DOR,type="l",ylab="DOR",xlab="Test values",ylim=c(0,60),xlim=c(0,2.5))
+# Some graphs that may be of interest. Validity measures at each test value.
+plot(x$test.cutoff.table$test.values,x$test.cutoff.table$DOR,type="l",ylab="DOR",xlab="Test values",ylim=c(0,90),xlim=c(0,2.5))
title(main="Test values x DOR")
plot(x$test.cutoff.table$test.values,x$test.cutoff.table$MCT,type="l",ylab="MCT",xlab="Test values",ylim=c(0,0.65),xlim=c(0,2.5))
title(main="Test values x MCT")
@@ -116,7 +128,7 @@
title(main="Test values x Efficiency")
plot(x$test.cutoff.table$test.values,x$test.cutoff.table$Youden,type="l",ylab="Youden index",xlab="Test values",ylim=c(0,.8),xlim=c(0,2.5))
title(main="Test values x Youden index")
-plot(x$test.diag.table$test.values,x$test.diag.table$PLR,type="l",ylim=c(0,12),ylab="Likelihood ratios",xlab="Test values",xlim=c(0,2.5))
+plot(x$test.diag.table$test.values,x$test.diag.table$PLR,type="l",ylim=c(0,49),ylab="Likelihood ratios",xlab="Test values",xlim=c(0,2.5))
lines(x$test.diag.table$test.values,x$test.diag.table$NLR,type="l",lty=2)
legend("right",lty=c(1,2),legend=c("PLR","NLR"))
title(main="Test values x Likelihood ratios")
@@ -128,6 +140,7 @@
title(main="Test values x Accuracy area")
plot(x$test.cutoff.table$test.values,x$test.cutoff.table$MinRocDist,type="l",,ylab="ROC distance",xlab="Test values",ylim=c(0,1),xlim=c(0,2.5))
title(main="Test values x ROC distance")
+rm(tutorial,x)
}
\keyword{iplot}
\keyword{univar}
Modified: pkg/DiagnosisMed/man/TGROC.Rd
===================================================================
--- pkg/DiagnosisMed/man/TGROC.Rd 2009-05-21 05:39:45 UTC (rev 14)
+++ pkg/DiagnosisMed/man/TGROC.Rd 2009-05-26 18:03:34 UTC (rev 15)
@@ -97,7 +97,7 @@
attach(tutorial)
# Running the analysis
TGROC(gold=Gold,test=Test_B)
-detach(tutorial)
+rm(tutorial)
}
\keyword{iplot}
\keyword{univar}
More information about the Diagnosismed-commits
mailing list