Free Statistics

of Irreproducible Research!

Author's title

Author*The author of this computation has been verified*
R Software Modulerwasp_regression_trees1.wasp
Title produced by softwareRecursive Partitioning (Regression Trees)
Date of computationThu, 15 Dec 2011 11:08:05 -0500
Cite this page as followsStatistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?v=date/2011/Dec/15/t13239653410pohzror93cbib8.htm/, Retrieved Wed, 08 May 2024 03:26:49 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=155536, Retrieved Wed, 08 May 2024 03:26:49 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact99
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
-     [Kendall tau Correlation Matrix] [] [2010-12-05 17:44:33] [b98453cac15ba1066b407e146608df68]
- RMPD  [Kendall tau Correlation Matrix] [Pearson Correlati...] [2011-12-13 17:28:26] [570fce4db58fd7864ac807c4286d6e49]
- RMPD      [Recursive Partitioning (Regression Trees)] [] [2011-12-15 16:08:05] [c7041fab4904771a5085f5eb0f28763f] [Current]
Feedback Forum

Post a new message
Dataseries X:
1575	129988	81	20	63	18158
1134	130358	46	38	50	30461
192	7215	18	0	0	1423
2044	112976	87	49	51	25629
3283	219904	126	76	112	48758
5877	402036	218	104	118	129230
1322	117604	50	37	59	27376
1225	131822	50	57	90	26706
1463	99729	38	42	50	26505
2568	256310	86	62	79	49801
1810	113066	69	50	49	46580
1915	165392	62	66	91	48352
1452	78240	90	38	32	13899
2415	152673	84	48	82	39342
1254	134368	47	42	58	27465
1374	125769	67	47	65	55211
1504	123467	50	71	111	74098
999	56232	47	0	36	13497
2222	108458	79	50	89	38338
634	22762	21	12	28	52505
849	48633	50	16	35	10663
2189	182081	83	77	78	74484
1469	140857	59	29	67	28895
1791	93773	46	38	61	32827
1751	133428	79	50	58	36188
1180	113933	23	33	49	28173
1749	153851	139	49	77	54926
1101	140711	75	59	71	38900
2391	303844	105	55	85	88530
1826	163810	38	42	56	35482
1301	123344	40	40	71	26730
1433	157640	39	51	58	29806
1893	103274	90	45	34	41799
2525	193500	105	73	59	54289
2033	178768	43	51	77	36805
1	0	1	0	0	0
1817	181412	55	46	75	33146
1506	92342	47	44	39	23333
1820	100023	41	31	83	47686
1649	178277	50	71	123	77783
1672	145067	58	61	67	36042
1433	114146	50	28	105	34541
864	86039	25	21	76	75620
1683	125481	66	42	57	60610
1024	95535	42	44	82	55041
1029	129221	78	40	64	32087
629	61554	26	15	57	16356
1679	168048	82	46	80	40161
1715	159121	75	43	94	55459
2093	129362	51	47	72	36679
658	48188	28	12	39	22346
1234	95461	56	46	60	27377
2059	229864	64	56	84	50273
1725	191094	68	47	69	32104
1504	161082	51	50	102	27016
1454	111388	47	35	28	19715
1620	172614	58	45	65	33629
733	63205	18	25	67	27084
894	109102	56	47	80	32352
2343	137303	74	28	79	51845
1503	125304	50	48	107	26591
1627	88620	65	32	60	29677
1119	95808	48	28	53	54237
897	83419	29	31	59	20284
855	101723	25	13	80	22741
1229	94982	37	38	89	34178
1991	143566	61	48	115	69551
2393	113325	63	68	59	29653
820	81518	32	32	66	38071
340	31970	15	5	42	4157
2443	192268	102	53	35	28321
1030	91261	55	33	3	40195
1091	80820	56	54	72	48158
1425	89141	60	37	38	13310
2192	116322	53	52	107	78474
1082	56544	32	0	73	6386
1790	118838	52	52	84	31588
2072	118781	80	51	69	61254
816	60138	23	16	46	21152
1121	73422	66	33	52	41272
820	67819	59	48	58	34165
1766	225857	54	35	85	37054
751	51185	24	24	13	12368
1309	97181	32	37	61	23168
732	45100	39	17	49	16380
1327	115801	43	32	47	41242
2246	186310	190	55	93	48450
968	71960	86	39	65	20790
1015	80105	48	31	64	34585
1149	110416	43	26	67	35672
1300	98707	33	37	57	52168
1982	136234	67	66	61	53933
1091	136781	52	35	71	34474
1107	105863	52	24	43	43753
759	49164	33	22	27	36456
1980	189493	93	42	103	51183
1608	169406	50	86	76	52742
223	19349	12	13	0	3895
1807	160819	87	21	83	37076
1466	109510	53	32	73	24079
553	43803	25	8	4	2325
708	47062	19	38	41	29354
1079	110845	44	45	57	30341
957	92517	52	24	52	18992
585	58660	36	23	24	15292
596	27676	22	2	17	5842
980	98550	32	52	89	28918
585	43646	24	5	20	3738
0	0	0	0	0	0
975	75566	28	43	51	95352
750	57359	48	18	63	37478
1071	104330	36	44	48	26839
931	70369	47	45	70	26783
783	65494	56	29	32	33392
78	3616	5	0	0	0
0	0	0	0	0	0
874	143931	37	32	72	25446
1327	117946	66	65	56	59847
1831	137332	85	26	66	28162
750	84336	33	24	77	33298
778	43410	19	7	3	2781
1442	139695	61	62	76	37121
807	79015	34	30	37	22698
1613	106116	47	54	57	27615
685	57586	38	3	32	32689
285	19764	12	10	4	5752
1336	105757	42	42	55	23164
954	103651	25	23	84	20304
1283	113402	35	40	90	34409
256	11796	9	1	1	0
81	7627	9	0	0	0
1214	121085	49	29	38	92538
41	6836	3	0	0	0
1634	139563	46	46	36	46037
42	5118	3	5	0	0
528	40248	16	8	7	5444
0	0	0	0	0	0
890	95079	42	21	75	23924
1203	80763	32	21	52	52230
81	7131	4	0	0	0
61	4194	11	0	0	0
849	60378	20	15	45	8019
1035	109173	44	47	66	34542
964	83484	16	17	48	21157




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time4 seconds
R Server'Gertrude Mary Cox' @ cox.wessa.net

\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 & 4 seconds \tabularnewline
R Server & 'Gertrude Mary Cox' @ cox.wessa.net \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=155536&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]4 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'Gertrude Mary Cox' @ cox.wessa.net[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=155536&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=155536&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 time4 seconds
R Server'Gertrude Mary Cox' @ cox.wessa.net







Confusion Matrix (predicted in columns / actuals in rows)
C1C2
C15715
C2567

\begin{tabular}{lllllllll}
\hline
Confusion Matrix (predicted in columns / actuals in rows) \tabularnewline
 & C1 & C2 \tabularnewline
C1 & 57 & 15 \tabularnewline
C2 & 5 & 67 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=155536&T=1

[TABLE]
[ROW][C]Confusion Matrix (predicted in columns / actuals in rows)[/C][/ROW]
[ROW][C][/C][C]C1[/C][C]C2[/C][/ROW]
[ROW][C]C1[/C][C]57[/C][C]15[/C][/ROW]
[ROW][C]C2[/C][C]5[/C][C]67[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=155536&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=155536&T=1

As an alternative you can also use a QR Code:  

The GUIDs for individual cells are displayed in the table below:

Confusion Matrix (predicted in columns / actuals in rows)
C1C2
C15715
C2567



Parameters (Session):
par1 = 2 ; par2 = quantiles ; par3 = 2 ; par4 = no ;
Parameters (R input):
par1 = 2 ; par2 = quantiles ; par3 = 2 ; par4 = no ;
R code (references can be found in the software module):
library(party)
library(Hmisc)
par1 <- as.numeric(par1)
par3 <- as.numeric(par3)
x <- data.frame(t(y))
is.data.frame(x)
x <- x[!is.na(x[,par1]),]
k <- length(x[1,])
n <- length(x[,1])
colnames(x)[par1]
x[,par1]
if (par2 == 'kmeans') {
cl <- kmeans(x[,par1], par3)
print(cl)
clm <- matrix(cbind(cl$centers,1:par3),ncol=2)
clm <- clm[sort.list(clm[,1]),]
for (i in 1:par3) {
cl$cluster[cl$cluster==clm[i,2]] <- paste('C',i,sep='')
}
cl$cluster <- as.factor(cl$cluster)
print(cl$cluster)
x[,par1] <- cl$cluster
}
if (par2 == 'quantiles') {
x[,par1] <- cut2(x[,par1],g=par3)
}
if (par2 == 'hclust') {
hc <- hclust(dist(x[,par1])^2, 'cen')
print(hc)
memb <- cutree(hc, k = par3)
dum <- c(mean(x[memb==1,par1]))
for (i in 2:par3) {
dum <- c(dum, mean(x[memb==i,par1]))
}
hcm <- matrix(cbind(dum,1:par3),ncol=2)
hcm <- hcm[sort.list(hcm[,1]),]
for (i in 1:par3) {
memb[memb==hcm[i,2]] <- paste('C',i,sep='')
}
memb <- as.factor(memb)
print(memb)
x[,par1] <- memb
}
if (par2=='equal') {
ed <- cut(as.numeric(x[,par1]),par3,labels=paste('C',1:par3,sep=''))
x[,par1] <- as.factor(ed)
}
table(x[,par1])
colnames(x)
colnames(x)[par1]
x[,par1]
if (par2 == 'none') {
m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x)
}
load(file='createtable')
if (par2 != 'none') {
m <- ctree(as.formula(paste('as.factor(',colnames(x)[par1],') ~ .',sep='')),data = x)
if (par4=='yes') {
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'10-Fold Cross Validation',3+2*par3,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'',1,TRUE)
a<-table.element(a,'Prediction (training)',par3+1,TRUE)
a<-table.element(a,'Prediction (testing)',par3+1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Actual',1,TRUE)
for (jjj in 1:par3) a<-table.element(a,paste('C',jjj,sep=''),1,TRUE)
a<-table.element(a,'CV',1,TRUE)
for (jjj in 1:par3) a<-table.element(a,paste('C',jjj,sep=''),1,TRUE)
a<-table.element(a,'CV',1,TRUE)
a<-table.row.end(a)
for (i in 1:10) {
ind <- sample(2, nrow(x), replace=T, prob=c(0.9,0.1))
m.ct <- ctree(as.formula(paste('as.factor(',colnames(x)[par1],') ~ .',sep='')),data =x[ind==1,])
if (i==1) {
m.ct.i.pred <- predict(m.ct, newdata=x[ind==1,])
m.ct.i.actu <- x[ind==1,par1]
m.ct.x.pred <- predict(m.ct, newdata=x[ind==2,])
m.ct.x.actu <- x[ind==2,par1]
} else {
m.ct.i.pred <- c(m.ct.i.pred,predict(m.ct, newdata=x[ind==1,]))
m.ct.i.actu <- c(m.ct.i.actu,x[ind==1,par1])
m.ct.x.pred <- c(m.ct.x.pred,predict(m.ct, newdata=x[ind==2,]))
m.ct.x.actu <- c(m.ct.x.actu,x[ind==2,par1])
}
}
print(m.ct.i.tab <- table(m.ct.i.actu,m.ct.i.pred))
numer <- 0
for (i in 1:par3) {
print(m.ct.i.tab[i,i] / sum(m.ct.i.tab[i,]))
numer <- numer + m.ct.i.tab[i,i]
}
print(m.ct.i.cp <- numer / sum(m.ct.i.tab))
print(m.ct.x.tab <- table(m.ct.x.actu,m.ct.x.pred))
numer <- 0
for (i in 1:par3) {
print(m.ct.x.tab[i,i] / sum(m.ct.x.tab[i,]))
numer <- numer + m.ct.x.tab[i,i]
}
print(m.ct.x.cp <- numer / sum(m.ct.x.tab))
for (i in 1:par3) {
a<-table.row.start(a)
a<-table.element(a,paste('C',i,sep=''),1,TRUE)
for (jjj in 1:par3) a<-table.element(a,m.ct.i.tab[i,jjj])
a<-table.element(a,round(m.ct.i.tab[i,i]/sum(m.ct.i.tab[i,]),4))
for (jjj in 1:par3) a<-table.element(a,m.ct.x.tab[i,jjj])
a<-table.element(a,round(m.ct.x.tab[i,i]/sum(m.ct.x.tab[i,]),4))
a<-table.row.end(a)
}
a<-table.row.start(a)
a<-table.element(a,'Overall',1,TRUE)
for (jjj in 1:par3) a<-table.element(a,'-')
a<-table.element(a,round(m.ct.i.cp,4))
for (jjj in 1:par3) a<-table.element(a,'-')
a<-table.element(a,round(m.ct.x.cp,4))
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file='mytable3.tab')
}
}
m
bitmap(file='test1.png')
plot(m)
dev.off()
bitmap(file='test1a.png')
plot(x[,par1] ~ as.factor(where(m)),main='Response by Terminal Node',xlab='Terminal Node',ylab='Response')
dev.off()
if (par2 == 'none') {
forec <- predict(m)
result <- as.data.frame(cbind(x[,par1],forec,x[,par1]-forec))
colnames(result) <- c('Actuals','Forecasts','Residuals')
print(result)
}
if (par2 != 'none') {
print(cbind(as.factor(x[,par1]),predict(m)))
myt <- table(as.factor(x[,par1]),predict(m))
print(myt)
}
bitmap(file='test2.png')
if(par2=='none') {
op <- par(mfrow=c(2,2))
plot(density(result$Actuals),main='Kernel Density Plot of Actuals')
plot(density(result$Residuals),main='Kernel Density Plot of Residuals')
plot(result$Forecasts,result$Actuals,main='Actuals versus Predictions',xlab='Predictions',ylab='Actuals')
plot(density(result$Forecasts),main='Kernel Density Plot of Predictions')
par(op)
}
if(par2!='none') {
plot(myt,main='Confusion Matrix',xlab='Actual',ylab='Predicted')
}
dev.off()
if (par2 == 'none') {
detcoef <- cor(result$Forecasts,result$Actuals)
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Goodness of Fit',2,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Correlation',1,TRUE)
a<-table.element(a,round(detcoef,4))
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'R-squared',1,TRUE)
a<-table.element(a,round(detcoef*detcoef,4))
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'RMSE',1,TRUE)
a<-table.element(a,round(sqrt(mean((result$Residuals)^2)),4))
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file='mytable1.tab')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Actuals, Predictions, and Residuals',4,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'#',header=TRUE)
a<-table.element(a,'Actuals',header=TRUE)
a<-table.element(a,'Forecasts',header=TRUE)
a<-table.element(a,'Residuals',header=TRUE)
a<-table.row.end(a)
for (i in 1:length(result$Actuals)) {
a<-table.row.start(a)
a<-table.element(a,i,header=TRUE)
a<-table.element(a,result$Actuals[i])
a<-table.element(a,result$Forecasts[i])
a<-table.element(a,result$Residuals[i])
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable.tab')
}
if (par2 != 'none') {
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Confusion Matrix (predicted in columns / actuals in rows)',par3+1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'',1,TRUE)
for (i in 1:par3) {
a<-table.element(a,paste('C',i,sep=''),1,TRUE)
}
a<-table.row.end(a)
for (i in 1:par3) {
a<-table.row.start(a)
a<-table.element(a,paste('C',i,sep=''),1,TRUE)
for (j in 1:par3) {
a<-table.element(a,myt[i,j])
}
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable2.tab')
}