R version 2.6.1 (2007-11-26) Copyright (C) 2007 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(0 + ,780.8 + ,93 + ,1 + ,699.1 + ,193 + ,1 + ,598.5 + ,112 + ,0 + ,735.3 + ,71 + ,0 + ,700.5 + ,105 + ,0 + ,706.9 + ,119 + ,0 + ,656.3 + ,162 + ,1 + ,1025.1 + ,277 + ,0 + ,639.4 + ,96 + ,0 + ,637.2 + ,24 + ,1 + ,1065.6 + ,231 + ,0 + ,576.1 + ,99 + ,0 + ,525.6 + ,27 + ,1 + ,377.5 + ,112 + ,0 + ,627.8 + ,96 + ,0 + ,646 + ,95 + ,1 + ,999.31 + ,143 + ,1 + ,168.3 + ,13 + ,0 + ,219.5 + ,22 + ,0 + ,507.4 + ,27 + ,1 + ,227.1 + ,56 + ,1 + ,821.6 + ,278 + ,0 + ,144.7 + ,10 + ,0 + ,761.6 + ,55 + ,1 + ,817.7 + ,61 + ,0 + ,547.8 + ,44 + ,0 + ,313.4 + ,10 + ,0 + ,291.8 + ,28 + ,0 + ,650.3 + ,53 + ,0 + ,679.4 + ,41 + ,1 + ,736.5 + ,135 + ,0 + ,842.6 + ,85 + ,0 + ,904.9 + ,14 + ,0 + ,263.7 + ,12 + ,1 + ,446.5 + ,93 + ,0 + ,511.8 + ,22 + ,1 + ,645.6 + ,101 + ,1 + ,873.9 + ,201 + ,0 + ,871.6 + ,2 + ,0 + ,287.3 + ,9 + ,0 + ,505.7 + ,49 + ,1 + ,597.7 + ,112 + ,1 + ,791 + ,27 + ,0 + ,725.8 + ,93 + ,0 + ,919.4 + ,49 + ,0 + ,114.7 + ,1 + ,0 + ,866.8 + ,69 + ,0 + ,870.7 + ,108 + ,0 + ,700.2 + ,108 + ,0 + ,636.5 + ,70 + ,1 + ,890.3 + ,165 + ,0 + ,879.1 + ,208 + ,0 + ,100.5 + ,4 + ,0 + ,782.8 + ,153 + ,0 + ,738.1 + ,67 + ,1 + ,762.3 + ,163 + ,1 + ,857 + ,75 + ,1 + ,712.5 + ,238 + ,1 + ,609.9 + ,90 + ,0 + ,940.1 + ,137 + ,0 + ,586.7 + ,133 + ,1 + ,49.3 + ,17 + ,0 + ,9.7 + ,0 + ,0 + ,786.7 + ,33 + ,1 + ,755.7 + ,123 + ,1 + ,749.2 + ,153 + ,1 + ,630.1 + ,126 + ,0 + ,835.6 + ,164 + ,0 + ,1024.3 + ,14 + ,1 + ,896.2 + ,102 + ,1 + ,410.7 + ,16 + ,0 + ,120.2 + ,6 + ,1 + ,700.7 + ,140 + ,0 + ,704.8 + ,120 + ,0 + ,1042.4 + ,124 + ,1 + ,831.8 + ,49 + ,1 + ,854.1 + ,99 + ,1 + ,547 + ,23 + ,0 + ,999.4 + ,80 + ,0 + ,532.6 + ,56 + ,0 + ,826.4 + ,152 + ,0 + ,670.9 + ,78 + ,1 + ,837.1 + ,105 + ,0 + ,1032.8 + ,229 + ,1 + ,639.9 + ,80 + ,1 + ,850.4 + ,144 + ,1 + ,845 + ,54 + ,1 + ,984.4 + ,52 + ,1 + ,993.2 + ,187 + ,1 + ,958.3 + ,117 + ,0 + ,832.5 + ,144 + ,1 + ,880.9 + ,147 + ,1 + ,1020.9 + ,182 + ,1 + ,764.8 + ,117 + ,1 + ,601.6 + ,104 + ,1 + ,686.2 + ,46 + ,1 + ,821.2 + ,138 + ,0 + ,836.9 + ,89 + ,0 + ,985.5 + ,120 + ,1 + ,973.2 + ,314 + ,1 + ,702.9 + ,111 + ,1 + ,929.2 + ,80 + ,0 + ,747.2 + ,187 + ,1 + ,654.3 + ,166 + ,1 + ,628.8 + ,70 + ,0 + ,564.6 + ,91 + ,0 + ,981 + ,202 + ,1 + ,705.3 + ,112 + ,0 + ,397.9 + ,40 + ,0 + ,56.3 + ,2 + ,1 + ,929.7 + ,69 + ,0 + ,559.7 + ,75 + ,1 + ,669.2 + ,78 + ,0 + ,923.5 + ,128 + ,1 + ,539.8 + ,38 + ,1 + ,401.7 + ,19 + ,0 + ,923.5 + ,171 + ,1 + ,688.3 + ,124 + ,0 + ,324.5 + ,4 + ,1 + ,613 + ,27 + ,0 + ,930.5 + ,255 + ,0 + ,348.6 + ,6 + ,1 + ,582.9 + ,143 + ,1 + ,919.7 + ,113 + ,0 + ,786.5 + ,87 + ,1 + ,637 + ,85 + ,1 + ,917.1 + ,110) + ,dim=c(3 + ,127) + ,dimnames=list(c('pass' + ,'ws' + ,'pe') + ,1:127)) > y <- array(NA,dim=c(3,127),dimnames=list(c('pass','ws','pe'),1:127)) > 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: Write here your technical program description (don't use hard returns!) > library(brlr) > 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 <- brlr(x) Warning message: In brlr(x) : Not converged: gradient values not all zero > summary(r) Call: brlr(formula = x) Coefficients: Value Std. Error t value (Intercept) -0.9294 0.5664 -1.6411 ws 0.0001 0.0010 0.0879 pe 0.0080 0.0037 2.1616 Deviance: 166.6604 Penalized deviance: 137.7453 Residual df: 124 > rc <- summary(r)$coeff > hm <- hosmerlem(y[1,],r$fitted.values) > hm X^2 Df P(>Chi) 6.1936207 8.0000000 0.6255534 > postscript(file="/var/www/html/rcomp/tmp/1y4kt1201950070.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > ra <- roc.analysis(r) > dev.off() null device 1 > te <- array(0,dim=c(2,99)) > for (i in 1:99) { + threshold <- i / 100 + numcorr1 <- 0 + numfaul1 <- 0 + numcorr0 <- 0 + numfaul0 <- 0 + for (j in 1:length(r$fitted.values)) { + if (y[1,j] > 0.99) { + if (r$fitted.values[j] >= threshold) numcorr1 = numcorr1 + 1 else numfaul1 = numfaul1 + 1 + } else { + if (r$fitted.values[j] < threshold) numcorr0 = numcorr0 + 1 else numfaul0 = numfaul0 + 1 + } + } + te[1,i] <- numfaul1 / (numfaul1 + numcorr1) + te[2,i] <- numfaul0 / (numfaul0 + numcorr0) + } > postscript(file="/var/www/html/rcomp/tmp/21vjy1201950070.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow=c(2,2)) > plot((1:99)/100,te[1,],xlab='Threshold',ylab='Type I error', main='1 - Specificity') > plot((1:99)/100,te[2,],xlab='Threshold',ylab='Type II error', main='1 - Sensitivity') > plot(te[1,],te[2,],xlab='Type I error',ylab='Type II error', main='(1-Sens.) vs (1-Spec.)') > plot((1:99)/100,te[1,]+te[2,],xlab='Threshold',ylab='Sum of Type I & II error', main='(1-Sens.) + (1-Spec.)') > par(op) > dev.off() null device 1 > load(file='/var/www/html/rcomp/createtable') > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Coefficients of Bias-Reduced Logistic Regression',5,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Variable',header=TRUE) > a<-table.element(a,'Parameter',header=TRUE) > a<-table.element(a,'S.E.',header=TRUE) > a<-table.element(a,'t-stat',header=TRUE) > a<-table.element(a,'2-sided p-value',header=TRUE) > a<-table.row.end(a) > for (i in 1:length(rc[,1])) { + a<-table.row.start(a) + a<-table.element(a,labels(rc)[[1]][i],header=TRUE) + a<-table.element(a,rc[i,1]) + a<-table.element(a,rc[i,2]) + a<-table.element(a,rc[i,3]) + a<-table.element(a,2*(1-pt(abs(rc[i,3]),r$df.residual))) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/3zi2s1201950070.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Summary of Bias-Reduced Logistic Regression',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Deviance',1,TRUE) > a<-table.element(a,r$deviance) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Penalized deviance',1,TRUE) > a<-table.element(a,r$penalized.deviance) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Residual Degrees of Freedom',1,TRUE) > a<-table.element(a,r$df.residual) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'ROC Area',1,TRUE) > a<-table.element(a,ra$area) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Hosmer–Lemeshow test',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Chi-square',1,TRUE) > a<-table.element(a,hm[1]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Degrees of Freedom',1,TRUE) > a<-table.element(a,hm[2]) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'P(>Chi)',1,TRUE) > a<-table.element(a,hm[3]) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/4vi5t1201950070.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Fit of Logistic Regression',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Index',1,TRUE) > a<-table.element(a,'Actual',1,TRUE) > a<-table.element(a,'Fitted',1,TRUE) > a<-table.element(a,'Error',1,TRUE) > a<-table.row.end(a) > for (i in 1:length(r$fitted.values)) { + a<-table.row.start(a) + a<-table.element(a,i,1,TRUE) + a<-table.element(a,y[1,i]) + a<-table.element(a,r$fitted.values[i]) + a<-table.element(a,y[1,i]-r$fitted.values[i]) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/5u60u1201950070.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Type I & II errors for various threshold values',3,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Threshold',1,TRUE) > a<-table.element(a,'Type I',1,TRUE) > a<-table.element(a,'Type II',1,TRUE) > a<-table.row.end(a) > for (i in 1:99) { + a<-table.row.start(a) + a<-table.element(a,i/100,1,TRUE) + a<-table.element(a,te[1,i]) + a<-table.element(a,te[2,i]) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/6kf3b1201950070.tab") > > system("convert tmp/1y4kt1201950070.ps tmp/1y4kt1201950070.png") > system("convert tmp/21vjy1201950070.ps tmp/21vjy1201950070.png") > > > proc.time() user system elapsed 2.412 0.542 2.515