R version 2.8.0 (2008-10-20) Copyright (C) 2008 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. Natural language support but running in an English locale 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(41 + ,38 + ,13 + ,12 + ,14 + ,12 + ,39 + ,32 + ,16 + ,11 + ,18 + ,11 + ,30 + ,35 + ,19 + ,15 + ,11 + ,14 + ,31 + ,33 + ,15 + ,6 + ,12 + ,12 + ,34 + ,37 + ,14 + ,13 + ,16 + ,21 + ,35 + ,29 + ,13 + ,10 + ,18 + ,12 + ,39 + ,31 + ,19 + ,12 + ,14 + ,22 + ,34 + ,36 + ,15 + ,14 + ,14 + ,11 + ,36 + ,35 + ,14 + ,12 + ,15 + ,10 + ,37 + ,38 + ,15 + ,6 + ,15 + ,13 + ,38 + ,31 + ,16 + ,10 + ,17 + ,10 + ,36 + ,34 + ,16 + ,12 + ,19 + ,8 + ,38 + ,35 + ,16 + ,12 + ,10 + ,15 + ,39 + ,38 + ,16 + ,11 + ,16 + ,14 + ,33 + ,37 + ,17 + ,15 + ,18 + ,10 + ,32 + ,33 + ,15 + ,12 + ,14 + ,14 + ,36 + ,32 + ,15 + ,10 + ,14 + ,14 + ,38 + ,38 + ,20 + ,12 + ,17 + ,11 + ,39 + ,38 + ,18 + ,11 + ,14 + ,10 + ,32 + ,32 + ,16 + ,12 + ,16 + ,13 + ,32 + ,33 + ,16 + ,11 + ,18 + ,7 + ,31 + ,31 + ,16 + ,12 + ,11 + ,14 + ,39 + ,38 + ,19 + ,13 + ,14 + ,12 + ,37 + ,39 + ,16 + ,11 + ,12 + ,14 + ,39 + ,32 + ,17 + ,9 + ,17 + ,11 + ,41 + ,32 + ,17 + ,13 + ,9 + ,9 + ,36 + ,35 + ,16 + ,10 + ,16 + ,11 + ,33 + ,37 + ,15 + ,14 + ,14 + ,15 + ,33 + ,33 + ,16 + ,12 + ,15 + ,14 + ,34 + ,33 + ,14 + ,10 + ,11 + ,13 + ,31 + ,28 + ,15 + ,12 + ,16 + ,9 + ,27 + ,32 + ,12 + ,8 + ,13 + ,15 + ,37 + ,31 + ,14 + ,10 + ,17 + ,10 + ,34 + ,37 + ,16 + ,12 + ,15 + ,11 + ,34 + ,30 + ,14 + ,12 + ,14 + ,13 + ,32 + ,33 + ,7 + ,7 + ,16 + ,8 + ,29 + ,31 + ,10 + ,6 + ,9 + ,20 + ,36 + ,33 + ,14 + ,12 + ,15 + ,12 + ,29 + ,31 + ,16 + ,10 + ,17 + ,10 + ,35 + ,33 + ,16 + ,10 + ,13 + ,10 + ,37 + ,32 + ,16 + ,10 + ,15 + ,9 + ,34 + ,33 + ,14 + ,12 + ,16 + ,14 + ,38 + ,32 + ,20 + ,15 + ,16 + ,8 + ,35 + ,33 + ,14 + ,10 + ,12 + ,14 + ,38 + ,28 + ,14 + ,10 + ,12 + ,11 + ,37 + ,35 + ,11 + ,12 + ,11 + ,13 + ,38 + ,39 + ,14 + ,13 + ,15 + ,9 + ,33 + ,34 + ,15 + ,11 + ,15 + ,11 + ,36 + ,38 + ,16 + ,11 + ,17 + ,15 + ,38 + ,32 + ,14 + ,12 + ,13 + ,11 + ,32 + ,38 + ,16 + ,14 + ,16 + ,10 + ,32 + ,30 + ,14 + ,10 + ,14 + ,14 + ,32 + ,33 + ,12 + ,12 + ,11 + ,18 + ,34 + ,38 + ,16 + ,13 + ,12 + ,14 + ,32 + ,32 + ,9 + ,5 + ,12 + ,11 + ,37 + ,32 + ,14 + ,6 + ,15 + ,12 + ,39 + ,34 + ,16 + ,12 + ,16 + ,13 + ,29 + ,34 + ,16 + ,12 + ,15 + ,9 + ,37 + ,36 + ,15 + ,11 + ,12 + ,10 + ,35 + ,34 + ,16 + ,10 + ,12 + ,15 + ,30 + ,28 + ,12 + ,7 + ,8 + ,20 + ,38 + ,34 + ,16 + ,12 + ,13 + ,12 + ,34 + ,35 + ,16 + ,14 + ,11 + ,12 + ,31 + ,35 + ,14 + ,11 + ,14 + ,14 + ,34 + ,31 + ,16 + ,12 + ,15 + ,13 + ,35 + ,37 + ,17 + ,13 + ,10 + ,11 + ,36 + ,35 + ,18 + ,14 + ,11 + ,17 + ,30 + ,27 + ,18 + ,11 + ,12 + ,12 + ,39 + ,40 + ,12 + ,12 + ,15 + ,13 + ,35 + ,37 + ,16 + ,12 + ,15 + ,14 + ,38 + ,36 + ,10 + ,8 + ,14 + ,13 + ,31 + ,38 + ,14 + ,11 + ,16 + ,15 + ,34 + ,39 + ,18 + ,14 + ,15 + ,13 + ,38 + ,41 + ,18 + ,14 + ,15 + ,10 + ,34 + ,27 + ,16 + ,12 + ,13 + ,11 + ,39 + ,30 + ,17 + ,9 + ,12 + ,19 + ,37 + ,37 + ,16 + ,13 + ,17 + ,13 + ,34 + ,31 + ,16 + ,11 + ,13 + ,17 + ,28 + ,31 + ,13 + ,12 + ,15 + ,13 + ,37 + ,27 + ,16 + ,12 + ,13 + ,9 + ,33 + ,36 + ,16 + ,12 + ,15 + ,11 + ,37 + ,38 + ,20 + ,12 + ,16 + ,10 + ,35 + ,37 + ,16 + ,12 + ,15 + ,9 + ,37 + ,33 + ,15 + ,12 + ,16 + ,12 + ,32 + ,34 + ,15 + ,11 + ,15 + ,12 + ,33 + ,31 + ,16 + ,10 + ,14 + ,13 + ,38 + ,39 + ,14 + ,9 + ,15 + ,13 + ,33 + ,34 + ,16 + ,12 + ,14 + ,12 + ,29 + ,32 + ,16 + ,12 + ,13 + ,15 + ,33 + ,33 + ,15 + ,12 + ,7 + ,22 + ,31 + ,36 + ,12 + ,9 + ,17 + ,13 + ,36 + ,32 + ,17 + ,15 + ,13 + ,15 + ,35 + ,41 + ,16 + ,12 + ,15 + ,13 + ,32 + ,28 + ,15 + ,12 + ,14 + ,15 + ,29 + ,30 + ,13 + ,12 + ,13 + ,10 + ,39 + ,36 + ,16 + ,10 + ,16 + ,11 + ,37 + ,35 + ,16 + ,13 + ,12 + ,16 + ,35 + ,31 + ,16 + ,9 + ,14 + ,11 + ,37 + ,34 + ,16 + ,12 + ,17 + ,11 + ,32 + ,36 + ,14 + ,10 + ,15 + ,10 + ,38 + ,36 + ,16 + ,14 + ,17 + ,10 + ,37 + ,35 + ,16 + ,11 + ,12 + ,16 + ,36 + ,37 + ,20 + ,15 + ,16 + ,12 + ,32 + ,28 + ,15 + ,11 + ,11 + ,11 + ,33 + ,39 + ,16 + ,11 + ,15 + ,16 + ,40 + ,32 + ,13 + ,12 + ,9 + ,19 + ,38 + ,35 + ,17 + ,12 + ,16 + ,11 + ,41 + ,39 + ,16 + ,12 + ,15 + ,16 + ,36 + ,35 + ,16 + ,11 + ,10 + ,15 + ,43 + ,42 + ,12 + ,7 + ,10 + ,24 + ,30 + ,34 + ,16 + ,12 + ,15 + ,14 + ,31 + ,33 + ,16 + ,14 + ,11 + ,15 + ,32 + ,41 + ,17 + ,11 + ,13 + ,11 + ,32 + ,33 + ,13 + ,11 + ,14 + ,15 + ,37 + ,34 + ,12 + ,10 + ,18 + ,12 + ,37 + ,32 + ,18 + ,13 + ,16 + ,10 + ,33 + ,40 + ,14 + ,13 + ,14 + ,14 + ,34 + ,40 + ,14 + ,8 + ,14 + ,13 + ,33 + ,35 + ,13 + ,11 + ,14 + ,9 + ,38 + ,36 + ,16 + ,12 + ,14 + ,15 + ,33 + ,37 + ,13 + ,11 + ,12 + ,15 + ,31 + ,27 + ,16 + ,13 + ,14 + ,14 + ,38 + ,39 + ,13 + ,12 + ,15 + ,11 + ,37 + ,38 + ,16 + ,14 + ,15 + ,8 + ,33 + ,31 + ,15 + ,13 + ,15 + ,11 + ,31 + ,33 + ,16 + ,15 + ,13 + ,11 + ,39 + ,32 + ,15 + ,10 + ,17 + ,8 + ,44 + ,39 + ,17 + ,11 + ,17 + ,10 + ,33 + ,36 + ,15 + ,9 + ,19 + ,11 + ,35 + ,33 + ,12 + ,11 + ,15 + ,13 + ,32 + ,33 + ,16 + ,10 + ,13 + ,11 + ,28 + ,32 + ,10 + ,11 + ,9 + ,20 + ,40 + ,37 + ,16 + ,8 + ,15 + ,10 + ,27 + ,30 + ,12 + ,11 + ,15 + ,15 + ,37 + ,38 + ,14 + ,12 + ,15 + ,12 + ,32 + ,29 + ,15 + ,12 + ,16 + ,14 + ,28 + ,22 + ,13 + ,9 + ,11 + ,23 + ,34 + ,35 + ,15 + ,11 + ,14 + ,14 + ,30 + ,35 + ,11 + ,10 + ,11 + ,16 + ,35 + ,34 + ,12 + ,8 + ,15 + ,11 + ,31 + ,35 + ,8 + ,9 + ,13 + ,12 + ,32 + ,34 + ,16 + ,8 + ,15 + ,10 + ,30 + ,34 + ,15 + ,9 + ,16 + ,14 + ,30 + ,35 + ,17 + ,15 + ,14 + ,12 + ,31 + ,23 + ,16 + ,11 + ,15 + ,12 + ,40 + ,31 + ,10 + ,8 + ,16 + ,11 + ,32 + ,27 + ,18 + ,13 + ,16 + ,12 + ,36 + ,36 + ,13 + ,12 + ,11 + ,13 + ,32 + ,31 + ,16 + ,12 + ,12 + ,11 + ,35 + ,32 + ,13 + ,9 + ,9 + ,19 + ,38 + ,39 + ,10 + ,7 + ,16 + ,12 + ,42 + ,37 + ,15 + ,13 + ,13 + ,17 + ,34 + ,38 + ,16 + ,9 + ,16 + ,9 + ,35 + ,39 + ,16 + ,6 + ,12 + ,12 + ,35 + ,34 + ,14 + ,8 + ,9 + ,19 + ,33 + ,31 + ,10 + ,8 + ,13 + ,18 + ,36 + ,32 + ,17 + ,15 + ,13 + ,15 + ,32 + ,37 + ,13 + ,6 + ,14 + ,14 + ,33 + ,36 + ,15 + ,9 + ,19 + ,11 + ,34 + ,32 + ,16 + ,11 + ,13 + ,9 + ,32 + ,35 + ,12 + ,8 + ,12 + ,18 + ,34 + ,36 + ,13 + ,8 + ,13 + ,16) + ,dim=c(6 + ,162) + ,dimnames=list(c('Connected' + ,'Separate' + ,'Learning' + ,'Software' + ,'Happiness' + ,'Depression') + ,1:162)) > y <- array(NA,dim=c(6,162),dimnames=list(c('Connected','Separate','Learning','Software','Happiness','Depression'),1:162)) > 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 = '5' > #'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 Attaching package: 'zoo' The following object(s) are masked from package:base : as.Date.numeric 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] "Happiness" > x[,par1] [1] 14 18 11 12 16 18 14 14 15 15 17 19 10 16 18 14 14 17 14 16 18 11 14 12 17 [26] 9 16 14 15 11 16 13 17 15 14 16 9 15 17 13 15 16 16 12 12 11 15 15 17 13 [51] 16 14 11 12 12 15 16 15 12 12 8 13 11 14 15 10 11 12 15 15 14 16 15 15 13 [76] 12 17 13 15 13 15 16 15 16 15 14 15 14 13 7 17 13 15 14 13 16 12 14 17 15 [101] 17 12 16 11 15 9 16 15 10 10 15 11 13 14 18 16 14 14 14 14 12 14 15 15 15 [126] 13 17 17 19 15 13 9 15 15 15 16 11 14 11 15 13 15 16 14 15 16 16 11 12 9 [151] 16 13 16 12 9 13 13 14 19 13 12 13 > 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]) 7 8 9 10 11 12 13 14 15 16 17 18 19 1 1 6 4 12 16 19 25 35 23 12 5 3 > colnames(x) [1] "Connected" "Separate" "Learning" "Software" "Happiness" [6] "Depression" > colnames(x)[par1] [1] "Happiness" > x[,par1] [1] 14 18 11 12 16 18 14 14 15 15 17 19 10 16 18 14 14 17 14 16 18 11 14 12 17 [26] 9 16 14 15 11 16 13 17 15 14 16 9 15 17 13 15 16 16 12 12 11 15 15 17 13 [51] 16 14 11 12 12 15 16 15 12 12 8 13 11 14 15 10 11 12 15 15 14 16 15 15 13 [76] 12 17 13 15 13 15 16 15 16 15 14 15 14 13 7 17 13 15 14 13 16 12 14 17 15 [101] 17 12 16 11 15 9 16 15 10 10 15 11 13 14 18 16 14 14 14 14 12 14 15 15 15 [126] 13 17 17 19 15 13 9 15 15 15 16 11 14 11 15 13 15 16 14 15 16 16 11 12 9 [151] 16 13 16 12 9 13 13 14 19 13 12 13 > if (par2 == 'none') { + m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) + } > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/www/html/freestat/rcomp/tmp/1m7y41293038902.tab") + } + } > m Conditional inference tree with 3 terminal nodes Response: Happiness Inputs: Connected, Separate, Learning, Software, Depression Number of observations: 162 1) Depression <= 16; criterion = 1, statistic = 47.688 2) Depression <= 13; criterion = 1, statistic = 16.565 3)* weights = 102 2) Depression > 13 4)* weights = 42 1) Depression > 16 5)* weights = 18 > postscript(file="/var/www/html/freestat/rcomp/tmp/2m7y41293038902.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/www/html/freestat/rcomp/tmp/3m7y41293038902.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 14 14.80392 -0.8039216 2 18 14.80392 3.1960784 3 11 13.52381 -2.5238095 4 12 14.80392 -2.8039216 5 16 10.88889 5.1111111 6 18 14.80392 3.1960784 7 14 10.88889 3.1111111 8 14 14.80392 -0.8039216 9 15 14.80392 0.1960784 10 15 14.80392 0.1960784 11 17 14.80392 2.1960784 12 19 14.80392 4.1960784 13 10 13.52381 -3.5238095 14 16 13.52381 2.4761905 15 18 14.80392 3.1960784 16 14 13.52381 0.4761905 17 14 13.52381 0.4761905 18 17 14.80392 2.1960784 19 14 14.80392 -0.8039216 20 16 14.80392 1.1960784 21 18 14.80392 3.1960784 22 11 13.52381 -2.5238095 23 14 14.80392 -0.8039216 24 12 13.52381 -1.5238095 25 17 14.80392 2.1960784 26 9 14.80392 -5.8039216 27 16 14.80392 1.1960784 28 14 13.52381 0.4761905 29 15 13.52381 1.4761905 30 11 14.80392 -3.8039216 31 16 14.80392 1.1960784 32 13 13.52381 -0.5238095 33 17 14.80392 2.1960784 34 15 14.80392 0.1960784 35 14 14.80392 -0.8039216 36 16 14.80392 1.1960784 37 9 10.88889 -1.8888889 38 15 14.80392 0.1960784 39 17 14.80392 2.1960784 40 13 14.80392 -1.8039216 41 15 14.80392 0.1960784 42 16 13.52381 2.4761905 43 16 14.80392 1.1960784 44 12 13.52381 -1.5238095 45 12 14.80392 -2.8039216 46 11 14.80392 -3.8039216 47 15 14.80392 0.1960784 48 15 14.80392 0.1960784 49 17 13.52381 3.4761905 50 13 14.80392 -1.8039216 51 16 14.80392 1.1960784 52 14 13.52381 0.4761905 53 11 10.88889 0.1111111 54 12 13.52381 -1.5238095 55 12 14.80392 -2.8039216 56 15 14.80392 0.1960784 57 16 14.80392 1.1960784 58 15 14.80392 0.1960784 59 12 14.80392 -2.8039216 60 12 13.52381 -1.5238095 61 8 10.88889 -2.8888889 62 13 14.80392 -1.8039216 63 11 14.80392 -3.8039216 64 14 13.52381 0.4761905 65 15 14.80392 0.1960784 66 10 14.80392 -4.8039216 67 11 10.88889 0.1111111 68 12 14.80392 -2.8039216 69 15 14.80392 0.1960784 70 15 13.52381 1.4761905 71 14 14.80392 -0.8039216 72 16 13.52381 2.4761905 73 15 14.80392 0.1960784 74 15 14.80392 0.1960784 75 13 14.80392 -1.8039216 76 12 10.88889 1.1111111 77 17 14.80392 2.1960784 78 13 10.88889 2.1111111 79 15 14.80392 0.1960784 80 13 14.80392 -1.8039216 81 15 14.80392 0.1960784 82 16 14.80392 1.1960784 83 15 14.80392 0.1960784 84 16 14.80392 1.1960784 85 15 14.80392 0.1960784 86 14 14.80392 -0.8039216 87 15 14.80392 0.1960784 88 14 14.80392 -0.8039216 89 13 13.52381 -0.5238095 90 7 10.88889 -3.8888889 91 17 14.80392 2.1960784 92 13 13.52381 -0.5238095 93 15 14.80392 0.1960784 94 14 13.52381 0.4761905 95 13 14.80392 -1.8039216 96 16 14.80392 1.1960784 97 12 13.52381 -1.5238095 98 14 14.80392 -0.8039216 99 17 14.80392 2.1960784 100 15 14.80392 0.1960784 101 17 14.80392 2.1960784 102 12 13.52381 -1.5238095 103 16 14.80392 1.1960784 104 11 14.80392 -3.8039216 105 15 13.52381 1.4761905 106 9 10.88889 -1.8888889 107 16 14.80392 1.1960784 108 15 13.52381 1.4761905 109 10 13.52381 -3.5238095 110 10 10.88889 -0.8888889 111 15 13.52381 1.4761905 112 11 13.52381 -2.5238095 113 13 14.80392 -1.8039216 114 14 13.52381 0.4761905 115 18 14.80392 3.1960784 116 16 14.80392 1.1960784 117 14 13.52381 0.4761905 118 14 14.80392 -0.8039216 119 14 14.80392 -0.8039216 120 14 13.52381 0.4761905 121 12 13.52381 -1.5238095 122 14 13.52381 0.4761905 123 15 14.80392 0.1960784 124 15 14.80392 0.1960784 125 15 14.80392 0.1960784 126 13 14.80392 -1.8039216 127 17 14.80392 2.1960784 128 17 14.80392 2.1960784 129 19 14.80392 4.1960784 130 15 14.80392 0.1960784 131 13 14.80392 -1.8039216 132 9 10.88889 -1.8888889 133 15 14.80392 0.1960784 134 15 13.52381 1.4761905 135 15 14.80392 0.1960784 136 16 13.52381 2.4761905 137 11 10.88889 0.1111111 138 14 13.52381 0.4761905 139 11 13.52381 -2.5238095 140 15 14.80392 0.1960784 141 13 14.80392 -1.8039216 142 15 14.80392 0.1960784 143 16 13.52381 2.4761905 144 14 14.80392 -0.8039216 145 15 14.80392 0.1960784 146 16 14.80392 1.1960784 147 16 14.80392 1.1960784 148 11 14.80392 -3.8039216 149 12 14.80392 -2.8039216 150 9 10.88889 -1.8888889 151 16 14.80392 1.1960784 152 13 10.88889 2.1111111 153 16 14.80392 1.1960784 154 12 14.80392 -2.8039216 155 9 10.88889 -1.8888889 156 13 10.88889 2.1111111 157 13 13.52381 -0.5238095 158 14 13.52381 0.4761905 159 19 14.80392 4.1960784 160 13 14.80392 -1.8039216 161 12 10.88889 1.1111111 162 13 13.52381 -0.5238095 > if (par2 != 'none') { + print(cbind(as.factor(x[,par1]),predict(m))) + myt <- table(as.factor(x[,par1]),predict(m)) + print(myt) + } > postscript(file="/var/www/html/freestat/rcomp/tmp/487xa1293038902.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/www/html/freestat/rcomp/tmp/5t8vy1293038902.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/www/html/freestat/rcomp/tmp/6mhu11293038902.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/www/html/freestat/rcomp/tmp/77zb71293038902.tab") + } > > try(system("convert tmp/2m7y41293038902.ps tmp/2m7y41293038902.png",intern=TRUE)) character(0) > try(system("convert tmp/3m7y41293038902.ps tmp/3m7y41293038902.png",intern=TRUE)) character(0) > try(system("convert tmp/487xa1293038902.ps tmp/487xa1293038902.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.453 0.748 4.600