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. > par9 = 'Learning Activities' > par8 = 'ATTLES all' > par7 = 'all' > par6 = 'bachelor' > par5 = 'all' > par4 = 'no' > par3 = '3' > par2 = 'none' > par1 = '0' > par9 <- 'Learning Activities' > par8 <- 'ATTLES all' > par7 <- 'all' > par6 <- 'bachelor' > par5 <- 'all' > par4 <- 'no' > par3 <- '3' > par2 <- 'none' > par1 <- '0' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., 2012, Recursive Partitioning (Regression Trees) in Information Management (v1.0.8) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_regression_trees.wasp/ > #Source of accompanying publication: > # > 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 <- as.data.frame(read.table(file='http://www.wessa.net/download/utaut.csv',sep=',',header=T)) > x$U25 <- 6-x$U25 > if(par5 == 'female') x <- x[x$Gender==0,] > if(par5 == 'male') x <- x[x$Gender==1,] > if(par6 == 'prep') x <- x[x$Pop==1,] > if(par6 == 'bachelor') x <- x[x$Pop==0,] > if(par7 != 'all') { + x <- x[x$Year==as.numeric(par7),] + } > cAc <- with(x,cbind( A1, A2, A3, A4, A5, A6, A7, A8, A9,A10)) > cAs <- with(x,cbind(A11,A12,A13,A14,A15,A16,A17,A18,A19,A20)) > cA <- cbind(cAc,cAs) > cCa <- with(x,cbind(C1,C3,C5,C7, C9,C11,C13,C15,C17,C19,C21,C23,C25,C27,C29,C31,C33,C35,C37,C39,C41,C43,C45,C47)) > cCp <- with(x,cbind(C2,C4,C6,C8,C10,C12,C14,C16,C18,C20,C22,C24,C26,C28,C30,C32,C34,C36,C38,C40,C42,C44,C46,C48)) > cC <- cbind(cCa,cCp) > cU <- with(x,cbind(U1,U2,U3,U4,U5,U6,U7,U8,U9,U10,U11,U12,U13,U14,U15,U16,U17,U18,U19,U20,U21,U22,U23,U24,U25,U26,U27,U28,U29,U30,U31,U32,U33)) > cE <- with(x,cbind(BC,NNZFG,MRT,AFL,LPM,LPC,W,WPA)) > cX <- with(x,cbind(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13,X14,X15,X16,X17,X18)) > if (par8=='ATTLES connected') x <- cAc > if (par8=='ATTLES separate') x <- cAs > if (par8=='ATTLES all') x <- cA > if (par8=='COLLES actuals') x <- cCa > if (par8=='COLLES preferred') x <- cCp > if (par8=='COLLES all') x <- cC > if (par8=='CSUQ') x <- cU > if (par8=='Learning Activities') x <- cE > if (par8=='Exam Items') x <- cX > if (par9=='ATTLES connected') y <- cAc > if (par9=='ATTLES separate') y <- cAs > if (par9=='ATTLES all') y <- cA > if (par9=='COLLES actuals') y <- cCa > if (par9=='COLLES preferred') y <- cCp > if (par9=='COLLES all') y <- cC > if (par9=='CSUQ') y <- cU > if (par9=='Learning Activities') y <- cE > if (par9=='Exam Items') y <- cX > if (par1==0) { + nr <- length(y[,1]) + nc <- length(y[1,]) + mysum <- array(0,dim=nr) + for(jjj in 1:nr) { + for(iii in 1:nc) { + mysum[jjj] = mysum[jjj] + y[jjj,iii] + } + } + y <- mysum + } else { + y <- y[,par1] + } > nx <- cbind(y,x) > colnames(nx) <- c('endo',colnames(x)) > x <- nx > par1=1 > ncol <- length(x[1,]) > for (jjj in 1:ncol) { + x <- x[!is.na(x[,jjj]),] + } > x <- as.data.frame(x) > k <- length(x[1,]) > n <- length(x[,1]) > colnames(x)[par1] [1] "endo" > x[,par1] [1] 6704.730 7365.200 9735.730 5123.100 11423.860 8446.730 5970.440 [8] 10441.130 8115.670 7707.260 7432.140 8028.263 8106.133 10489.060 [15] 7122.570 6550.880 12247.670 6713.040 7519.270 5721.450 7941.540 [22] 6734.700 9659.920 10472.940 9370.703 8282.810 8756.093 7171.570 [29] 6905.900 6411.900 12624.320 8866.343 4046.330 6063.610 7018.630 [36] 4520.670 8171.440 5517.950 9701.810 7045.030 9810.060 7446.070 [43] 7954.650 6300.700 7142.280 7138.500 9202.320 5867.790 4481.130 [50] 3540.170 13707.573 9927.510 12068.390 8741.737 6796.870 9300.490 [57] 7095.660 9186.730 8958.790 5701.560 6940.110 8452.860 13315.123 [64] 6301.370 5614.490 10239.780 7072.100 5381.770 10010.060 4844.830 [71] 9678.670 7982.600 10139.580 9533.680 9268.450 5769.620 5108.870 [78] 8956.813 8350.200 13201.790 5350.280 9521.070 6015.800 7660.520 [85] 7290.230 9404.760 9303.930 11055.210 10406.840 6996.910 9820.990 [92] 6184.580 7473.557 6982.560 6696.290 8569.547 11914.480 6086.440 [99] 9784.520 7368.020 8711.650 5384.010 11344.700 7137.820 8736.020 [106] 7297.280 12375.840 7294.080 9876.430 8047.740 9801.260 13022.310 [113] 11924.240 9815.300 8057.830 6213.800 9314.640 11078.190 8829.977 [120] 9024.670 6959.310 9545.510 8963.523 4868.320 9288.220 8351.320 [127] 8579.560 8439.600 6591.210 6619.700 8972.963 6410.880 8098.200 [134] 7377.957 7727.837 6317.420 8735.850 13327.653 17394.270 14159.910 [141] 8975.820 7360.020 9096.530 13043.260 17338.590 8228.390 7967.820 [148] 11613.870 11392.940 14565.620 6399.880 7894.850 8315.490 15474.530 [155] 15740.780 8821.300 9649.980 12950.090 11025.410 9762.970 10007.320 [162] 14456.690 312.320 8000.230 12871.940 12670.050 10142.820 10443.820 [169] 10070.770 12364.370 7685.110 16068.910 11407.430 4260.960 4263.650 [176] 8652.820 9808.160 6106.860 9756.570 17509.510 7451.380 8409.370 [183] 7559.880 9480.000 9447.650 10012.880 14942.560 5679.410 10118.750 [190] 9826.740 11758.490 9503.110 3928.270 9389.230 20683.240 6783.190 [197] 2078.300 8665.670 14167.730 11099.220 12040.950 7242.240 19323.430 [204] 14235.200 5643.240 3626.590 14639.780 906.040 4100.630 14625.770 [211] 6894.780 12805.950 7642.430 8562.890 8514.390 19226.290 5641.340 [218] 8592.500 13625.030 8005.460 15285.880 10996.040 8228.670 7955.020 [225] 7690.870 8254.530 13953.020 13104.850 5915.810 5504.230 9730.570 [232] 12431.050 10350.380 8117.730 7404.660 > 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]) 312.32 906.04 2078.3 3540.17 1 1 1 1 3626.59 3928.27 4046.33 4100.63 1 1 1 1 4260.96 4263.65 4481.13 4520.67 1 1 1 1 4844.83 4868.32 5108.87 5123.1 1 1 1 1 5350.28 5381.77 5384.01 5504.23 1 1 1 1 5517.95 5614.49 5641.34 5643.24 1 1 1 1 5679.41 5701.56 5721.45 5769.62 1 1 1 1 5867.79 5915.81 5970.44 6015.8 1 1 1 1 6063.61 6086.44 6106.86 6184.58 1 1 1 1 6213.8 6300.7 6301.37 6317.42 1 1 1 1 6399.88 6410.88 6411.9 6550.88 1 1 1 1 6591.21 6619.7 6696.29 6704.73 1 1 1 1 6713.04 6734.7 6783.19 6796.87 1 1 1 1 6894.78 6905.9 6940.11 6959.31 1 1 1 1 6982.56 6996.91 7018.63 7045.03 1 1 1 1 7072.1 7095.66 7122.57 7137.82 1 1 1 1 7138.5 7142.28 7171.57 7242.24 1 1 1 1 7290.23 7294.08 7297.28 7360.02 1 1 1 1 7365.2 7368.02 7377.9566666667 7404.66 1 1 1 1 7432.14 7446.07 7451.38 7473.5566666667 1 1 1 1 7519.27 7559.88 7642.43 7660.52 1 1 1 1 7685.11 7690.87 7707.26 7727.8366666667 1 1 1 1 7894.85 7941.54 7954.65 7955.02 1 1 1 1 7967.82 7982.6 8000.23 8005.46 1 1 1 1 8028.2633333333 8047.74 8057.83 8098.2 1 1 1 1 8106.1333333333 8115.67 8117.73 8171.44 1 1 1 1 8228.39 8228.67 8254.53 8282.81 1 1 1 1 8315.49 8350.2 8351.32 8409.37 1 1 1 1 8439.6 8446.73 8452.86 8514.39 1 1 1 1 8562.89 8569.5466666667 8579.56 8592.5 1 1 1 1 8652.82 8665.67 8711.65 8735.85 1 1 1 1 8736.02 8741.7366666667 8756.0933333333 8821.3 1 1 1 1 8829.9766666667 8866.3433333333 8956.8133333333 8958.79 1 1 1 1 8963.5233333333 8972.9633333333 8975.82 9024.67 1 1 1 1 9096.53 9186.73 9202.32 9268.45 1 1 1 1 9288.22 9300.49 9303.93 9314.64 1 1 1 1 9370.7033333333 9389.23 9404.76 9447.65 1 1 1 1 9480 9503.11 9521.07 9533.68 1 1 1 1 9545.51 9649.98 9659.92 9678.67 1 1 1 1 9701.81 9730.57 9735.73 9756.57 1 1 1 1 9762.97 9784.52 9801.26 9808.16 1 1 1 1 9810.06 9815.3 9820.99 9826.74 1 1 1 1 9876.43 9927.51 10007.32 10010.06 1 1 1 1 10012.88 10070.77 10118.75 10139.58 1 1 1 1 10142.82 10239.78 10350.38 10406.84 1 1 1 1 10441.13 10443.82 10472.94 10489.06 1 1 1 1 10996.04 11025.41 11055.21 11078.19 1 1 1 1 11099.22 11344.7 11392.94 11407.43 1 1 1 1 11423.86 11613.87 11758.49 11914.48 1 1 1 1 11924.24 12040.95 12068.39 12247.67 1 1 1 1 12364.37 12375.84 12431.05 12624.32 1 1 1 1 12670.05 12805.95 12871.94 12950.09 1 1 1 1 13022.31 13043.26 13104.85 13201.79 1 1 1 1 13315.1233333333 13327.6533333333 13625.03 13707.5733333333 1 1 1 1 13953.02 14159.91 14167.73 14235.2 1 1 1 1 14456.69 14565.62 14625.77 14639.78 1 1 1 1 14942.56 15285.88 15474.53 15740.78 1 1 1 1 16068.91 17338.59 17394.27 17509.51 1 1 1 1 19226.29 19323.43 20683.24 1 1 1 > colnames(x) [1] "endo" "A1" "A2" "A3" "A4" "A5" "A6" "A7" "A8" "A9" [11] "A10" "A11" "A12" "A13" "A14" "A15" "A16" "A17" "A18" "A19" [21] "A20" > colnames(x)[par1] [1] "endo" > x[,par1] [1] 6704.730 7365.200 9735.730 5123.100 11423.860 8446.730 5970.440 [8] 10441.130 8115.670 7707.260 7432.140 8028.263 8106.133 10489.060 [15] 7122.570 6550.880 12247.670 6713.040 7519.270 5721.450 7941.540 [22] 6734.700 9659.920 10472.940 9370.703 8282.810 8756.093 7171.570 [29] 6905.900 6411.900 12624.320 8866.343 4046.330 6063.610 7018.630 [36] 4520.670 8171.440 5517.950 9701.810 7045.030 9810.060 7446.070 [43] 7954.650 6300.700 7142.280 7138.500 9202.320 5867.790 4481.130 [50] 3540.170 13707.573 9927.510 12068.390 8741.737 6796.870 9300.490 [57] 7095.660 9186.730 8958.790 5701.560 6940.110 8452.860 13315.123 [64] 6301.370 5614.490 10239.780 7072.100 5381.770 10010.060 4844.830 [71] 9678.670 7982.600 10139.580 9533.680 9268.450 5769.620 5108.870 [78] 8956.813 8350.200 13201.790 5350.280 9521.070 6015.800 7660.520 [85] 7290.230 9404.760 9303.930 11055.210 10406.840 6996.910 9820.990 [92] 6184.580 7473.557 6982.560 6696.290 8569.547 11914.480 6086.440 [99] 9784.520 7368.020 8711.650 5384.010 11344.700 7137.820 8736.020 [106] 7297.280 12375.840 7294.080 9876.430 8047.740 9801.260 13022.310 [113] 11924.240 9815.300 8057.830 6213.800 9314.640 11078.190 8829.977 [120] 9024.670 6959.310 9545.510 8963.523 4868.320 9288.220 8351.320 [127] 8579.560 8439.600 6591.210 6619.700 8972.963 6410.880 8098.200 [134] 7377.957 7727.837 6317.420 8735.850 13327.653 17394.270 14159.910 [141] 8975.820 7360.020 9096.530 13043.260 17338.590 8228.390 7967.820 [148] 11613.870 11392.940 14565.620 6399.880 7894.850 8315.490 15474.530 [155] 15740.780 8821.300 9649.980 12950.090 11025.410 9762.970 10007.320 [162] 14456.690 312.320 8000.230 12871.940 12670.050 10142.820 10443.820 [169] 10070.770 12364.370 7685.110 16068.910 11407.430 4260.960 4263.650 [176] 8652.820 9808.160 6106.860 9756.570 17509.510 7451.380 8409.370 [183] 7559.880 9480.000 9447.650 10012.880 14942.560 5679.410 10118.750 [190] 9826.740 11758.490 9503.110 3928.270 9389.230 20683.240 6783.190 [197] 2078.300 8665.670 14167.730 11099.220 12040.950 7242.240 19323.430 [204] 14235.200 5643.240 3626.590 14639.780 906.040 4100.630 14625.770 [211] 6894.780 12805.950 7642.430 8562.890 8514.390 19226.290 5641.340 [218] 8592.500 13625.030 8005.460 15285.880 10996.040 8228.670 7955.020 [225] 7690.870 8254.530 13953.020 13104.850 5915.810 5504.230 9730.570 [232] 12431.050 10350.380 8117.730 7404.660 > 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/1d5271335803641.tab") + } + } > m Conditional inference tree with 2 terminal nodes Response: endo Inputs: A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20 Number of observations: 235 1) A18 <= 2; criterion = 0.953, statistic = 9.225 2)* weights = 40 1) A18 > 2 3)* weights = 195 > postscript(file="/var/wessaorg/rcomp/tmp/2a2b31335803641.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/3crwx1335803641.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 6704.730 9279.117 -2574.387385 2 7365.200 9279.117 -1913.917385 3 9735.730 9279.117 456.612615 4 5123.100 9279.117 -4156.017385 5 11423.860 7538.442 3885.417833 6 8446.730 9279.117 -832.387385 7 5970.440 9279.117 -3308.677385 8 10441.130 9279.117 1162.012615 9 8115.670 9279.117 -1163.447385 10 7707.260 7538.442 168.817833 11 7432.140 9279.117 -1846.977385 12 8028.263 9279.117 -1250.854051 13 8106.133 7538.442 567.691167 14 10489.060 9279.117 1209.942615 15 7122.570 9279.117 -2156.547385 16 6550.880 7538.442 -987.562167 17 12247.670 9279.117 2968.552615 18 6713.040 9279.117 -2566.077385 19 7519.270 9279.117 -1759.847385 20 5721.450 9279.117 -3557.667385 21 7941.540 9279.117 -1337.577385 22 6734.700 7538.442 -803.742167 23 9659.920 7538.442 2121.477833 24 10472.940 9279.117 1193.822615 25 9370.703 9279.117 91.585949 26 8282.810 9279.117 -996.307385 27 8756.093 9279.117 -523.024051 28 7171.570 7538.442 -366.872167 29 6905.900 7538.442 -632.542167 30 6411.900 7538.442 -1126.542167 31 12624.320 9279.117 3345.202615 32 8866.343 9279.117 -412.774051 33 4046.330 7538.442 -3492.112167 34 6063.610 7538.442 -1474.832167 35 7018.630 9279.117 -2260.487385 36 4520.670 9279.117 -4758.447385 37 8171.440 9279.117 -1107.677385 38 5517.950 7538.442 -2020.492167 39 9701.810 9279.117 422.692615 40 7045.030 7538.442 -493.412167 41 9810.060 9279.117 530.942615 42 7446.070 9279.117 -1833.047385 43 7954.650 9279.117 -1324.467385 44 6300.700 9279.117 -2978.417385 45 7142.280 9279.117 -2136.837385 46 7138.500 9279.117 -2140.617385 47 9202.320 9279.117 -76.797385 48 5867.790 9279.117 -3411.327385 49 4481.130 9279.117 -4797.987385 50 3540.170 7538.442 -3998.272167 51 13707.573 9279.117 4428.455949 52 9927.510 9279.117 648.392615 53 12068.390 9279.117 2789.272615 54 8741.737 9279.117 -537.380718 55 6796.870 9279.117 -2482.247385 56 9300.490 9279.117 21.372615 57 7095.660 9279.117 -2183.457385 58 9186.730 9279.117 -92.387385 59 8958.790 7538.442 1420.347833 60 5701.560 9279.117 -3577.557385 61 6940.110 7538.442 -598.332167 62 8452.860 9279.117 -826.257385 63 13315.123 9279.117 4036.005949 64 6301.370 9279.117 -2977.747385 65 5614.490 9279.117 -3664.627385 66 10239.780 9279.117 960.662615 67 7072.100 9279.117 -2207.017385 68 5381.770 9279.117 -3897.347385 69 10010.060 9279.117 730.942615 70 4844.830 9279.117 -4434.287385 71 9678.670 9279.117 399.552615 72 7982.600 7538.442 444.157833 73 10139.580 9279.117 860.462615 74 9533.680 9279.117 254.562615 75 9268.450 9279.117 -10.667385 76 5769.620 9279.117 -3509.497385 77 5108.870 9279.117 -4170.247385 78 8956.813 9279.117 -322.304051 79 8350.200 9279.117 -928.917385 80 13201.790 9279.117 3922.672615 81 5350.280 9279.117 -3928.837385 82 9521.070 9279.117 241.952615 83 6015.800 9279.117 -3263.317385 84 7660.520 9279.117 -1618.597385 85 7290.230 7538.442 -248.212167 86 9404.760 7538.442 1866.317833 87 9303.930 9279.117 24.812615 88 11055.210 9279.117 1776.092615 89 10406.840 9279.117 1127.722615 90 6996.910 9279.117 -2282.207385 91 9820.990 9279.117 541.872615 92 6184.580 7538.442 -1353.862167 93 7473.557 7538.442 -64.885500 94 6982.560 9279.117 -2296.557385 95 6696.290 7538.442 -842.152167 96 8569.547 9279.117 -709.570718 97 11914.480 9279.117 2635.362615 98 6086.440 7538.442 -1452.002167 99 9784.520 9279.117 505.402615 100 7368.020 7538.442 -170.422167 101 8711.650 9279.117 -567.467385 102 5384.010 9279.117 -3895.107385 103 11344.700 9279.117 2065.582615 104 7137.820 9279.117 -2141.297385 105 8736.020 7538.442 1197.577833 106 7297.280 9279.117 -1981.837385 107 12375.840 9279.117 3096.722615 108 7294.080 9279.117 -1985.037385 109 9876.430 9279.117 597.312615 110 8047.740 9279.117 -1231.377385 111 9801.260 9279.117 522.142615 112 13022.310 9279.117 3743.192615 113 11924.240 9279.117 2645.122615 114 9815.300 9279.117 536.182615 115 8057.830 7538.442 519.387833 116 6213.800 9279.117 -3065.317385 117 9314.640 9279.117 35.522615 118 11078.190 9279.117 1799.072615 119 8829.977 7538.442 1291.534500 120 9024.670 9279.117 -254.447385 121 6959.310 9279.117 -2319.807385 122 9545.510 9279.117 266.392615 123 8963.523 9279.117 -315.594051 124 4868.320 9279.117 -4410.797385 125 9288.220 9279.117 9.102615 126 8351.320 9279.117 -927.797385 127 8579.560 9279.117 -699.557385 128 8439.600 9279.117 -839.517385 129 6591.210 9279.117 -2687.907385 130 6619.700 9279.117 -2659.417385 131 8972.963 9279.117 -306.154051 132 6410.880 7538.442 -1127.562167 133 8098.200 9279.117 -1180.917385 134 7377.957 9279.117 -1901.160718 135 7727.837 9279.117 -1551.280718 136 6317.420 9279.117 -2961.697385 137 8735.850 9279.117 -543.267385 138 13327.653 9279.117 4048.535949 139 17394.270 7538.442 9855.827833 140 14159.910 9279.117 4880.792615 141 8975.820 9279.117 -303.297385 142 7360.020 9279.117 -1919.097385 143 9096.530 7538.442 1558.087833 144 13043.260 9279.117 3764.142615 145 17338.590 9279.117 8059.472615 146 8228.390 9279.117 -1050.727385 147 7967.820 9279.117 -1311.297385 148 11613.870 9279.117 2334.752615 149 11392.940 9279.117 2113.822615 150 14565.620 9279.117 5286.502615 151 6399.880 7538.442 -1138.562167 152 7894.850 9279.117 -1384.267385 153 8315.490 9279.117 -963.627385 154 15474.530 9279.117 6195.412615 155 15740.780 9279.117 6461.662615 156 8821.300 9279.117 -457.817385 157 9649.980 9279.117 370.862615 158 12950.090 9279.117 3670.972615 159 11025.410 9279.117 1746.292615 160 9762.970 9279.117 483.852615 161 10007.320 7538.442 2468.877833 162 14456.690 9279.117 5177.572615 163 312.320 9279.117 -8966.797385 164 8000.230 9279.117 -1278.887385 165 12871.940 9279.117 3592.822615 166 12670.050 9279.117 3390.932615 167 10142.820 9279.117 863.702615 168 10443.820 9279.117 1164.702615 169 10070.770 9279.117 791.652615 170 12364.370 9279.117 3085.252615 171 7685.110 9279.117 -1594.007385 172 16068.910 9279.117 6789.792615 173 11407.430 9279.117 2128.312615 174 4260.960 7538.442 -3277.482167 175 4263.650 9279.117 -5015.467385 176 8652.820 9279.117 -626.297385 177 9808.160 9279.117 529.042615 178 6106.860 9279.117 -3172.257385 179 9756.570 9279.117 477.452615 180 17509.510 9279.117 8230.392615 181 7451.380 9279.117 -1827.737385 182 8409.370 9279.117 -869.747385 183 7559.880 9279.117 -1719.237385 184 9480.000 9279.117 200.882615 185 9447.650 9279.117 168.532615 186 10012.880 7538.442 2474.437833 187 14942.560 9279.117 5663.442615 188 5679.410 7538.442 -1859.032167 189 10118.750 9279.117 839.632615 190 9826.740 9279.117 547.622615 191 11758.490 9279.117 2479.372615 192 9503.110 9279.117 223.992615 193 3928.270 9279.117 -5350.847385 194 9389.230 9279.117 110.112615 195 20683.240 9279.117 11404.122615 196 6783.190 7538.442 -755.252167 197 2078.300 7538.442 -5460.142167 198 8665.670 9279.117 -613.447385 199 14167.730 9279.117 4888.612615 200 11099.220 9279.117 1820.102615 201 12040.950 7538.442 4502.507833 202 7242.240 9279.117 -2036.877385 203 19323.430 9279.117 10044.312615 204 14235.200 9279.117 4956.082615 205 5643.240 9279.117 -3635.877385 206 3626.590 9279.117 -5652.527385 207 14639.780 9279.117 5360.662615 208 906.040 9279.117 -8373.077385 209 4100.630 9279.117 -5178.487385 210 14625.770 9279.117 5346.652615 211 6894.780 9279.117 -2384.337385 212 12805.950 9279.117 3526.832615 213 7642.430 9279.117 -1636.687385 214 8562.890 7538.442 1024.447833 215 8514.390 9279.117 -764.727385 216 19226.290 9279.117 9947.172615 217 5641.340 9279.117 -3637.777385 218 8592.500 9279.117 -686.617385 219 13625.030 9279.117 4345.912615 220 8005.460 9279.117 -1273.657385 221 15285.880 9279.117 6006.762615 222 10996.040 9279.117 1716.922615 223 8228.670 9279.117 -1050.447385 224 7955.020 9279.117 -1324.097385 225 7690.870 9279.117 -1588.247385 226 8254.530 9279.117 -1024.587385 227 13953.020 9279.117 4673.902615 228 13104.850 9279.117 3825.732615 229 5915.810 7538.442 -1622.632167 230 5504.230 9279.117 -3774.887385 231 9730.570 9279.117 451.452615 232 12431.050 9279.117 3151.932615 233 10350.380 9279.117 1071.262615 234 8117.730 9279.117 -1161.387385 235 7404.660 9279.117 -1874.457385 > 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/4lt7d1335803641.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/5mwxa1335803641.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/6p54q1335803641.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/75n3w1335803641.tab") + } > > try(system("convert tmp/2a2b31335803641.ps tmp/2a2b31335803641.png",intern=TRUE)) character(0) > try(system("convert tmp/3crwx1335803641.ps tmp/3crwx1335803641.png",intern=TRUE)) character(0) > try(system("convert tmp/4lt7d1335803641.ps tmp/4lt7d1335803641.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.627 0.296 4.920