R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- array(list(22,78.1,21.8,74.5,21.5,74.6,21.3,75.5,21.1,76.9,21.2,76.3,21,73.8,20.8,73.4,20.5,75.8,20.4,76.9,20.1,73.2,19.9,72.1,19.6,74.3,19.4,73.1,19.2,72.2,19.1,69.4,19.1,70.8,18.9,71.1,18.7,71.2,18.7,70.6,18.7,71.1,18.4,70.3,18.4,68.3,18.3,68.9,18.4,71.9,18.3,73.3,18.3,70.9,18,70,17.7,65.5,17.7,70.1,17.9,66.6,17.6,67.4,17.7,67.8,17.4,69.4,17.1,69.4,16.8,66.7,16.5,65,16.2,63.1,15.8,65,15.5,63.9,15.2,63,14.9,62.2,14.6,61.4,14.4,61,14.5,58.8,14.2,61),dim=c(2,46),dimnames=list(c('Sterfte','Huwelijk'),1:46)) > y <- array(NA,dim=c(2,46),dimnames=list(c('Sterfte','Huwelijk'),1:46)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: > library(brglm) Loading required package: profileModel > roc.plot <- function (sd, sdc, newplot = TRUE, ...) + { + sall <- sort(c(sd, sdc)) + sens <- 0 + specc <- 0 + for (i in length(sall):1) { + sens <- c(sens, mean(sd >= sall[i], na.rm = T)) + specc <- c(specc, mean(sdc >= sall[i], na.rm = T)) + } + if (newplot) { + plot(specc, sens, xlim = c(0, 1), ylim = c(0, 1), type = 'l', + xlab = '1-specificity', ylab = 'sensitivity', main = 'ROC plot', ...) + abline(0, 1) + } + else lines(specc, sens, ...) + npoints <- length(sens) + area <- sum(0.5 * (sens[-1] + sens[-npoints]) * (specc[-1] - + specc[-npoints])) + lift <- (sens - specc)[-1] + cutoff <- sall[lift == max(lift)][1] + sensopt <- sens[-1][lift == max(lift)][1] + specopt <- 1 - specc[-1][lift == max(lift)][1] + list(area = area, cutoff = cutoff, sensopt = sensopt, specopt = specopt) + } > roc.analysis <- function (object, newdata = NULL, newplot = TRUE, ...) + { + if (is.null(newdata)) { + sd <- object$fitted[object$y == 1] + sdc <- object$fitted[object$y == 0] + } + else { + sd <- predict(object, newdata, type = 'response')[newdata$y == + 1] + sdc <- predict(object, newdata, type = 'response')[newdata$y == + 0] + } + roc.plot(sd, sdc, newplot, ...) + } > hosmerlem <- function (y, yhat, g = 10) + { + cutyhat <- cut(yhat, breaks = quantile(yhat, probs = seq(0, + 1, 1/g)), include.lowest = T) + obs <- xtabs(cbind(1 - y, y) ~ cutyhat) + expect <- xtabs(cbind(1 - yhat, yhat) ~ cutyhat) + chisq <- sum((obs - expect)^2/expect) + P <- 1 - pchisq(chisq, g - 2) + c('X^2' = chisq, Df = g - 2, 'P(>Chi)' = P) + } > x <- as.data.frame(t(y)) > r <- brglm(x) Error in eval(expr, envir, enclos) : y values must be 0 <= y <= 1 Calls: brglm -> fit.proc -> eval -> eval Execution halted