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(279055 + ,73 + ,3 + ,96 + ,130 + ,212408 + ,75 + ,4 + ,75 + ,143 + ,233939 + ,83 + ,16 + ,70 + ,118 + ,222117 + ,106 + ,2 + ,134 + ,146 + ,179751 + ,55 + ,1 + ,72 + ,73 + ,70849 + ,28 + ,3 + ,8 + ,89 + ,605767 + ,135 + ,0 + ,173 + ,146 + ,33186 + ,19 + ,0 + ,1 + ,22 + ,227332 + ,62 + ,7 + ,88 + ,132 + ,258874 + ,48 + ,0 + ,98 + ,92 + ,359064 + ,120 + ,0 + ,112 + ,147 + ,264989 + ,131 + ,7 + ,125 + ,203 + ,212638 + ,87 + ,10 + ,57 + ,113 + ,368577 + ,85 + ,4 + ,139 + ,171 + ,269455 + ,88 + ,10 + ,87 + ,87 + ,397992 + ,190 + ,0 + ,176 + ,208 + ,335567 + ,76 + ,8 + ,114 + ,153 + ,428322 + ,172 + ,4 + ,121 + ,97 + ,182016 + ,58 + ,3 + ,103 + ,95 + ,267365 + ,89 + ,8 + ,135 + ,197 + ,279428 + ,73 + ,0 + ,123 + ,160 + ,508849 + ,111 + ,1 + ,99 + ,148 + ,206722 + ,47 + ,5 + ,74 + ,84 + ,200004 + ,58 + ,9 + ,103 + ,227 + ,257139 + ,133 + ,1 + ,158 + ,154 + ,270941 + ,138 + ,0 + ,116 + ,151 + ,324969 + ,134 + ,5 + ,114 + ,142 + ,329962 + ,92 + ,0 + ,150 + ,148 + ,190867 + ,60 + ,0 + ,64 + ,110 + ,393860 + ,79 + ,0 + ,150 + ,149 + ,327660 + ,89 + ,3 + ,143 + ,179 + ,269239 + ,83 + ,6 + ,50 + ,149 + ,391045 + ,105 + ,1 + ,145 + ,187 + ,130446 + ,49 + ,4 + ,56 + ,153 + ,430118 + ,104 + ,4 + ,141 + ,163 + ,273950 + ,56 + ,0 + ,83 + ,127 + ,428077 + ,128 + ,0 + ,112 + ,151 + ,254312 + ,93 + ,2 + ,79 + ,100 + ,120351 + ,35 + ,1 + ,33 + ,46 + ,395643 + ,211 + ,2 + ,152 + ,156 + ,345875 + ,86 + ,10 + ,126 + ,128 + ,216827 + ,82 + ,10 + ,97 + ,111 + ,224524 + ,83 + ,5 + ,84 + ,119 + ,182485 + ,69 + ,6 + ,68 + ,148 + ,157164 + ,85 + ,1 + ,50 + ,65 + ,459455 + ,157 + ,2 + ,101 + ,134 + ,78800 + ,42 + ,2 + ,20 + ,66 + ,217932 + ,84 + ,0 + ,101 + ,201 + ,368086 + ,123 + ,10 + ,150 + ,177 + ,230299 + ,70 + ,3 + ,129 + ,156 + ,244782 + ,81 + ,0 + ,99 + ,158 + ,24188 + ,24 + ,0 + ,8 + ,7 + ,400109 + ,334 + ,8 + ,88 + ,175 + ,65029 + ,17 + ,5 + ,21 + ,61 + ,101097 + ,64 + ,3 + ,30 + ,41 + ,309810 + ,67 + ,1 + ,102 + ,133 + ,369627 + ,90 + ,5 + ,163 + ,228 + ,367127 + ,204 + ,6 + ,132 + ,140 + ,377704 + ,154 + ,0 + ,161 + ,155 + ,280106 + ,90 + ,12 + ,90 + ,141 + ,400971 + ,153 + ,10 + ,160 + ,181 + ,315924 + ,122 + ,12 + ,139 + ,75 + ,291391 + ,124 + ,11 + ,104 + ,97 + ,295075 + ,93 + ,8 + ,103 + ,142 + ,280018 + ,81 + ,3 + ,66 + ,136 + ,267432 + ,71 + ,0 + ,163 + ,87 + ,217181 + ,141 + ,6 + ,93 + ,140 + ,258166 + ,159 + ,10 + ,85 + ,169 + ,260919 + ,87 + ,2 + ,150 + ,129 + ,182961 + ,73 + ,5 + ,143 + ,92 + ,256967 + ,74 + ,13 + ,107 + ,160 + ,73566 + ,32 + ,6 + ,22 + ,67 + ,272362 + ,93 + ,7 + ,85 + ,179 + ,229056 + ,62 + ,2 + ,101 + ,90 + ,229851 + ,70 + ,5 + ,131 + ,144 + ,371391 + ,91 + ,4 + ,140 + ,144 + ,398210 + ,104 + ,3 + ,156 + ,144 + ,220419 + ,111 + ,6 + ,81 + ,134 + ,231884 + ,72 + ,2 + ,137 + ,146 + ,217714 + ,72 + ,0 + ,102 + ,121 + ,200046 + ,53 + ,1 + ,72 + ,112 + ,483074 + ,131 + ,1 + ,161 + ,145 + ,146100 + ,72 + ,5 + ,30 + ,99 + ,295224 + ,109 + ,2 + ,120 + ,96 + ,80953 + ,25 + ,0 + ,49 + ,27 + ,217384 + ,63 + ,0 + ,121 + ,77 + ,179344 + ,62 + ,6 + ,76 + ,137 + ,415550 + ,221 + ,1 + ,85 + ,151 + ,389059 + ,129 + ,4 + ,151 + ,126 + ,180679 + ,106 + ,1 + ,165 + ,159 + ,299505 + ,104 + ,1 + ,89 + ,101 + ,292260 + ,84 + ,3 + ,168 + ,144 + ,199481 + ,68 + ,10 + ,48 + ,102 + ,282361 + ,78 + ,1 + ,149 + ,135 + ,329281 + ,89 + ,4 + ,75 + ,147 + ,234577 + ,48 + ,5 + ,107 + ,155 + ,297995 + ,67 + ,7 + ,116 + ,138 + ,329583 + ,89 + ,0 + ,173 + ,113 + ,416463 + ,163 + ,12 + ,155 + ,248 + ,415683 + ,119 + ,13 + ,165 + ,116 + ,297080 + ,142 + ,9 + ,121 + ,176 + ,318283 + ,70 + ,0 + ,156 + ,140 + ,224033 + ,199 + ,0 + ,86 + ,59 + ,43287 + ,14 + ,4 + ,13 + ,64 + ,238089 + ,87 + ,4 + ,120 + ,40 + ,263322 + ,160 + ,0 + ,117 + ,98 + ,299566 + ,60 + ,0 + ,133 + ,139 + ,321797 + ,95 + ,0 + ,169 + ,135 + ,193926 + ,95 + ,0 + ,39 + ,97 + ,175138 + ,105 + ,0 + ,125 + ,142 + ,354041 + ,78 + ,5 + ,82 + ,155 + ,303273 + ,91 + ,1 + ,148 + ,115 + ,23668 + ,13 + ,0 + ,12 + ,0 + ,196743 + ,79 + ,0 + ,146 + ,103 + ,61857 + ,25 + ,4 + ,23 + ,30 + ,217543 + ,54 + ,0 + ,87 + ,130 + ,440711 + ,128 + ,1 + ,164 + ,102 + ,21054 + ,16 + ,0 + ,4 + ,0 + ,252805 + ,52 + ,5 + ,81 + ,77 + ,31961 + ,22 + ,0 + ,18 + ,9 + ,360436 + ,125 + ,3 + ,118 + ,150 + ,251948 + ,77 + ,7 + ,76 + ,163 + ,187003 + ,96 + ,14 + ,55 + ,148 + ,180842 + ,58 + ,3 + ,62 + ,94 + ,38214 + ,34 + ,0 + ,16 + ,21 + ,280392 + ,56 + ,3 + ,98 + ,151 + ,358276 + ,84 + ,0 + ,137 + ,187 + ,211775 + ,67 + ,0 + ,50 + ,171 + ,447335 + ,90 + ,4 + ,152 + ,170 + ,348017 + ,99 + ,0 + ,163 + ,145 + ,441946 + ,133 + ,3 + ,142 + ,198 + ,215177 + ,43 + ,0 + ,80 + ,152 + ,130177 + ,47 + ,0 + ,59 + ,112 + ,316128 + ,363 + ,4 + ,94 + ,173 + ,466139 + ,198 + ,5 + ,128 + ,177 + ,162279 + ,62 + ,16 + ,63 + ,153 + ,416643 + ,140 + ,6 + ,127 + ,161 + ,178322 + ,86 + ,5 + ,60 + ,115 + ,292443 + ,54 + ,2 + ,118 + ,147 + ,283913 + ,100 + ,1 + ,110 + ,124 + ,244802 + ,126 + ,1 + ,45 + ,57 + ,387072 + ,125 + ,9 + ,96 + ,144 + ,246963 + ,92 + ,1 + ,128 + ,126 + ,173260 + ,63 + ,3 + ,41 + ,78 + ,346748 + ,108 + ,11 + ,146 + ,153 + ,176654 + ,59 + ,5 + ,147 + ,196 + ,268189 + ,95 + ,2 + ,121 + ,130 + ,314070 + ,112 + ,1 + ,185 + ,159 + ,1 + ,0 + ,9 + ,0 + ,0 + ,14688 + ,10 + ,0 + ,4 + ,0 + ,98 + ,1 + ,0 + ,0 + ,0 + ,455 + ,2 + ,0 + ,0 + ,0 + ,0 + ,0 + ,1 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,0 + ,291650 + ,94 + ,2 + ,85 + ,94 + ,415421 + ,168 + ,3 + ,164 + ,129 + ,0 + ,0 + ,0 + ,0 + ,0 + ,203 + ,4 + ,0 + ,0 + ,0 + ,7199 + ,5 + ,0 + ,7 + ,0 + ,46660 + ,20 + ,0 + ,12 + ,13 + ,17547 + ,5 + ,0 + ,0 + ,4 + ,121550 + ,46 + ,0 + ,37 + ,89 + ,969 + ,2 + ,0 + ,0 + ,0 + ,242774 + ,75 + ,2 + ,62 + ,71) + ,dim=c(5 + ,164) + ,dimnames=list(c('Tijd_RFC' + ,'#Logins' + ,'#Gedeelde_Compendia' + ,'#Blogs' + ,'#Reviews+120tekens') + ,1:164)) > y <- array(NA,dim=c(5,164),dimnames=list(c('Tijd_RFC','#Logins','#Gedeelde_Compendia','#Blogs','#Reviews+120tekens'),1:164)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '1' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Dr. Ian E. Holliday > #To cite this work: Ian E. Holliday, 2009, 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: > #Technical description: > library(party) Loading required package: survival Loading required package: splines Loading required package: grid Loading required package: modeltools Loading required package: stats4 Loading required package: coin Loading required package: mvtnorm Loading required package: zoo Loading required package: sandwich Loading required package: strucchange Loading required package: vcd Loading required package: MASS Loading required package: colorspace > library(Hmisc) Attaching package: 'Hmisc' The following object(s) are masked from 'package:survival': untangle.specials The following object(s) are masked from 'package:base': format.pval, round.POSIXt, trunc.POSIXt, units > par1 <- as.numeric(par1) > par3 <- as.numeric(par3) > x <- data.frame(t(y)) > is.data.frame(x) [1] TRUE > x <- x[!is.na(x[,par1]),] > k <- length(x[1,]) > n <- length(x[,1]) > colnames(x)[par1] [1] "Tijd_RFC" > x[,par1] [1] 279055 212408 233939 222117 179751 70849 605767 33186 227332 258874 [11] 359064 264989 212638 368577 269455 397992 335567 428322 182016 267365 [21] 279428 508849 206722 200004 257139 270941 324969 329962 190867 393860 [31] 327660 269239 391045 130446 430118 273950 428077 254312 120351 395643 [41] 345875 216827 224524 182485 157164 459455 78800 217932 368086 230299 [51] 244782 24188 400109 65029 101097 309810 369627 367127 377704 280106 [61] 400971 315924 291391 295075 280018 267432 217181 258166 260919 182961 [71] 256967 73566 272362 229056 229851 371391 398210 220419 231884 217714 [81] 200046 483074 146100 295224 80953 217384 179344 415550 389059 180679 [91] 299505 292260 199481 282361 329281 234577 297995 329583 416463 415683 [101] 297080 318283 224033 43287 238089 263322 299566 321797 193926 175138 [111] 354041 303273 23668 196743 61857 217543 440711 21054 252805 31961 [121] 360436 251948 187003 180842 38214 280392 358276 211775 447335 348017 [131] 441946 215177 130177 316128 466139 162279 416643 178322 292443 283913 [141] 244802 387072 246963 173260 346748 176654 268189 314070 1 14688 [151] 98 455 0 0 291650 415421 0 203 7199 46660 [161] 17547 121550 969 242774 > if (par2 == 'kmeans') { + cl <- kmeans(x[,par1], par3) + print(cl) + clm <- matrix(cbind(cl$centers,1:par3),ncol=2) + clm <- clm[sort.list(clm[,1]),] + for (i in 1:par3) { + cl$cluster[cl$cluster==clm[i,2]] <- paste('C',i,sep='') + } + cl$cluster <- as.factor(cl$cluster) + print(cl$cluster) + x[,par1] <- cl$cluster + } > if (par2 == 'quantiles') { + x[,par1] <- cut2(x[,par1],g=par3) + } > if (par2 == 'hclust') { + hc <- hclust(dist(x[,par1])^2, 'cen') + print(hc) + memb <- cutree(hc, k = par3) + dum <- c(mean(x[memb==1,par1])) + for (i in 2:par3) { + dum <- c(dum, mean(x[memb==i,par1])) + } + hcm <- matrix(cbind(dum,1:par3),ncol=2) + hcm <- hcm[sort.list(hcm[,1]),] + for (i in 1:par3) { + memb[memb==hcm[i,2]] <- paste('C',i,sep='') + } + memb <- as.factor(memb) + print(memb) + x[,par1] <- memb + } > if (par2=='equal') { + ed <- cut(as.numeric(x[,par1]),par3,labels=paste('C',1:par3,sep='')) + x[,par1] <- as.factor(ed) + } > table(x[,par1]) 0 1 98 203 455 969 7199 14688 17547 21054 23668 3 1 1 1 1 1 1 1 1 1 1 24188 31961 33186 38214 43287 46660 61857 65029 70849 73566 78800 1 1 1 1 1 1 1 1 1 1 1 80953 101097 120351 121550 130177 130446 146100 157164 162279 173260 175138 1 1 1 1 1 1 1 1 1 1 1 176654 178322 179344 179751 180679 180842 182016 182485 182961 187003 190867 1 1 1 1 1 1 1 1 1 1 1 193926 196743 199481 200004 200046 206722 211775 212408 212638 215177 216827 1 1 1 1 1 1 1 1 1 1 1 217181 217384 217543 217714 217932 220419 222117 224033 224524 227332 229056 1 1 1 1 1 1 1 1 1 1 1 229851 230299 231884 233939 234577 238089 242774 244782 244802 246963 251948 1 1 1 1 1 1 1 1 1 1 1 252805 254312 256967 257139 258166 258874 260919 263322 264989 267365 267432 1 1 1 1 1 1 1 1 1 1 1 268189 269239 269455 270941 272362 273950 279055 279428 280018 280106 280392 1 1 1 1 1 1 1 1 1 1 1 282361 283913 291391 291650 292260 292443 295075 295224 297080 297995 299505 1 1 1 1 1 1 1 1 1 1 1 299566 303273 309810 314070 315924 316128 318283 321797 324969 327660 329281 1 1 1 1 1 1 1 1 1 1 1 329583 329962 335567 345875 346748 348017 354041 358276 359064 360436 367127 1 1 1 1 1 1 1 1 1 1 1 368086 368577 369627 371391 377704 387072 389059 391045 393860 395643 397992 1 1 1 1 1 1 1 1 1 1 1 398210 400109 400971 415421 415550 415683 416463 416643 428077 428322 430118 1 1 1 1 1 1 1 1 1 1 1 440711 441946 447335 459455 466139 483074 508849 605767 1 1 1 1 1 1 1 1 > colnames(x) [1] "Tijd_RFC" "X.Logins" "X.Gedeelde_Compendia" [4] "X.Blogs" "X.Reviews.120tekens" > colnames(x)[par1] [1] "Tijd_RFC" > x[,par1] [1] 279055 212408 233939 222117 179751 70849 605767 33186 227332 258874 [11] 359064 264989 212638 368577 269455 397992 335567 428322 182016 267365 [21] 279428 508849 206722 200004 257139 270941 324969 329962 190867 393860 [31] 327660 269239 391045 130446 430118 273950 428077 254312 120351 395643 [41] 345875 216827 224524 182485 157164 459455 78800 217932 368086 230299 [51] 244782 24188 400109 65029 101097 309810 369627 367127 377704 280106 [61] 400971 315924 291391 295075 280018 267432 217181 258166 260919 182961 [71] 256967 73566 272362 229056 229851 371391 398210 220419 231884 217714 [81] 200046 483074 146100 295224 80953 217384 179344 415550 389059 180679 [91] 299505 292260 199481 282361 329281 234577 297995 329583 416463 415683 [101] 297080 318283 224033 43287 238089 263322 299566 321797 193926 175138 [111] 354041 303273 23668 196743 61857 217543 440711 21054 252805 31961 [121] 360436 251948 187003 180842 38214 280392 358276 211775 447335 348017 [131] 441946 215177 130177 316128 466139 162279 416643 178322 292443 283913 [141] 244802 387072 246963 173260 346748 176654 268189 314070 1 14688 [151] 98 455 0 0 291650 415421 0 203 7199 46660 [161] 17547 121550 969 242774 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > if (par2 != 'none') { + m <- ctree(as.formula(paste('as.factor(',colnames(x)[par1],') ~ .',sep='')),data = x) + if (par4=='yes') { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'10-Fold Cross Validation',3+2*par3,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'',1,TRUE) + a<-table.element(a,'Prediction (training)',par3+1,TRUE) + a<-table.element(a,'Prediction (testing)',par3+1,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'Actual',1,TRUE) + for (jjj in 1:par3) a<-table.element(a,paste('C',jjj,sep=''),1,TRUE) + a<-table.element(a,'CV',1,TRUE) + for (jjj in 1:par3) a<-table.element(a,paste('C',jjj,sep=''),1,TRUE) + a<-table.element(a,'CV',1,TRUE) + a<-table.row.end(a) + for (i in 1:10) { + ind <- sample(2, nrow(x), replace=T, prob=c(0.9,0.1)) + m.ct <- ctree(as.formula(paste('as.factor(',colnames(x)[par1],') ~ .',sep='')),data =x[ind==1,]) + if (i==1) { + m.ct.i.pred <- predict(m.ct, newdata=x[ind==1,]) + m.ct.i.actu <- x[ind==1,par1] + m.ct.x.pred <- predict(m.ct, newdata=x[ind==2,]) + m.ct.x.actu <- x[ind==2,par1] + } else { + m.ct.i.pred <- c(m.ct.i.pred,predict(m.ct, newdata=x[ind==1,])) + m.ct.i.actu <- c(m.ct.i.actu,x[ind==1,par1]) + m.ct.x.pred <- c(m.ct.x.pred,predict(m.ct, newdata=x[ind==2,])) + m.ct.x.actu <- c(m.ct.x.actu,x[ind==2,par1]) + } + } + print(m.ct.i.tab <- table(m.ct.i.actu,m.ct.i.pred)) + numer <- 0 + for (i in 1:par3) { + print(m.ct.i.tab[i,i] / sum(m.ct.i.tab[i,])) + numer <- numer + m.ct.i.tab[i,i] + } + print(m.ct.i.cp <- numer / sum(m.ct.i.tab)) + print(m.ct.x.tab <- table(m.ct.x.actu,m.ct.x.pred)) + numer <- 0 + for (i in 1:par3) { + print(m.ct.x.tab[i,i] / sum(m.ct.x.tab[i,])) + numer <- numer + m.ct.x.tab[i,i] + } + print(m.ct.x.cp <- numer / sum(m.ct.x.tab)) + for (i in 1:par3) { + a<-table.row.start(a) + a<-table.element(a,paste('C',i,sep=''),1,TRUE) + for (jjj in 1:par3) a<-table.element(a,m.ct.i.tab[i,jjj]) + a<-table.element(a,round(m.ct.i.tab[i,i]/sum(m.ct.i.tab[i,]),4)) + for (jjj in 1:par3) a<-table.element(a,m.ct.x.tab[i,jjj]) + a<-table.element(a,round(m.ct.x.tab[i,i]/sum(m.ct.x.tab[i,]),4)) + a<-table.row.end(a) + } + a<-table.row.start(a) + a<-table.element(a,'Overall',1,TRUE) + for (jjj in 1:par3) a<-table.element(a,'-') + a<-table.element(a,round(m.ct.i.cp,4)) + for (jjj in 1:par3) a<-table.element(a,'-') + a<-table.element(a,round(m.ct.x.cp,4)) + a<-table.row.end(a) + a<-table.end(a) + table.save(a,file="/var/wessaorg/rcomp/tmp/1pi761324647008.tab") + } + } > m Conditional inference tree with 8 terminal nodes Response: Tijd_RFC Inputs: X.Logins, X.Gedeelde_Compendia, X.Blogs, X.Reviews.120tekens Number of observations: 164 1) X.Blogs <= 37; criterion = 1, statistic = 109.044 2) X.Blogs <= 18; criterion = 1, statistic = 23.002 3) X.Logins <= 10; criterion = 0.999, statistic = 14.25 4)* weights = 11 3) X.Logins > 10 5)* weights = 9 2) X.Blogs > 18 6)* weights = 8 1) X.Blogs > 37 7) X.Blogs <= 81; criterion = 1, statistic = 44.877 8) X.Logins <= 69; criterion = 0.984, statistic = 8.319 9)* weights = 16 8) X.Logins > 69 10)* weights = 15 7) X.Blogs > 81 11) X.Logins <= 109; criterion = 1, statistic = 19.178 12) X.Logins <= 74; criterion = 0.992, statistic = 9.469 13)* weights = 25 12) X.Logins > 74 14)* weights = 42 11) X.Logins > 109 15)* weights = 38 > postscript(file="/var/wessaorg/rcomp/tmp/2ptlm1324647008.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(m) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/3f6ft1324647008.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x[,par1] ~ as.factor(where(m)),main='Response by Terminal Node',xlab='Terminal Node',ylab='Response') > dev.off() null device 1 > if (par2 == 'none') { + forec <- predict(m) + result <- as.data.frame(cbind(x[,par1],forec,x[,par1]-forec)) + colnames(result) <- c('Actuals','Forecasts','Residuals') + print(result) + } Actuals Forecasts Residuals 1 279055 247658.800 31396.200 2 212408 231212.867 -18804.867 3 233939 231212.867 2726.133 4 222117 302217.619 -80100.619 5 179751 179775.625 -24.625 6 70849 37007.444 33841.556 7 605767 372649.895 233117.105 8 33186 37007.444 -3821.444 9 227332 247658.800 -20326.800 10 258874 247658.800 11215.200 11 359064 372649.895 -13585.895 12 264989 372649.895 -107660.895 13 212638 231212.867 -18574.867 14 368577 302217.619 66359.381 15 269455 302217.619 -32762.619 16 397992 372649.895 25342.105 17 335567 302217.619 33349.381 18 428322 372649.895 55672.105 19 182016 247658.800 -65642.800 20 267365 302217.619 -34852.619 21 279428 247658.800 31769.200 22 508849 372649.895 136199.105 23 206722 179775.625 26946.375 24 200004 247658.800 -47654.800 25 257139 372649.895 -115510.895 26 270941 372649.895 -101708.895 27 324969 372649.895 -47680.895 28 329962 302217.619 27744.381 29 190867 179775.625 11091.375 30 393860 302217.619 91642.381 31 327660 302217.619 25442.381 32 269239 231212.867 38026.133 33 391045 302217.619 88827.381 34 130446 179775.625 -49329.625 35 430118 302217.619 127900.381 36 273950 247658.800 26291.200 37 428077 372649.895 55427.105 38 254312 231212.867 23099.133 39 120351 96043.750 24307.250 40 395643 372649.895 22993.105 41 345875 302217.619 43657.381 42 216827 302217.619 -85390.619 43 224524 302217.619 -77693.619 44 182485 179775.625 2709.375 45 157164 231212.867 -74048.867 46 459455 372649.895 86805.105 47 78800 96043.750 -17243.750 48 217932 302217.619 -84285.619 49 368086 372649.895 -4563.895 50 230299 247658.800 -17359.800 51 244782 302217.619 -57435.619 52 24188 37007.444 -12819.444 53 400109 372649.895 27459.105 54 65029 96043.750 -31014.750 55 101097 96043.750 5053.250 56 309810 247658.800 62151.200 57 369627 302217.619 67409.381 58 367127 372649.895 -5522.895 59 377704 372649.895 5054.105 60 280106 302217.619 -22111.619 61 400971 372649.895 28321.105 62 315924 372649.895 -56725.895 63 291391 372649.895 -81258.895 64 295075 302217.619 -7142.619 65 280018 231212.867 48805.133 66 267432 247658.800 19773.200 67 217181 372649.895 -155468.895 68 258166 372649.895 -114483.895 69 260919 302217.619 -41298.619 70 182961 247658.800 -64697.800 71 256967 247658.800 9308.200 72 73566 96043.750 -22477.750 73 272362 302217.619 -29855.619 74 229056 247658.800 -18602.800 75 229851 247658.800 -17807.800 76 371391 302217.619 69173.381 77 398210 302217.619 95992.381 78 220419 231212.867 -10793.867 79 231884 247658.800 -15774.800 80 217714 247658.800 -29944.800 81 200046 179775.625 20270.375 82 483074 372649.895 110424.105 83 146100 96043.750 50056.250 84 295224 302217.619 -6993.619 85 80953 179775.625 -98822.625 86 217384 247658.800 -30274.800 87 179344 179775.625 -431.625 88 415550 372649.895 42900.105 89 389059 372649.895 16409.105 90 180679 302217.619 -121538.619 91 299505 302217.619 -2712.619 92 292260 302217.619 -9957.619 93 199481 179775.625 19705.375 94 282361 302217.619 -19856.619 95 329281 231212.867 98068.133 96 234577 247658.800 -13081.800 97 297995 247658.800 50336.200 98 329583 302217.619 27365.381 99 416463 372649.895 43813.105 100 415683 372649.895 43033.105 101 297080 372649.895 -75569.895 102 318283 247658.800 70624.200 103 224033 372649.895 -148616.895 104 43287 37007.444 6279.556 105 238089 302217.619 -64128.619 106 263322 372649.895 -109327.895 107 299566 247658.800 51907.200 108 321797 302217.619 19579.381 109 193926 231212.867 -37286.867 110 175138 302217.619 -127079.619 111 354041 302217.619 51823.381 112 303273 302217.619 1055.381 113 23668 37007.444 -13339.444 114 196743 302217.619 -105474.619 115 61857 96043.750 -34186.750 116 217543 247658.800 -30115.800 117 440711 372649.895 68061.105 118 21054 37007.444 -15953.444 119 252805 179775.625 73029.375 120 31961 37007.444 -5046.444 121 360436 372649.895 -12213.895 122 251948 231212.867 20735.133 123 187003 231212.867 -44209.867 124 180842 179775.625 1066.375 125 38214 37007.444 1206.556 126 280392 247658.800 32733.200 127 358276 302217.619 56058.381 128 211775 179775.625 31999.375 129 447335 302217.619 145117.381 130 348017 302217.619 45799.381 131 441946 372649.895 69296.105 132 215177 179775.625 35401.375 133 130177 179775.625 -49598.625 134 316128 372649.895 -56521.895 135 466139 372649.895 93489.105 136 162279 179775.625 -17496.625 137 416643 372649.895 43993.105 138 178322 231212.867 -52890.867 139 292443 247658.800 44784.200 140 283913 302217.619 -18304.619 141 244802 231212.867 13589.133 142 387072 372649.895 14422.105 143 246963 302217.619 -55254.619 144 173260 179775.625 -6515.625 145 346748 302217.619 44530.381 146 176654 247658.800 -71004.800 147 268189 302217.619 -34028.619 148 314070 372649.895 -58579.895 149 1 3741.818 -3740.818 150 14688 3741.818 10946.182 151 98 3741.818 -3643.818 152 455 3741.818 -3286.818 153 0 3741.818 -3741.818 154 0 3741.818 -3741.818 155 291650 302217.619 -10567.619 156 415421 372649.895 42771.105 157 0 3741.818 -3741.818 158 203 3741.818 -3538.818 159 7199 3741.818 3457.182 160 46660 37007.444 9652.556 161 17547 3741.818 13805.182 162 121550 96043.750 25506.250 163 969 3741.818 -2772.818 164 242774 231212.867 11561.133 > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } > postscript(file="/var/wessaorg/rcomp/tmp/4n9kw1324647008.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > if(par2=='none') { + op <- par(mfrow=c(2,2)) + plot(density(result$Actuals),main='Kernel Density Plot of Actuals') + plot(density(result$Residuals),main='Kernel Density Plot of Residuals') + plot(result$Forecasts,result$Actuals,main='Actuals versus Predictions',xlab='Predictions',ylab='Actuals') + plot(density(result$Forecasts),main='Kernel Density Plot of Predictions') + par(op) + } > if(par2!='none') { + plot(myt,main='Confusion Matrix',xlab='Actual',ylab='Predicted') + } > dev.off() null device 1 > if (par2 == 'none') { + detcoef <- cor(result$Forecasts,result$Actuals) + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Goodness of Fit',2,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'Correlation',1,TRUE) + a<-table.element(a,round(detcoef,4)) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'R-squared',1,TRUE) + a<-table.element(a,round(detcoef*detcoef,4)) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'RMSE',1,TRUE) + a<-table.element(a,round(sqrt(mean((result$Residuals)^2)),4)) + a<-table.row.end(a) + a<-table.end(a) + table.save(a,file="/var/wessaorg/rcomp/tmp/52xhk1324647008.tab") + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Actuals, Predictions, and Residuals',4,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'#',header=TRUE) + a<-table.element(a,'Actuals',header=TRUE) + a<-table.element(a,'Forecasts',header=TRUE) + a<-table.element(a,'Residuals',header=TRUE) + a<-table.row.end(a) + for (i in 1:length(result$Actuals)) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,result$Actuals[i]) + a<-table.element(a,result$Forecasts[i]) + a<-table.element(a,result$Residuals[i]) + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/wessaorg/rcomp/tmp/68rgi1324647008.tab") + } > if (par2 != 'none') { + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Confusion Matrix (predicted in columns / actuals in rows)',par3+1,TRUE) + a<-table.row.end(a) + a<-table.row.start(a) + a<-table.element(a,'',1,TRUE) + for (i in 1:par3) { + a<-table.element(a,paste('C',i,sep=''),1,TRUE) + } + a<-table.row.end(a) + for (i in 1:par3) { + a<-table.row.start(a) + a<-table.element(a,paste('C',i,sep=''),1,TRUE) + for (j in 1:par3) { + a<-table.element(a,myt[i,j]) + } + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/wessaorg/rcomp/tmp/75d7v1324647008.tab") + } > > try(system("convert tmp/2ptlm1324647008.ps tmp/2ptlm1324647008.png",intern=TRUE)) character(0) > try(system("convert tmp/3f6ft1324647008.ps tmp/3f6ft1324647008.png",intern=TRUE)) character(0) > try(system("convert tmp/4n9kw1324647008.ps tmp/4n9kw1324647008.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.673 0.302 3.969