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:16:23 +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/t12748690354bf3e51om0txxsp.htm/, Retrieved Fri, 03 May 2024 14:01:13 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=76444, Retrieved Fri, 03 May 2024 14:01:13 +0000
QR Codes:

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

Post a new message
Dataseries X:
387	NA	342.645625588810	386.613000262070	465
295.5	387	360.224691610665	374.123316633082	299
343.35	377.85	334.57221331123	336.048165995784	516
264.025	374.4	338.051132668702	338.086548077006	320
322.5	363.3625	308.712193932653	307.542001780858	365
392.5	359.27625	314.176745205712	313.784027977660	354
315.75	362.598625	345.218771733043	345.706762345858	408
274.4	357.9137625	333.539349111146	333.558139957923	265
361.875	349.56238625	310.100521795569	309.612466337202	335
411.276	350.793647625	330.620413749521	330.768423422594	388
518.775	356.8418828625	362.586818293621	363.353572983656	397
392.55	373.03519457625	424.489221258347	426.254986865821	444
467	374.986675118625	411.830679983883	412.614239712998	402
382.852	384.188007606763	433.696057002919	434.624717051376	400
449.25	384.054406846086	413.544920914575	413.671773960281	NA
564.252	390.573966161478	427.695992841313	428.070647900106	496
417	407.94176954533	481.817533216771	483.184602478810	475
450.8	408.847592590797	456.128258800945	456.399032969728	486
538.675	413.042833331717	454.016498360475	454.133048676047	459
394	425.606049998546	487.569387097804	488.348019556919	424
532	422.445444998691	450.484827677171	450.164435084369	513
461.4	433.400900498822	482.791913845528	483.284104365518	454
523	436.20081044894	474.313609939397	474.427389078871	506
405.9	444.880729404046	493.609593178994	494.085209133688	450
386.25	440.982656463641	458.847458672266	458.395775524229	493
384.5	435.509390817277	430.074749419565	429.19766065875	480
382	430.408451735549	412.012009506951	411.108071619878	475
381.75	425.567606561994	400.117284272407	399.327744740213	393
151.5	421.185845905795	392.837738406794	392.213856140806	254
287.775	394.217261315216	297.187825780639	294.794557918947	319 
247.6	383.573035183694	293.457219993799	291.953672823028	280 
290.35	369.975731665325	275.282527901956	274.003299091931	184 
266.55	362.013158498792	281.254252006065	280.618971975236	321 
318.025	352.466842648913	275.426483713804	274.925118706862	296 
213.3	349.022658384022	292.309646652501	292.368070501736	310 
148.75	335.450392545619	260.99558094183	260.368433823036	196 
273	316.780353291058	216.509044850814	215.195340483111	222 
282.25	312.402317961952	238.898228406847	238.589462676036	180 
191.25	309.387086165757	256.079930665467	256.259317558014	255 
142.25	297.573377549181	230.385742741739	229.94939840372	125 
259.25	282.041039794263	195.45471144866	194.456577242768	237 
272.75	279.761935814837	220.738837405002	220.679121618065	238 
173.75	279.060742233353	241.352535000074	241.752725402618	231 
204.75	268.529668010018	214.559474748700	214.231344240327	111 
185.525	262.151701209016	210.671664210590	210.394149668727	201 
267.175	254.489031088114	200.705231896851	200.329356777518	224 
190.25	255.757627979303	227.049340171498	227.382455241916	180 
127.25	249.206865181373	212.464577360093	212.35458028317	106 
183.5	237.011178663235	178.691297918695	177.911907893752	199 
254.125	231.660060796912	180.597141310443	180.173464499248	212 





Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time8 seconds
R Server'George Udny Yule' @ 72.249.76.132
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 & 8 seconds \tabularnewline
R Server & 'George Udny Yule' @ 72.249.76.132 \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=76444&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]8 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'George Udny Yule' @ 72.249.76.132[/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=76444&T=0

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

\begin{tabular}{lllllllll}
\hline
Model Performance \tabularnewline
# & Complexity & split & relative error & CV error & CV S.D. \tabularnewline
1 & 0.71 & 0 & 1 & 1.088 & 0.167 \tabularnewline
2 & 0.055 & 1 & 0.29 & 0.347 & 0.056 \tabularnewline
3 & 0.029 & 2 & 0.235 & 0.366 & 0.057 \tabularnewline
4 & 0.01 & 3 & 0.206 & 0.345 & 0.057 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=76444&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.71[/C][C]0[/C][C]1[/C][C]1.088[/C][C]0.167[/C][/ROW]
[ROW][C]2[/C][C]0.055[/C][C]1[/C][C]0.29[/C][C]0.347[/C][C]0.056[/C][/ROW]
[ROW][C]3[/C][C]0.029[/C][C]2[/C][C]0.235[/C][C]0.366[/C][C]0.057[/C][/ROW]
[ROW][C]4[/C][C]0.01[/C][C]3[/C][C]0.206[/C][C]0.345[/C][C]0.057[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=76444&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=76444&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.71011.0880.167
20.05510.290.3470.056
30.02920.2350.3660.057
40.0130.2060.3450.057



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