R version 2.9.0 (2009-04-17) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(-999.00 + ,6654.00 + ,3.00 + ,6.30 + ,1.00 + ,3.00 + ,-999.00 + ,3.39 + ,1.00 + ,-999.00 + ,0.92 + ,3.00 + ,2.10 + ,2547.00 + ,4.00 + ,9.10 + ,10.55 + ,4.00 + ,15.80 + ,0.02 + ,1.00 + ,5.20 + ,160.00 + ,4.00 + ,10.90 + ,3.30 + ,1.00 + ,8.30 + ,52.16 + ,1.00 + ,11.00 + ,0.43 + ,4.00 + ,3.20 + ,465.00 + ,5.00 + ,7.60 + ,0.55 + ,2.00 + ,-999.00 + ,187.10 + ,5.00 + ,6.30 + ,0.08 + ,1.00 + ,8.60 + ,3.00 + ,2.00 + ,6.60 + ,0.79 + ,2.00 + ,9.50 + ,0.20 + ,2.00 + ,4.80 + ,1.41 + ,1.00 + ,12.00 + ,60.00 + ,1.00 + ,-999.00 + ,529.00 + ,5.00 + ,3.30 + ,27.66 + ,5.00 + ,11.00 + ,0.12 + ,2.00 + ,-999.00 + ,207.00 + ,1.00 + ,4.70 + ,85.00 + ,1.00 + ,-999.00 + ,36.33 + ,1.00 + ,10.40 + ,0.10 + ,3.00 + ,7.40 + ,1.04 + ,4.00 + ,2.10 + ,521.00 + ,5.00 + ,-999.00 + ,100.00 + ,1.00 + ,-999.00 + ,35.00 + ,4.00 + ,7.70 + ,0.01 + ,4.00 + ,17.90 + ,0.01 + ,1.00 + ,6.10 + ,62.00 + ,1.00 + ,8.20 + ,0.12 + ,1.00 + ,8.40 + ,1.35 + ,3.00 + ,11.90 + ,0.02 + ,3.00 + ,10.80 + ,0.05 + ,3.00 + ,13.80 + ,1.70 + ,1.00 + ,14.30 + ,3.50 + ,1.00 + ,-999.00 + ,250.00 + ,5.00 + ,15.20 + ,0.48 + ,2.00 + ,10.00 + ,10.00 + ,4.00 + ,11.90 + ,1.62 + ,2.00 + ,6.50 + ,192.00 + ,4.00 + ,7.50 + ,2.50 + ,5.00 + ,-999.00 + ,4.29 + ,2.00 + ,10.60 + ,0.28 + ,3.00 + ,7.40 + ,4.24 + ,1.00 + ,8.40 + ,6.80 + ,2.00 + ,5.70 + ,0.75 + ,2.00 + ,4.90 + ,3.60 + ,3.00 + ,-999.00 + ,14.83 + ,5.00 + ,3.20 + ,55.50 + ,5.00 + ,-999.00 + ,1.40 + ,2.00 + ,8.10 + ,0.06 + ,2.00 + ,11.00 + ,0.90 + ,2.00 + ,4.90 + ,2.00 + ,3.00 + ,13.20 + ,0.10 + ,2.00 + ,9.70 + ,4.19 + ,4.00 + ,12.80 + ,3.50 + ,1.00 + ,-999.00 + ,4.05 + ,1.00) + ,dim=c(3 + ,62) + ,dimnames=list(c('SWS' + ,'Wb' + ,'D') + ,1:62)) > y <- array(NA,dim=c(3,62),dimnames=list(c('SWS','Wb','D'),1:62)) > 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