Free Statistics

of Irreproducible Research!

Author's title

Author*Unverified author*
R Software Modulerwasp_regression_trees.wasp
Title produced by softwareRecursive Partitioning (Regression Trees)
Date of computationThu, 03 Jun 2010 11:51:11 +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/Jun/03/t127556594366j0wfsyh0kcx36.htm/, Retrieved Sun, 05 May 2024 08:53:26 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=77356, Retrieved Sun, 05 May 2024 08:53:26 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywordsB11A,steven,coomans,regression tree,per maand,thesis,revised
Estimated Impact192
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
-     [Recursive Partitioning (Regression Trees)] [Regression tree,p...] [2010-05-26 09:57:53] [74be16979710d4c4e7c6647856088456]
-    D  [Recursive Partitioning (Regression Trees)] [B11A,steven,cooma...] [2010-05-31 09:40:29] [74be16979710d4c4e7c6647856088456]
-    D      [Recursive Partitioning (Regression Trees)] [B11A,steven,cooma...] [2010-06-03 11:51:11] [d41d8cd98f00b204e9800998ecf8427e] [Current]
Feedback Forum

Post a new message
Dataseries X:
62	NA	49,1485946234278	61,93727661	32
30	62	45,3349835319040	53,69907547	30
31	58,8	41,8176511556289	42,97961039	70
50	56,02	38,5909798541646	40,11452585	30
33	55,418	35,6520298034287	40,9963732	30
12	53,1762	32,9504078576450	37,85777961	10
20	49,05858	30,4539152863161	32,44046133	30
30	46,152722	28,1658962839276	29,7292962	30
21,5	44,5374498	26,0766501187039	28,9511509	38
23	42,23370482	24,156446356987	27,07351868	20
13,5	40,310334338	22,3980495637221	25,66908954	10
0,5	37,6293009042	20,7779239031914	23,07285439	11
12	33,91637081378	19,2763140211818	19,09395794	12
10	31,724733732402	17,9029571235767	17,34376879	10
70,5	29,5522603591618	16,6398256486149	15,69357484	 30
30	33,6470343232456	15,5438391587265	22,68102951	31
20,5	33,2823308909211	14,5275375931142	22,97988796	30
12	32,0040978018290	13,5952912424967	21,90195337	12
20	30,0036880216461	12,7363232603913	19,79755753	20
45	29,0033192194815	11,9577990661807	19,11379007	10
11,505	30,6029872975333	11,2759453783387	21,98924725	50
0	28,69318856778	10,6345631046696	19,80301639	10
10	28,69318856778	10,0354091488450	16,32602887	11
5,5	24,3853361009109	9,491781865029	14,72244369	1
27,5	22,6527364586255	8,98941596678817	12,71951926	31
0,5	23,1011419666157	8,55085675842196	14,0475627	1
7	20,994595040843	8,1309880805476	11,44289609	20
0	19,6813007736305	7,74915685785539	10,10225109	0
2,5	19,6813007736305	7,39159969411268	7,976306769	0
0	16,5008829011108	7,06270326550288	6,492577652	0 
0	16,5008829011108	6,75629871592574	4,867892606	0 
6,025	16,5008829011108	6,47193662930408	3,46884702	1 
1	13,2638773777770	6,21434038969776	3,100150102	0 
0	12,3268664380437	5,97297356764721	2,085216954	0 
0	12,3268664380437	5,74809890698749	1,072369242	0 
0	12,3268664380437	5,53896241148096	0,200095795	0 
0	12,3268664380437	5,34435520194198	-0,551118036	0 
2	12,3268664380437	5,16316210918967	-1,198072087	2 
0	8,77286013713574	4,99648594330416	-1,477684042	2 
6	8,77286013713574	4,84004626539840	-1,996046968	0 
20	8,09773184771271	4,70048199890951	-1,609782119	0 
0	8,82386207874147	4,58831288025937	0,665774885	0 
0	8,82386207874147	4,4728445018471	-0,150066663	0 
0	8,82386207874147	4,36461125530118	-0,852685768	0 
7	8,82386207874147	4,26306411947283	-1,457793951	5 
35	7,3149510902026	4,17515697240404	-1,007465392	0 
0	8,86359100991655	4,12606441076908	3,266180329	0 
0	8,86359100991655	4,06097419798148	2,089456367	0 
0	8,86359100991655	3,99910621856815	1,076037511	0 
1	8,86359100991655	3,94022356081926	0,203260318	0 




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time7 seconds
R Server'George Udny Yule' @ 72.249.76.132

\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 & 7 seconds \tabularnewline
R Server & 'George Udny Yule' @ 72.249.76.132 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=77356&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]7 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'George Udny Yule' @ 72.249.76.132[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=77356&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=77356&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 time7 seconds
R Server'George Udny Yule' @ 72.249.76.132







Model Performance
#Complexitysplitrelative errorCV errorCV S.D.
10.484011.0260.285
20.07710.5160.5990.17
30.02620.4390.5420.159
40.0130.4130.5540.159

\begin{tabular}{lllllllll}
\hline
Model Performance \tabularnewline
# & Complexity & split & relative error & CV error & CV S.D. \tabularnewline
1 & 0.484 & 0 & 1 & 1.026 & 0.285 \tabularnewline
2 & 0.077 & 1 & 0.516 & 0.599 & 0.17 \tabularnewline
3 & 0.026 & 2 & 0.439 & 0.542 & 0.159 \tabularnewline
4 & 0.01 & 3 & 0.413 & 0.554 & 0.159 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=77356&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.484[/C][C]0[/C][C]1[/C][C]1.026[/C][C]0.285[/C][/ROW]
[ROW][C]2[/C][C]0.077[/C][C]1[/C][C]0.516[/C][C]0.599[/C][C]0.17[/C][/ROW]
[ROW][C]3[/C][C]0.026[/C][C]2[/C][C]0.439[/C][C]0.542[/C][C]0.159[/C][/ROW]
[ROW][C]4[/C][C]0.01[/C][C]3[/C][C]0.413[/C][C]0.554[/C][C]0.159[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=77356&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=77356&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.484011.0260.285
20.07710.5160.5990.17
30.02620.4390.5420.159
40.0130.4130.5540.159



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')