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 computationWed, 26 May 2010 09:57:53 +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/May/26/t12748683050kz5p8m1bjkr6jf.htm/, Retrieved Fri, 03 May 2024 11:44:16 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=76441, Retrieved Fri, 03 May 2024 11:44:16 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywordsRegression tree,per,maand,B28A,steven,coomans,thesis
Estimated Impact181
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] [d41d8cd98f00b204e9800998ecf8427e] [Current]
-    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] [74be16979710d4c4e7c6647856088456]
Feedback Forum

Post a new message
Dataseries X:
266.25	NA	266.311321524294	251.27004	328
235.25	266.25	235.417067752269	251.27004	346
323.775	263.15	323.615181804147	251.27004	352
305.25	269.2125	305.168540483468	251.27004	353
383.527	272.81625	383.175856621936	251.27004	382
515.25	283.887325	514.478001121786	251.27004	402
496.15	307.0235925	495.530485498141	251.27004	479
115.25	325.93623325	115.889317709444	251.27004	391
170.5	304.867609925	170.941626674590	251.27004	169
154.25	291.4308489325	154.728866537332	251.27004	129
170	277.71276403925	170.405904769100	251.27004	322
534.05	266.941487635325	533.12955044254	251.27004	456
193.75	293.652338871793	194.095120183447	251.27004	289
564.5	283.662104984613	563.545138664681	251.27004	431
346	311.745894486152	345.876293463356	251.27004	NA
308.25	315.171305037537	308.257418801685	251.27004	280
437.05	314.479174533783	436.641950834438	251.27004	403
410.275	326.736257080405	409.989624466476	251.27004	478
149.75	335.090131372364	150.289953421438	251.27004	243
154.75	316.556118235128	155.256078086846	251.27004	199
240.1	300.375506411615	240.305758401530	251.27004	246
127.525	294.347955770454	128.097039005303	251.27004	223
222.25	277.665660193408	222.473306779830	251.27004	223
85.525	272.124094174068	86.2214108124829	251.27004	101
427.75	253.464184756661	427.154471037843	251.27004	442
63.5	270.892766280995	64.2725456009076	251.27004	75
118.3	250.153489652895	118.852239647829	251.27004	301
99.5	236.968140687606	100.108382885394	251.27004	145
182.25	223.221326618845	182.501059010644	251.27004	274
401	219.124193956961	400.322893463908	251.27004	284 
119.5	237.311774561265	120.022652560074	251.27004	276 
450.25	225.530597105138	449.383742888922	251.27004	555 
147.5	248.002537394624	147.923303679596	251.27004	116 
237	237.952283655162	237.045320771771	251.27004	222 
80.025	237.857055289646	80.7016272696347	251.27004	110 
10.5	222.073849760681	11.4554792842250	251.27004	25 
176.75	200.916464784613	176.947324415927	251.27004	105 
234	198.499818306152	233.922575170563	251.27004	236 
282.5	202.049836475537	282.206216960764	251.27004	261 
320	210.094852827983	319.563768371117	251.27004	92 
167.5	221.085367545185	167.770320599499	251.27004	128 
163.25	215.726830790666	163.525233477721	251.27004	223 
238.15	210.479147711600	238.072110692052	251.27004	108 
325.125	213.246232940440	324.661368009176	251.27004	417 
126.3	224.434109646396	126.749158639776	251.27004	389 
154.875	214.620698681756	155.17779201064	251.27004	138 
327.25	208.646128813580	326.745170688580	251.27004	339 
336.25	220.506515932222	335.756140224028	251.27004	85 
188	232.080864339	188.192458229121	251.27004	117 
277.25	227.672777905100	277.042963328486	251.27004	227 




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time3 seconds
R Server'RServer@AstonUniversity' @ vre.aston.ac.uk

\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 & 'RServer@AstonUniversity' @ vre.aston.ac.uk \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=76441&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]'RServer@AstonUniversity' @ vre.aston.ac.uk[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=76441&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=76441&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'RServer@AstonUniversity' @ vre.aston.ac.uk







Model Performance
#Complexitysplitrelative errorCV errorCV S.D.
10.716011.0480.181
20.12610.2840.3330.057
30.07320.1580.3330.057
40.02730.0860.2620.053
50.0140.0590.2620.053

\begin{tabular}{lllllllll}
\hline
Model Performance \tabularnewline
# & Complexity & split & relative error & CV error & CV S.D. \tabularnewline
1 & 0.716 & 0 & 1 & 1.048 & 0.181 \tabularnewline
2 & 0.126 & 1 & 0.284 & 0.333 & 0.057 \tabularnewline
3 & 0.073 & 2 & 0.158 & 0.333 & 0.057 \tabularnewline
4 & 0.027 & 3 & 0.086 & 0.262 & 0.053 \tabularnewline
5 & 0.01 & 4 & 0.059 & 0.262 & 0.053 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=76441&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.716[/C][C]0[/C][C]1[/C][C]1.048[/C][C]0.181[/C][/ROW]
[ROW][C]2[/C][C]0.126[/C][C]1[/C][C]0.284[/C][C]0.333[/C][C]0.057[/C][/ROW]
[ROW][C]3[/C][C]0.073[/C][C]2[/C][C]0.158[/C][C]0.333[/C][C]0.057[/C][/ROW]
[ROW][C]4[/C][C]0.027[/C][C]3[/C][C]0.086[/C][C]0.262[/C][C]0.053[/C][/ROW]
[ROW][C]5[/C][C]0.01[/C][C]4[/C][C]0.059[/C][C]0.262[/C][C]0.053[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=76441&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=76441&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.716011.0480.181
20.12610.2840.3330.057
30.07320.1580.3330.057
40.02730.0860.2620.053
50.0140.0590.2620.053



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