This code is untested, since you did not provide any example data. But it may help you get started.
Jean mydata <- read.csv(file.choose(), header=TRUE) library(ROCR) # ROC curve and assessment of my prediction plot(0:1, 0:1, type="n", xlab="False positive rate", ylab="True positive rate") abline(0, 1, col="red") nsim <- 5 auc <- rep(NA, nsim) for(i in 1:nsim) { select <- sample(nrow(mydata), round(nrow(mydata)*0.7)) data70 <- mydata[select, ] # train data30 <- mydata[-select, ] # test temp.glm <- glm(Death ~ Temperature, data=data70, family=binomial) pred <- prediction(data30$pred, data30$Death) perf <- performance(pred, "tpr", "fpr") plot(perf, add=TRUE) auc[i] <- attributes(performance(pred, "auc"))$y.values[[1]] # area under the ROC } auc On Tue, Jul 2, 2013 at 3:25 AM, Eddie Smith <eddie...@gmail.com> wrote: > Guys, > > I select 70% of my data and keep 30% of it for model validation. > > mydata <- read.csv(file.choose(), header=TRUE) > select <- sample(nrow(mydata), nrow(mydata) * .7) > data70 <- mydata[select,] # select > data30 <- mydata[-select,] # testing > temp.glm <- glm(Death~Temperature, data=data70, > family=binomial(link="logit")) > > library(ROCR) # ROC curve and assessment of my prediction > pred <- prediction(data30$pred, data30$Death) > perf <- performance(pred,"tpr","fpr") > plot(perf); abline(0, 1, col="red") > attributes(performance(pred, 'auc'))$y.values[[1]] # area under the ROC > > How do i make a loop so that the process could be repeated several time, > producing randomly ROC curve and under ROC values? > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.