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:45:41 +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/t1274870821ktjyk4hl4ptagga.htm/, Retrieved Fri, 03 May 2024 07:15:20 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=76448, Retrieved Fri, 03 May 2024 07:15:20 +0000
QR Codes:

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

Post a new message
Dataseries X:
797	NA	782.711417226421	796.20300065502	648
642.25	797	765.0294568744	762.952337247724	592
726.275	781.525	649.806107458521	704.410416896747	617
652.75	776	723.56791155541	665.581080920744	702
678.75	763.675	615.796974930425	704.818827828887	688
602.25	755.1825	711.777300846748	631.816961296255	663
689.775	739.88925	719.287764661505	654.598278915382	693
393	734.877825	514.492157182367	606.863336282914	419
580.525	700.6900425	568.698163436724	509.418190174305	581
462.25	688.67353825	527.978998668824	465.80488389292	585
725.65	666.031184425	478.336938109688	584.551182892532	458
501	671.9930659825	534.996332111507	584.24363832272	476
675	654.89375938425	664.412824861296	643.519082911609	568
691	656.904383445825	643.611465200888	520.449547068052	558
769.025	660.313945101243	671.176086172387	758.07019155421	NA
688.25	671.185050591118	762.860278704985	708.310127515555	579
518.8	672.891545532007	651.92127364904	727.053151603044	631
386.275	657.482390978806	583.381473899396	508.80532190237	553
491.35	630.361651880925	517.422882856391	434.2318942773	555
269.5	616.460486692833	315.503881065959	331.248437042921	368
379	581.76443802355	433.056689590744	389.269640545343	461
375.25	561.487994221195	337.054612518579	299.1481893675	397
337.5	542.864194799075	374.635041228908	502.876183618978	376
296	522.327775319168	192.619299478441	267.453582131041	316
375	499.694997787251	437.296999705657	340.713876999818	386
399.525	487.225498008526	355.350992000882	407.070535873498	457
336	478.455448207673	380.223837962091	417.641465716004	370
483.5	464.209903386906	352.694153942505	332.898922218684	382
370.25	466.138913048215	414.089307855428	337.338283908306	399
625.5	456.550021743394	420.44880902639	355.134629732789	478 
736.75	473.445019569055	691.91012962691	571.23916170188	600 
496.05	499.775517612149	549.483513444763	681.062633873284	525 
740.5	499.402965850934	660.802183052332	549.057121163136	714 
690.525	523.512669265841	677.0269500232	693.072231556067	687 
568.75	540.213902339257	693.8791043314	712.003500002354	650 
341.1	543.067512105331	438.052398315464	548.996333351918	445 
519.75	522.870760894798	514.637616791392	427.493775297068	497 
408.75	522.558684805318	489.25763684781	468.264830665661	473 
278.35	511.177816324786	409.515986555195	446.239032991459	399 
217	487.895034692308	309.061396860208	330.312869791279	317 
266	460.805531223077	183.457445377064	205.218731892318	296 
319.025	441.324978100769	295.874273558410	337.419117389042	301 
454.75	429.094980290692	414.708291820007	419.036160167183	298 
378.3	431.660482261623	268.246080312969	291.687302641049	196 
509.575	426.324434035461	516.741113232939	515.635322954833	620 
453.75	434.649490631915	460.081976315332	469.396122015109	600 
252	436.559541568723	460.282975001957	413.361749776128	533 
187.525	418.103587411851	134.694665694760	166.430760748899	187 
401.5	395.045728670666	336.955099542137	248.202334497077	484 
403.75	395.691155803599	361.429105851861	333.451042483504	322 





Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time2 seconds
R Server'RServer@AstonUniversity' @ vre.aston.ac.uk
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 & 2 seconds \tabularnewline
R Server & 'RServer@AstonUniversity' @ vre.aston.ac.uk \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=76448&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]2 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'RServer@AstonUniversity' @ vre.aston.ac.uk[/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=76448&T=0

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

\begin{tabular}{lllllllll}
\hline
Model Performance \tabularnewline
# & Complexity & split & relative error & CV error & CV S.D. \tabularnewline
1 & 0.616 & 0 & 1 & 1.069 & 0.143 \tabularnewline
2 & 0.118 & 1 & 0.384 & 0.574 & 0.124 \tabularnewline
3 & 0.01 & 2 & 0.265 & 0.485 & 0.125 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=76448&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.616[/C][C]0[/C][C]1[/C][C]1.069[/C][C]0.143[/C][/ROW]
[ROW][C]2[/C][C]0.118[/C][C]1[/C][C]0.384[/C][C]0.574[/C][C]0.124[/C][/ROW]
[ROW][C]3[/C][C]0.01[/C][C]2[/C][C]0.265[/C][C]0.485[/C][C]0.125[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=76448&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=76448&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.616011.0690.143
20.11810.3840.5740.124
30.0120.2650.4850.125



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