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:57:55 +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/t1274871525ldhy9tvnv6ne89s.htm/, Retrieved Fri, 03 May 2024 10:36:23 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=76452, Retrieved Fri, 03 May 2024 10:36:23 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywordsFM22,regressin tree,steven,coomans,thesis,per maand
Estimated Impact153
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
-       [Recursive Partitioning (Regression Trees)] [FM22,regressin tr...] [2010-05-26 10:57:55] [d41d8cd98f00b204e9800998ecf8427e] [Current]
Feedback Forum

Post a new message
Dataseries X:
594.25	NA	699.997920798106	593.655750472382	722,75
853.75	594.25	648.094696588097	647.942799207107	803,8
766.5	620.2	749.03449041482	744.673364998473	876,8
758.05	634.83	757.606916738666	753.778778169047	795,8
756.85	647.152	757.824390989537	755.529720168062	917,3
685.4	658.1218	757.346140130168	749.907388162832	733
696.525	660.84962	722.033515408683	723.33892944098	850,5
610.025	664.417158	709.513418705798	704.516968331494	678,8
708.325	658.9779422	660.682485072171	672.68501267814	910,3
619.1	663.91264798	684.066397640522	680.23484230233	730
740.525	659.431383182	652.179572089688	664.582874665436	798,5
730.5	667.5407448638	695.541299848975	696.052601976007	763,5
489.75	673.83667037742	712.699738883378	655.544241875514	725,3
766.525	655.428003339678	603.271485377383	680.45740717072	768,5
780.125	666.53770300571	683.399621312151	686.76864206964	NA
804.975	677.896432705139	730.874398867526	724.218996193073	883
529.25	690.604289434625	767.244476743744	753.807367605178	2289
743.75	674.468860491163	650.431960772313	635.506534904222	775,5
771.15	681.396974442046	696.234347016108	686.076054174035	684
830.5	690.372276997842	733.004468871136	691.728771063574	685,5
600	704.385049298058	780.857252864086	782.989097499081	843,8
856.1	693.946544368252	692.088845177539	676.610491913217	855,3
702.75	710.161889931427	772.588846288154	794.826530239656	839,3
533.775	709.420700938284	738.31052412253	749.345042400237	708,8
311.25	691.856130844456	637.920340681366	576.525816892812	546,3
590	653.79551776001	477.583912246844	540.525418350128	644,75
738	647.415965984009	532.760008036036	581.845867357353	805,5
797.05	656.474369385608	633.495958581145	660.565830930517	772,5
531.3	670.531932447048	713.771599162515	600.288183112223	756,6
820	656.608739202343	624.210837572008	674.707766590396	800 
533.25	672.947865282109	720.30812930781	745.636209048273	780 
633.25	658.978078753898	628.496205702196	694.548612624309	621 
634.275	656.405270878508	630.829464355652	554.468246486220	643 
747.3	654.192243790657	632.520603129091	712.272349523156	668 
220.375	663.503019411592	688.856658963743	640.90531318958	635 
195.75	619.190217470432	458.916359429194	391.230261941304	306 
123.25	576.846195723389	329.748972922716	245.312950038669	274 
161.75	531.486576151050	228.395088989555	281.611155066594	305 
126.75	494.512918535945	195.684327678938	286.879143124124	339 
285.1	457.736626682351	161.849961591333	239.469364780464	220 
461.5	440.472964014116	222.343580086496	194.082609246879	340 
463.625	442.575667612704	339.726401331110	389.383530982008	1651 
325.875	444.680600851434	400.538346355494	290.573224811809	448 
177	432.800040766290	363.892061710736	332.245829765658	243 
223	407.220036689661	272.161647449797	316.860055686865	211 
168.45	388.798033020695	248.032113830012	272.113450680930	190 
251.75	366.763229718626	208.971598350831	33.9050653080551	157 
131.5	355.261906746763	229.968105472534	146.848855028763	189 
110.375	332.885716072087	181.63796226685	136.067930419851	135 
164.125	310.634644464878	146.660655096268	103.076560780786	164 





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=76452&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=76452&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=76452&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.767011.0250.129
20.0210.2330.4140.103
30.0130.1930.4120.085

\begin{tabular}{lllllllll}
\hline
Model Performance \tabularnewline
# & Complexity & split & relative error & CV error & CV S.D. \tabularnewline
1 & 0.767 & 0 & 1 & 1.025 & 0.129 \tabularnewline
2 & 0.02 & 1 & 0.233 & 0.414 & 0.103 \tabularnewline
3 & 0.01 & 3 & 0.193 & 0.412 & 0.085 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=76452&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.767[/C][C]0[/C][C]1[/C][C]1.025[/C][C]0.129[/C][/ROW]
[ROW][C]2[/C][C]0.02[/C][C]1[/C][C]0.233[/C][C]0.414[/C][C]0.103[/C][/ROW]
[ROW][C]3[/C][C]0.01[/C][C]3[/C][C]0.193[/C][C]0.412[/C][C]0.085[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=76452&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=76452&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.767011.0250.129
20.0210.2330.4140.103
30.0130.1930.4120.085



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