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

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

Post a new message
Dataseries X:
209	NA	207.578503057629	208.791000220112	223
175	209	215.531763346576	198.426779339075	201
247.5	205.6	285.751097248607	203.378258089298	241
177	209.79	118.186987745813	206.916502799148	199
188.775	206.511	214.853226812988	198.493885113137	198
194.825	204.7374	138.401727102421	196.263512901256 254
182.275	203.74616	216.486643563448	193.640749579656	232
145.25	201.599044	97.6257034058337	183.618255052768	176
286.3	195.9641396	245.459409265308	194.973766357325	284
257.75	204.99772564	280.672235749570	219.947196737977	229
335	210.272953076	262.276026647169	245.338121076719	229
234.15	222.7456577684	233.243533537997	257.514432415318	292
276.275	223.88609199156	250.184476503336	258.505048267576	252
327.052	229.124982792404	267.134675437714	255.53357353954	192
375.325	238.917684513164	374.008804029831	315.322448001021	NA
199.75	252.558416061847	220.89450878188	293.272867505843	246
215.875	247.277574455663	288.373712865628	268.44574756024	276
225	244.137317010096	194.992809298708	254.391240106182	279
228.1	242.223585309087	263.427632470548	239.544311419872	294
128.5	240.811226778178	144.169115657069	213.489073070484	195
242.5	229.58010410036	268.90584331271	254.053084952268	214
327.275	230.872093690324	279.572485861439	243.25421812959	233
346.8	240.512384321292	286.95899170416	305.330568389782	314
221.175	251.141145889163	253.216947852348	267.255114086196	308
245.275	248.144531300246	258.137771298881	270.024693610743	248
230.725	247.857578170222	260.877650429826	298.681762847649	260
335.3	246.144320353200	334.877745498272	287.508494249009	298
97.25	255.059888317880	181.434595292499	214.89352137417	211
254.5	239.278899486092	225.904002981947	186.707631098946	132
71.25	240.801009537482	169.425310278149	207.601739355676	113 
273.575	223.845908583734	191.077796826959	173.554668621071	176 
98.325	228.818817725361	114.816648313125	154.336231589396	59 
184.55	215.769435952825	239.251961739029	166.278743842984	154 
203.025	212.647492357542	239.601909862737	228.807116636272	220 
121.655	211.685243121788	216.235737726035	209.003839800871	258 
135	202.682218809609	126.133353910805	135.659535200178	133 
98.75	195.913996928648	145.984252152785	139.943125963237	136 
69.1	186.197597235784	136.179714477329	92.208844377748	96 
256.525	174.487837512205	196.708490866528	147.122521391435	151 
97.775	182.691553760985	64.9287086805014	84.4553816480669	138 
202.7	174.199898384886	152.116753990838	184.750081665235	102 
81.9	177.049908546398	103.646395070923	71.8893513924464	150 
165.25	167.534917691758	153.209605600343	199.790371621642	125 
75.825	167.306425922582	51.2266305836655	107.963672206709	107 
300	158.158283330324	190.651450747171	136.157711472038	140 
238.5	172.342454997291	250.866635894662	164.294723220295	247 
194.5	178.958209497562	236.328106963891	142.880720140488	209 
140.75	180.512388547806	165.487705941164	196.613502921185	159 
211.75	176.536149693025	173.069538773582	152.099346335145	192 
274.8	180.057534723723	194.613497545848	175.013624568627	197 





Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time2 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 & 2 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=76446&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]'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=76446&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=76446&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'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.532011.0320.168
20.11310.4680.5720.108
30.0220.3550.5290.081
40.0130.3340.530.082

\begin{tabular}{lllllllll}
\hline
Model Performance \tabularnewline
# & Complexity & split & relative error & CV error & CV S.D. \tabularnewline
1 & 0.532 & 0 & 1 & 1.032 & 0.168 \tabularnewline
2 & 0.113 & 1 & 0.468 & 0.572 & 0.108 \tabularnewline
3 & 0.02 & 2 & 0.355 & 0.529 & 0.081 \tabularnewline
4 & 0.01 & 3 & 0.334 & 0.53 & 0.082 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=76446&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.532[/C][C]0[/C][C]1[/C][C]1.032[/C][C]0.168[/C][/ROW]
[ROW][C]2[/C][C]0.113[/C][C]1[/C][C]0.468[/C][C]0.572[/C][C]0.108[/C][/ROW]
[ROW][C]3[/C][C]0.02[/C][C]2[/C][C]0.355[/C][C]0.529[/C][C]0.081[/C][/ROW]
[ROW][C]4[/C][C]0.01[/C][C]3[/C][C]0.334[/C][C]0.53[/C][C]0.082[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=76446&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=76446&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.532011.0320.168
20.11310.4680.5720.108
30.0220.3550.5290.081
40.0130.3340.530.082



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