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 10:13:29 +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/t1274868877jrb5kh90sz4daa0.htm/, Retrieved Fri, 03 May 2024 10:42:17 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=76443, Retrieved Fri, 03 May 2024 10:42:17 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywordsB511,regression tree,per maand,steven,coomans,thesis
Estimated Impact168
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
-       [Recursive Partitioning (Regression Trees)] [B511,regression t...] [2010-05-26 10:13:29] [d41d8cd98f00b204e9800998ecf8427e] [Current]
Feedback Forum

Post a new message
Dataseries X:
66	NA	66.6400081602945	65.9340000642625	66
66	66	74.8865290244873	65.9999544970003	44
66	66	69.4466779638461	65.9999741429027	66
76	66	54.592968576561	67.2912652912436	88
34	67	65.359813335731	65.097618300786	66
66	63.7	53.5306148746235	61.2705546832229	67
66	63.93	60.2131403294856	62.1803867658173	66
66	64.137	81.3710894221322	62.85982112799	66
66	64.3233	54.1503901382023	63.3873521146392	44
66	64.49097	63.170927562093	63.8082659858302	66
44	64.641873	53.4785961678077	62.7780896791892	44
44	62.5776857	36.0086271515583	59.9095531527368	44
66	60.71991713	65.3413647125152	59.6936234581407	44
87.5	61.247925417	73.8332331092841	60.8356206794414	66
66	63.8731328753	72.6698371634263	64.5842558764913	NA
66	64.08581958777	57.2076479997321	67.8930159267455	66
66	64.277237628993	65.5773520419694	54.5864341559968	66
65.5	64.4495138660937	59.7783847805255	66.1702603554484	88
65.5	64.5545624794843	65.1808994846169	66.0732597482336	66
88	64.6491062315359	85.3000011788247	66.1506824734975	66
42	66.9841956083823	61.5082524102149	68.9786501509172	66
88	64.4857760475441	64.5826998014614	65.4118136535975	88
88	66.8371984427897	58.7924091111244	61.8306169774286	66
64	68.9534785985107	48.658793284746	65.4303451710531	66
88	68.4581307386596	79.3842209531546	71.7459994615169	88
88	70.4123176647937	89.3860473656974	81.541820717718	88
88	72.1710858983143	85.3666565050138	75.0341722880627	88
63	73.7539773084829	71.669877609083	75.7932175260843	88
110	72.6785795776346	76.728036815868	78.5471215921968	68
85	76.4107216198711	77.1575352833932	79.4125986158928	88 
88	77.269649457884	82.9615773183237	80.2193112847716	88 
108	78.3426845120956	103.975665764726	89.1470965719674	88 
88.023	81.308416060886	80.4326749481525	75.9111663510669	88 
88	81.9798744547975	88.6492400856969	93.5794162521968	110 
66	82.5818870093177	78.2967726105023	95.1408210293909	88 
44.5	80.923698308386	60.2928816562315	82.6263841746852	66 
88.5	77.2813284775473	85.1148847421264	83.2819192115887	88 
88	78.4031956297926	94.1239817721025	81.4190987011273	88 
108	79.3628760668133	89.206744989429	84.9800826115048	130 
66	82.226588460132	78.5725460830362	79.8950729834965	110 
85	80.6039296141188	82.895184727681	92.7859883215547	88 
66	81.043536652707	77.4130342232758	84.1762183576399	88 
66	79.5391829874362	79.566127179505	82.6180545745621	88 
110	78.1852646886926	97.0528674218656	84.5153822287424	66 
83	81.3667382198233	75.2019256231291	86.7568550833349	110 
66	81.530064397841	83.457016080909	80.6175653648853	93 
83	79.9770579580569	69.9167389332608	69.9703995656468	88 
44	80.2793521622512	56.7242903583614	67.2147242043591	66 
83	76.6514169460261	82.13007477616	77.1762590877615	88 
105	77.2862752514235	90.6613214415051	78.7550058539266	88 





Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time3 seconds
R Server'Sir Ronald Aylmer Fisher' @ 193.190.124.24
R Framework error message
Warning: there are blank lines in the 'Data X' field.
Please, use NA for missing data - blank lines are simply
 deleted and are NOT treated as missing values.

\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 & 'Sir Ronald Aylmer Fisher' @ 193.190.124.24 \tabularnewline
R Framework error message & 
Warning: there are blank lines in the 'Data X' field.
Please, use NA for missing data - blank lines are simply
 deleted and are NOT treated as missing values.
\tabularnewline \hline \end{tabular} %Source: https://freestatistics.org/blog/index.php?pk=76443&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]'Sir Ronald Aylmer Fisher' @ 193.190.124.24[/C][/ROW]
[ROW][C]R Framework error message[/C][C]
Warning: there are blank lines in the 'Data X' field.
Please, use NA for missing data - blank lines are simply
 deleted and are NOT treated as missing values.
[/C][/ROW] [/TABLE] Source: https://freestatistics.org/blog/index.php?pk=76443&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=76443&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'Sir Ronald Aylmer Fisher' @ 193.190.124.24
R Framework error message
Warning: there are blank lines in the 'Data X' field.
Please, use NA for missing data - blank lines are simply
 deleted and are NOT treated as missing values.







Model Performance
#Complexitysplitrelative errorCV errorCV S.D.
10.391011.0280.191
20.11410.6090.8340.155
30.05220.4950.7080.167
40.0130.4440.7650.177

\begin{tabular}{lllllllll}
\hline
Model Performance \tabularnewline
# & Complexity & split & relative error & CV error & CV S.D. \tabularnewline
1 & 0.391 & 0 & 1 & 1.028 & 0.191 \tabularnewline
2 & 0.114 & 1 & 0.609 & 0.834 & 0.155 \tabularnewline
3 & 0.052 & 2 & 0.495 & 0.708 & 0.167 \tabularnewline
4 & 0.01 & 3 & 0.444 & 0.765 & 0.177 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=76443&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.391[/C][C]0[/C][C]1[/C][C]1.028[/C][C]0.191[/C][/ROW]
[ROW][C]2[/C][C]0.114[/C][C]1[/C][C]0.609[/C][C]0.834[/C][C]0.155[/C][/ROW]
[ROW][C]3[/C][C]0.052[/C][C]2[/C][C]0.495[/C][C]0.708[/C][C]0.167[/C][/ROW]
[ROW][C]4[/C][C]0.01[/C][C]3[/C][C]0.444[/C][C]0.765[/C][C]0.177[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=76443&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=76443&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.391011.0280.191
20.11410.6090.8340.155
30.05220.4950.7080.167
40.0130.4440.7650.177



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