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:07:43 +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/t127486865199wlbhr5jbs6ars.htm/, Retrieved Fri, 03 May 2024 09:40:44 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=76442, Retrieved Fri, 03 May 2024 09:40:44 +0000
QR Codes:

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

Post a new message
Dataseries X:
283.25	NA	266.188606019126	282.966750204949	213
286.75	283.25	270.891611334875	283.840363485213	297
230.25	283.6	275.263005974429	281.694091305162	199
200.5	278.265	262.855086280826	260.877303843805	250
297.95	270.4885	245.666789558327	240.477467725152	302
329.5	273.23465	260.078754776835	260.301637689324	276
289.75	278.861185	279.214851491821	283.473863134466	251
223.775	279.9500665	282.118884977697	285.501477042126	265
281.78	274.33255985	266.036283432995	265.016411510642	271
265.8	275.077303865	270.376068493188	270.574646930639	278
256.75	274.1495734785	269.114666612848	268.990967395394	255
89.275	272.40961613065	265.706323023052	264.927551074807	205
225.5	254.096154517585	217.072697249434	206.724868986268	207
124.25	251.236539065827	219.395699090770	212.945092462218	221
230	238.537885159244	193.168608321036	183.557737684414	NA
286.525	237.684096643320	203.321250657694	198.945546067943	186
227	242.568186978988	226.256520535747	227.963047580939	191
218.3	241.011368281089	226.461462047352	227.643960820815	221
334.525	238.74023145298	224.211739695473	224.548070833112	339
128.95	248.318708307682	254.619797219461	260.986363812137	181
195.5	236.381837476914	219.978681434033	217.239187431134	265
106.056	232.293653729222	213.231086891884	210.036412890030	214
173.525	219.669888356300	183.688072766927	175.584926903992	244
114.75	215.05539952067	180.886602658401	174.902418000307	113
131.05	205.024859568603	162.655923839499	154.972316858305	208
141.25	197.627373611743	153.943691533454	147.046214989471	238
160.25	191.989636250569	150.444651605929	145.125774315763	174
145.5	188.815672625512	153.147514318775	150.13683381711	148
297.5	184.484105362961	151.039462624184	148.600527064262	156
179.25	195.785694826665	191.411585007509	197.934895247504	165 
137	194.132125343998	188.059221243893	191.744090918481	166 
158.6	188.418912809598	173.984650948099	173.605912966515	94 
55.6	185.437021528638	169.743843000579	168.634053626825	113 
15.25	172.453319375775	138.279878157287	131.182855791850	162 
67.75	156.732987438197	104.366461022770	92.7712074566496	98 
93	147.834688694377	94.2730647254302	84.481013833961	56 
126.75	142.351219824940	93.922142041287	87.3035812463404	56 
160	140.791097842446	102.971202783778	100.373232251632	154 
150.525	142.711988058201	118.691297915473	120.129171311937	105 
239.25	143.493289252381	127.466317722843	130.200120349172	101 
165.05	153.068960327143	158.279699827074	166.331255043692	211 
215.81	154.267064294429	160.145945793739	165.906741062477	170 
166	160.421357864986	175.489846949862	182.441022220241	149 
79.05	160.979222078487	172.873952803060	176.993672894802	123 
204.25	152.786299870639	147.011203881603	144.542320823904	96 
102	157.932669883575	162.789185605352	164.325067999016	215 
87.025	152.339402895217	146.032532346977	143.675110072167	60 
72.175	145.807962605696	129.766995157684	124.905417120366	46 
176.75	138.444666345126	113.891653454959	107.434423025053	158 
188.975	142.275199710613	131.218674815109	130.400523089806	106 





Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time2 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135
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 & 'Gwilym Jenkins' @ 72.249.127.135 \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=76442&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]'Gwilym Jenkins' @ 72.249.127.135[/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=76442&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=76442&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'Gwilym Jenkins' @ 72.249.127.135
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.371011.0730.164
20.08310.6290.7750.154
30.03220.5460.8080.164
40.0140.4820.8060.162

\begin{tabular}{lllllllll}
\hline
Model Performance \tabularnewline
# & Complexity & split & relative error & CV error & CV S.D. \tabularnewline
1 & 0.371 & 0 & 1 & 1.073 & 0.164 \tabularnewline
2 & 0.083 & 1 & 0.629 & 0.775 & 0.154 \tabularnewline
3 & 0.032 & 2 & 0.546 & 0.808 & 0.164 \tabularnewline
4 & 0.01 & 4 & 0.482 & 0.806 & 0.162 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=76442&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.371[/C][C]0[/C][C]1[/C][C]1.073[/C][C]0.164[/C][/ROW]
[ROW][C]2[/C][C]0.083[/C][C]1[/C][C]0.629[/C][C]0.775[/C][C]0.154[/C][/ROW]
[ROW][C]3[/C][C]0.032[/C][C]2[/C][C]0.546[/C][C]0.808[/C][C]0.164[/C][/ROW]
[ROW][C]4[/C][C]0.01[/C][C]4[/C][C]0.482[/C][C]0.806[/C][C]0.162[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=76442&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=76442&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.371011.0730.164
20.08310.6290.7750.154
30.03220.5460.8080.164
40.0140.4820.8060.162



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