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(41 + ,NA + ,33.3763873532711 + ,40.9569135138413 + ,44 + ,31.66666667 + ,41 + ,29.6246335440404 + ,36.7345324696379 + ,23.33333 + ,23.83333333 + ,40.066666667 + ,26.2043027371594 + ,31.758263136203 + ,32.66667 + ,12.33333333 + ,38.4433333333 + ,23.0857558185012 + ,22.6335077092444 + ,13.5 + ,30.83333333 + ,35.83233333297 + ,20.2411085776598 + ,17.9625206650331 + ,7.333333 + ,20.83333333 + ,35.332433332673 + ,17.6509908453781 + ,18.3414307638322 + ,24.16667 + ,25.50166667 + ,33.8825233324057 + ,15.2895321468614 + ,23.370763577192 + ,26.66667 + ,5.166666667 + ,33.0444376661651 + ,13.1385354672161 + ,17.3223286042793 + ,7.066667 + ,11.66666667 + ,30.2566605662486 + ,11.1752719285065 + ,12.4854037188620 + ,17.06667 + ,0.833333333 + ,28.3976611766238 + ,9.3864204889596 + ,4.48602028418904 + ,0 + ,2.341666667 + ,25.6412283922614 + ,7.75405731874686 + ,2.83130750565654 + ,0.333333 + ,0 + ,23.3112722197352 + ,6.2657718954017 + ,0 + ,0 + ,0.666666667 + ,23.3112722197352 + ,4.90837511570664 + ,0 + ,1 + ,8.666666667 + ,19.1334651495107 + ,3.6707589378187 + ,1.07220255011467 + ,0 + ,2.333333333 + ,18.1732084079959 + ,2.54391483550720 + ,6.63228634277377 + ,1.666667 + ,11.66666667 + ,16.7079100661832 + ,1.51620952168044 + ,9.5419036881876 + ,0 + ,0.275 + ,16.2380393050513 + ,0.581334283101121 + ,0 + ,0) + ,dim=c(5 + ,17) + ,dimnames=list(c('Actuals' + ,'Croston' + ,'ETS' + ,'Arima' + ,'Kaneka') + ,1:17)) > y <- array(NA,dim=c(5,17),dimnames=list(c('Actuals','Croston','ETS','Arima','Kaneka'),1:17)) > for (i in 1:dim(x)[1]) + { + for (j in 1:dim(x)[2]) + { + y[i,j] <- as.numeric(x[i,j]) + } + } > par2 = 'No' > 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(rpart) > library(partykit) Loading required package: grid Loading required package: mvtnorm > par1 <- as.numeric(par1) > autoprune <- function ( tree, method='Minimum CV'){ + xerr <- tree$cptable[,'xerror'] + cpmin.id <- which.min(xerr) + if (method == 'Minimum CV Error plus 1 SD'){ + xstd <- tree$cptable[,'xstd'] + errt <- xerr[cpmin.id] + xstd[cpmin.id] + cpSE1.min <- which.min( errt < xerr ) + mycp <- (tree$cptable[,'CP'])[cpSE1.min] + } + if (method == 'Minimum CV') { + mycp <- (tree$cptable[,'CP'])[cpmin.id] + } + return (mycp) + } > conf.multi.mat <- function(true, new) + { + if ( all( is.na(match( levels(true),levels(new) ) )) ) + stop ( 'conflict of vector levels') + multi.t <- list() + for (mylev in levels(true) ) { + true.tmp <- true + new.tmp <- new + left.lev <- levels (true.tmp)[- match(mylev,levels(true) ) ] + levels(true.tmp) <- list ( mylev = mylev, all = left.lev ) + levels(new.tmp) <- list ( mylev = mylev, all = left.lev ) + curr.t <- conf.mat ( true.tmp , new.tmp ) + multi.t[[mylev]] <- curr.t + multi.t[[mylev]]$precision <- + round( curr.t$conf[1,1] / sum( curr.t$conf[1,] ), 2 ) + } + return (multi.t) + } > x <- t(y) > k <- length(x[1,]) > n <- length(x[,1]) > x1 <- cbind(x[,par1], x[,1:k!=par1]) > mycolnames <- c(colnames(x)[par1], colnames(x)[1:k!=par1]) > colnames(x1) <- mycolnames #colnames(x)[par1] > m <- rpart(as.data.frame(x1)) > par2 [1] "No" > if (par2 != 'No') { + mincp <- autoprune(m,method=par2) + print(mincp) + m <- prune(m,cp=mincp) + } > m$cptable CP nsplit rel error 1 0.01 0 1 > postscript(file="/var/www/html/rcomp/tmp/1cvms1274874781.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(as.party(m),tp_args=list(id=FALSE)) Error: length(i) == 1 & is.numeric(i) is not TRUE Execution halted