Free Statistics

of Irreproducible Research!

Author's title

Author*The author of this computation has been verified*
R Software Modulerwasp_regression_trees.wasp
Title produced by softwareRecursive Partitioning (Regression Trees)
Date of computationMon, 27 Dec 2010 15:25:47 +0000
Cite this page as followsStatistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?v=date/2010/Dec/27/t1293463473w40dae3zcbuj5l2.htm/, Retrieved Mon, 06 May 2024 22:56:13 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=116025, Retrieved Mon, 06 May 2024 22:56:13 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact114
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
-       [Recursive Partitioning (Regression Trees)] [workshop 7 Recurs...] [2010-12-27 15:25:47] [462b8b87257ac3e5f611bbf1374c6e89] [Current]
Feedback Forum

Post a new message
Dataseries X:
13	13	14	13	3	2
12	12	8	13	5	1
15	10	12	16	6	0
12	9	7	12	6	3
10	10	10	11	5	3
12	12	7	12	3	1
15	13	16	18	8	3
9	12	11	11	4	1
12	12	14	14	4	4
11	6	6	9	4	0
11	5	16	14	6	3
11	12	11	12	6	2
15	11	16	11	5	4
7	14	12	12	4	3
11	14	7	13	6	1
11	12	13	11	4	1
10	12	11	12	6	2
14	11	15	16	6	3
10	11	7	9	4	1
6	7	9	11	4	1
11	9	7	13	2	2
15	11	14	15	7	3
11	11	15	10	5	4
12	12	7	11	4	2
14	12	15	13	6	1
15	11	17	16	6	2
9	11	15	15	7	2
13	8	14	14	5	4
13	9	14	14	6	2
16	12	8	14	4	3
13	10	8	8	4	3
12	10	14	13	7	3
14	12	14	15	7	4
11	8	8	13	4	2
9	12	11	11	4	2
16	11	16	15	6	4
12	12	10	15	6	3
10	7	8	9	5	4
13	11	14	13	6	2
16	11	16	16	7	5
14	12	13	13	6	3
15	9	5	11	3	1
5	15	8	12	3	1
8	11	10	12	4	1
11	11	8	12	6	2
16	11	13	14	7	3
17	11	15	14	5	9
9	15	6	8	4	0
9	11	12	13	5	0
13	12	16	16	6	2
10	12	5	13	6	2
6	9	15	11	6	3
12	12	12	14	5	1
8	12	8	13	4	2
14	13	13	13	5	0
12	11	14	13	5	5
11	9	12	12	4	2
16	9	16	16	6	4
8	11	10	15	2	3
15	11	15	15	8	0
7	12	8	12	3	0
16	12	16	14	6	4
14	9	19	12	6	1
16	11	14	15	6	1
9	9	6	12	5	4
14	12	13	13	5	2
11	12	15	12	6	4
13	12	7	12	5	1
15	12	13	13	6	4
5	14	4	5	2	2
15	11	14	13	5	5
13	12	13	13	5	4
11	11	11	14	5	4
11	6	14	17	6	4
12	10	12	13	6	4
12	12	15	13	6	3
12	13	14	12	5	3
12	8	13	13	5	3
14	12	8	14	4	2
6	12	6	11	2	1
7	12	7	12	4	1
14	6	13	12	6	5
14	11	13	16	6	4
10	10	11	12	5	2
13	12	5	12	3	3
12	13	12	12	6	2
9	11	8	10	4	2
12	7	11	15	5	2
16	11	14	15	8	2
10	11	9	12	4	3
14	11	10	16	6	2
10	11	13	15	6	3
16	12	16	16	7	4
15	10	16	13	6	3
12	11	11	12	5	3
10	12	8	11	4	0
8	7	4	13	6	1
8	13	7	10	3	2
11	8	14	15	5	2
13	12	11	13	6	3
16	11	17	16	7	4
16	12	15	15	7	4
14	14	17	18	6	1
11	10	5	13	3	2
4	10	4	10	2	2
14	13	10	16	8	3
9	10	11	13	3	3
14	11	15	15	8	3
8	10	10	14	3	1
8	7	9	15	4	1
11	10	12	14	5	1
12	8	15	13	7	1
11	12	7	13	6	0
14	12	13	15	6	1
15	12	12	16	7	3
16	11	14	14	6	3
16	12	14	14	6	0
11	12	8	16	6	2
14	12	15	14	6	5
14	11	12	12	4	2
12	12	12	13	4	3
14	11	16	12	5	3
8	11	9	12	4	5
13	13	15	14	6	4
16	12	15	14	6	4
12	12	6	14	5	0
16	12	14	16	8	3
12	12	15	13	6	0
11	8	10	14	5	2
4	8	6	4	4	0
16	12	14	16	8	6
15	11	12	13	6	3
10	12	8	16	4	1
13	13	11	15	6	6
15	12	13	14	6	2
12	12	9	13	4	1
14	11	15	14	6	3
7	12	13	12	3	1
19	12	15	15	6	2
12	10	14	14	5	4
12	11	16	13	4	1
13	12	14	14	6	2
15	12	14	16	4	0
8	10	10	6	4	5
12	12	10	13	4	2
10	13	4	13	6	1
8	12	8	14	5	1
10	15	15	15	6	4
15	11	16	14	6	3
16	12	12	15	8	0
13	11	12	13	7	3
16	12	15	16	7	3
9	11	9	12	4	0
14	10	12	15	6	2
14	11	14	12	6	5
12	11	11	14	2	2




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time3 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135

\begin{tabular}{lllllllll}
\hline
Summary of computational transaction \tabularnewline
Raw Input & view raw input (R code)  \tabularnewline
Raw Output & view raw output of R engine  \tabularnewline
Computing time & 3 seconds \tabularnewline
R Server & 'Gwilym Jenkins' @ 72.249.127.135 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=116025&T=0

[TABLE]
[ROW][C]Summary of computational transaction[/C][/ROW]
[ROW][C]Raw Input[/C][C]view raw input (R code) [/C][/ROW]
[ROW][C]Raw Output[/C][C]view raw output of R engine [/C][/ROW]
[ROW][C]Computing time[/C][C]3 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'Gwilym Jenkins' @ 72.249.127.135[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=116025&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=116025&T=0

As an alternative you can also use a QR Code:  

The GUIDs for individual cells are displayed in the table below:

Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time3 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135







Model Performance
#Complexitysplitrelative errorCV errorCV S.D.
10.326011.0120.11
20.05910.6740.7580.092
30.03920.6150.7290.088
40.02330.5770.7570.098
50.02340.5530.7680.099
60.01750.530.7740.095
70.01460.5130.7590.096
80.0170.4980.7580.098
90.0180.4880.7430.097

\begin{tabular}{lllllllll}
\hline
Model Performance \tabularnewline
# & Complexity & split & relative error & CV error & CV S.D. \tabularnewline
1 & 0.326 & 0 & 1 & 1.012 & 0.11 \tabularnewline
2 & 0.059 & 1 & 0.674 & 0.758 & 0.092 \tabularnewline
3 & 0.039 & 2 & 0.615 & 0.729 & 0.088 \tabularnewline
4 & 0.023 & 3 & 0.577 & 0.757 & 0.098 \tabularnewline
5 & 0.023 & 4 & 0.553 & 0.768 & 0.099 \tabularnewline
6 & 0.017 & 5 & 0.53 & 0.774 & 0.095 \tabularnewline
7 & 0.014 & 6 & 0.513 & 0.759 & 0.096 \tabularnewline
8 & 0.01 & 7 & 0.498 & 0.758 & 0.098 \tabularnewline
9 & 0.01 & 8 & 0.488 & 0.743 & 0.097 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=116025&T=1

[TABLE]
[ROW][C]Model Performance[/C][/ROW]
[ROW][C]#[/C][C]Complexity[/C][C]split[/C][C]relative error[/C][C]CV error[/C][C]CV S.D.[/C][/ROW]
[ROW][C]1[/C][C]0.326[/C][C]0[/C][C]1[/C][C]1.012[/C][C]0.11[/C][/ROW]
[ROW][C]2[/C][C]0.059[/C][C]1[/C][C]0.674[/C][C]0.758[/C][C]0.092[/C][/ROW]
[ROW][C]3[/C][C]0.039[/C][C]2[/C][C]0.615[/C][C]0.729[/C][C]0.088[/C][/ROW]
[ROW][C]4[/C][C]0.023[/C][C]3[/C][C]0.577[/C][C]0.757[/C][C]0.098[/C][/ROW]
[ROW][C]5[/C][C]0.023[/C][C]4[/C][C]0.553[/C][C]0.768[/C][C]0.099[/C][/ROW]
[ROW][C]6[/C][C]0.017[/C][C]5[/C][C]0.53[/C][C]0.774[/C][C]0.095[/C][/ROW]
[ROW][C]7[/C][C]0.014[/C][C]6[/C][C]0.513[/C][C]0.759[/C][C]0.096[/C][/ROW]
[ROW][C]8[/C][C]0.01[/C][C]7[/C][C]0.498[/C][C]0.758[/C][C]0.098[/C][/ROW]
[ROW][C]9[/C][C]0.01[/C][C]8[/C][C]0.488[/C][C]0.743[/C][C]0.097[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=116025&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=116025&T=1

As an alternative you can also use a QR Code:  

The GUIDs for individual cells are displayed in the table below:

Model Performance
#Complexitysplitrelative errorCV errorCV S.D.
10.326011.0120.11
20.05910.6740.7580.092
30.03920.6150.7290.088
40.02330.5770.7570.098
50.02340.5530.7680.099
60.01750.530.7740.095
70.01460.5130.7590.096
80.0170.4980.7580.098
90.0180.4880.7430.097



Parameters (Session):
par1 = 1 ; par2 = No ;
Parameters (R input):
par1 = 1 ; par2 = No ;
R code (references can be found in the software module):
library(rpart)
library(partykit)
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
if (par2 != 'No') {
mincp <- autoprune(m,method=par2)
print(mincp)
m <- prune(m,cp=mincp)
}
m$cptable
bitmap(file='test1.png')
plot(as.party(m),tp_args=list(id=FALSE))
dev.off()
bitmap(file='test2.png')
plotcp(m)
dev.off()
cbind(y=m$y,pred=predict(m),res=residuals(m))
myr <- residuals(m)
myp <- predict(m)
bitmap(file='test4.png')
op <- par(mfrow=c(2,2))
plot(myr,ylab='residuals')
plot(density(myr),main='Residual Kernel Density')
plot(myp,myr,xlab='predicted',ylab='residuals',main='Predicted vs Residuals')
plot(density(myp),main='Prediction Kernel Density')
par(op)
dev.off()
load(file='createtable')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Model Performance',6,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'#',header=TRUE)
a<-table.element(a,'Complexity',header=TRUE)
a<-table.element(a,'split',header=TRUE)
a<-table.element(a,'relative error',header=TRUE)
a<-table.element(a,'CV error',header=TRUE)
a<-table.element(a,'CV S.D.',header=TRUE)
a<-table.row.end(a)
for (i in 1:length(m$cptable[,1])) {
a<-table.row.start(a)
a<-table.element(a,i,header=TRUE)
a<-table.element(a,round(m$cptable[i,'CP'],3))
a<-table.element(a,m$cptable[i,'nsplit'])
a<-table.element(a,round(m$cptable[i,'rel error'],3))
a<-table.element(a,round(m$cptable[i,'xerror'],3))
a<-table.element(a,round(m$cptable[i,'xstd'],3))
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable.tab')