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, 22 Dec 2011 15:37:26 -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/22/t1324586292c7atc0gtw01yhbj.htm/, Retrieved Fri, 03 May 2024 11:16:29 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=159959, Retrieved Fri, 03 May 2024 11:16:29 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact66
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
-     [Recursive Partitioning (Regression Trees)] [] [2010-12-05 18:59:57] [b98453cac15ba1066b407e146608df68]
- R PD  [Recursive Partitioning (Regression Trees)] [WS X-recursive pa...] [2011-12-13 19:30:08] [7c680a04865e75aa8ab422cdbfd97ac3]
-   PD    [Recursive Partitioning (Regression Trees)] [Paper recursive p...] [2011-12-22 20:31:09] [7c680a04865e75aa8ab422cdbfd97ac3]
-   P       [Recursive Partitioning (Regression Trees)] [Paper recursive p...] [2011-12-22 20:35:07] [7c680a04865e75aa8ab422cdbfd97ac3]
-   P           [Recursive Partitioning (Regression Trees)] [Paper recursive p...] [2011-12-22 20:37:26] [3e388c05c22237d436c48535c44f60bb] [Current]
Feedback Forum

Post a new message
Dataseries X:
112285	79	396	115	94	1418	146283
84786	58	297	109	103	869	98364
83123	60	559	146	93	1530	86146
101193	108	967	116	103	2172	96933
38361	49	270	68	51	901	79234
68504	0	143	101	70	463	42551
119182	121	1562	96	91	3201	195663
22807	1	109	67	22	371	6853
17140	20	371	44	38	1192	21529
116174	43	656	100	93	1583	95757
57635	69	511	93	60	1439	85584
66198	78	655	140	123	1764	143983
71701	86	465	166	148	1495	75851
57793	44	525	99	90	1373	59238
80444	104	885	139	124	2187	93163
53855	63	497	130	70	1491	96037
97668	158	1436	181	168	4041	151511
133824	102	612	116	115	1706	136368
101481	77	865	116	71	2152	112642
99645	82	385	88	66	1036	94728
114789	115	567	139	134	1882	105499
99052	101	639	135	117	1929	121527
67654	80	963	108	108	2242	127766
65553	50	398	89	84	1220	98958
97500	83	410	156	156	1289	77900
69112	123	966	129	120	2515	85646
82753	73	801	118	114	2147	98579
85323	81	892	118	94	2352	130767
72654	105	513	125	120	1638	131741
30727	47	469	95	81	1222	53907
77873	105	683	126	110	1812	178812
117478	94	643	135	133	1677	146761
74007	44	535	154	122	1579	82036
90183	114	625	165	158	1731	163253
61542	38	264	113	109	807	27032
101494	107	992	127	124	2452	171975
27570	30	238	52	39	829	65990
55813	71	818	121	92	1940	86572
79215	84	937	136	126	2662	159676
1423	0	70	0	0	186	1929
55461	59	507	108	70	1499	85371
31081	33	260	46	37	865	58391
22996	42	503	54	38	1793	31580
83122	96	927	124	120	2527	136815
70106	106	1269	115	93	2747	120642
60578	56	537	128	95	1324	69107
39992	57	910	80	77	2702	50495
79892	59	532	97	90	1383	108016
49810	39	345	104	80	1179	46341
71570	34	918	59	31	2099	78348
100708	76	1635	125	110	4308	79336
33032	20	330	82	66	918	56968
82875	91	557	149	138	1831	93176
139077	115	1178	149	133	3373	161632
71595	85	740	122	113	1713	87850
72260	76	452	118	100	1438	127969
5950	8	218	12	7	496	15049
115762	79	764	144	140	2253	155135
32551	21	255	67	61	744	25109
31701	30	454	52	41	1161	45824
80670	76	866	108	96	2352	102996
143558	101	574	166	164	2144	160604
117105	94	1276	80	78	4691	158051
23789	27	379	60	49	1112	44547
120733	92	825	107	102	2694	162647
105195	123	798	127	124	1973	174141
73107	75	663	107	99	1769	60622
132068	128	1069	146	129	3148	179566
149193	105	921	84	62	2474	184301
46821	55	858	141	73	2084	75661
87011	56	711	123	114	1954	96144
95260	41	503	111	99	1226	129847
55183	72	382	98	70	1389	117286
106671	67	464	105	104	1496	71180
73511	75	717	135	116	2269	109377
92945	114	690	107	91	1833	85298
78664	118	462	85	74	1268	73631
70054	77	657	155	138	1943	86767
22618	22	385	88	67	893	23824
74011	66	577	155	151	1762	93487
83737	69	619	104	72	1403	82981
69094	105	479	132	120	1425	73815
93133	116	817	127	115	1857	94552
95536	88	752	108	105	1840	132190
225920	73	430	129	104	1502	128754
62133	99	451	116	108	1441	66363
61370	62	537	122	98	1420	67808
43836	53	519	85	69	1416	61724
106117	118	1000	147	111	2970	131722
38692	30	637	99	99	1317	68580
84651	100	465	87	71	1644	106175
56622	49	437	28	27	870	55792
15986	24	711	90	69	1654	25157
95364	67	299	109	107	1054	76669
26706	46	248	78	73	937	57283
89691	57	1162	111	107	3004	105805
67267	75	714	158	93	2008	129484
126846	135	905	141	129	2547	72413
41140	68	649	122	69	1885	87831
102860	124	512	124	118	1626	96971
51715	33	472	93	73	1468	71299
55801	98	905	124	119	2445	77494
111813	58	786	112	104	1964	120336
120293	68	489	108	107	1381	93913
138599	81	479	99	99	1369	136048
161647	131	617	117	90	1659	181248
115929	110	925	199	197	2888	146123
24266	37	351	78	36	1290	32036
162901	130	1144	91	85	2845	186646
109825	93	669	158	139	1982	102255
129838	118	707	126	106	1904	168237
37510	39	458	122	50	1391	64219
43750	13	214	71	64	602	19630
40652	74	599	75	31	1743	76825
87771	81	572	115	63	1559	115338
85872	109	897	119	92	2014	109427
89275	151	819	124	106	2143	118168
44418	51	720	72	63	2146	84845
192565	28	273	91	69	874	153197
35232	40	508	45	41	1590	29877
40909	56	506	78	56	1590	63506
13294	27	451	39	25	1210	22445
32387	37	699	68	65	2072	47695
140867	83	407	119	93	1281	68370
120662	54	465	117	114	1401	146304
21233	27	245	39	38	834	38233
44332	28	370	50	44	1105	42071
61056	59	316	88	87	1272	50517
101338	133	603	155	110	1944	103950
1168	12	154	0	0	391	5841
13497	0	229	36	27	761	2341
65567	106	577	123	83	1605	84396
25162	23	192	32	30	530	24610
32334	44	617	99	80	1988	35753
40735	71	411	136	98	1386	55515
91413	116	975	117	82	2395	209056
855	4	146	0	0	387	6622
97068	62	705	88	60	1742	115814
44339	12	184	39	28	620	11609
14116	18	200	25	9	449	13155
10288	14	274	52	33	800	18274
65622	60	502	75	59	1684	72875
16563	7	382	71	49	1050	10112
76643	98	964	124	115	2699	142775
110681	64	537	151	140	1606	68847
29011	29	438	71	49	1502	17659
92696	32	369	145	120	1204	20112
94785	25	417	87	66	1138	61023
8773	16	276	27	21	568	13983
83209	48	514	131	124	1459	65176
93815	100	822	162	152	2158	132432
86687	46	389	165	139	1111	112494
34553	45	466	54	38	1421	45109
105547	129	1255	159	144	2833	170875
103487	130	694	147	120	1955	180759
213688	136	1024	170	160	2922	214921
71220	59	400	119	114	1002	100226
23517	25	397	49	39	1060	32043
56926	32	350	104	78	956	54454
91721	63	719	120	119	2186	78876
115168	95	1277	150	141	3604	170745
111194	14	356	112	101	1035	6940
51009	36	457	59	56	1417	49025
135777	113	1402	136	133	3261	122037
51513	47	600	107	83	1587	53782
74163	92	480	130	116	1424	127748
51633	70	595	115	90	1701	86839
75345	19	436	107	36	1249	44830
33416	50	230	75	50	946	77395
83305	41	651	71	61	1926	89324
98952	91	1367	120	97	3352	103300
102372	111	564	116	98	1641	112283
37238	41	716	79	78	2035	10901
103772	120	747	150	117	2312	120691
123969	135	467	156	148	1369	58106
27142	27	671	51	41	1577	57140
135400	87	861	118	105	2201	122422
21399	25	319	71	55	961	25899
130115	131	612	144	132	1900	139296
24874	45	433	47	44	1254	52678
34988	29	434	28	21	1335	23853
45549	58	503	68	50	1597	17306
6023	4	85	0	0	207	7953
64466	47	564	110	73	1645	89455
54990	109	824	147	86	2429	147866
1644	7	74	0	0	151	4245
6179	12	259	15	13	474	21509
3926	0	69	4	4	141	7670
32755	37	535	64	57	1639	66675
34777	37	239	111	48	872	14336
73224	46	438	85	46	1318	53608
27114	15	459	68	48	1018	30059
20760	42	426	40	32	1383	29668
37636	7	288	80	68	1314	22097
65461	54	498	88	87	1335	96841
30080	54	454	48	43	1403	41907
24094	14	376	76	67	910	27080
69008	16	225	51	46	616	35885
54968	33	555	67	46	1407	41247
46090	32	252	59	56	771	28313
27507	21	208	61	48	766	36845
10672	15	130	76	44	473	16548
34029	38	481	60	60	1376	36134
46300	22	389	68	65	1232	55764
24760	28	565	71	55	1521	28910
18779	10	173	76	38	572	13339
21280	31	278	62	52	1059	25319
40662	32	609	61	60	1544	66956
28987	32	422	67	54	1230	47487
22827	43	445	88	86	1206	52785
18513	27	387	30	24	1205	44683
30594	37	339	64	52	1255	35619
24006	20	181	68	49	613	21920
27913	32	245	64	61	721	45608
42744	0	384	91	61	1109	7721
12934	5	212	88	81	740	20634
22574	26	399	52	43	1126	29788
41385	10	229	49	40	728	31931
18653	27	224	62	40	689	37754
18472	11	203	61	56	592	32505
30976	29	333	76	68	995	40557
63339	25	384	88	79	1613	94238
25568	55	636	66	47	2048	44197
33747	23	185	71	57	705	43228
4154	5	93	68	41	301	4103
19474	43	581	48	29	1803	44144
35130	23	248	25	3	799	32868
39067	34	304	68	60	861	27640
13310	36	344	41	30	1186	14063
65892	35	407	90	79	1451	28990
4143	0	170	66	47	628	4694
28579	37	312	54	40	1161	42648
51776	28	507	59	48	1463	64329
21152	16	224	60	36	742	21928
38084	26	340	77	42	979	25836
27717	38	168	68	49	675	22779
32928	23	443	72	57	1241	40820
11342	22	204	67	12	676	27530
19499	30	367	64	40	1049	32378
16380	16	210	63	43	620	10824
36874	18	335	59	33	1081	39613
48259	28	364	84	77	1688	60865
16734	32	178	64	43	736	19787
28207	21	206	56	45	617	20107
30143	23	279	54	47	812	36605
41369	29	387	67	43	1051	40961
45833	50	490	58	45	1656	48231
29156	12	238	59	50	705	39725
35944	21	343	40	35	945	21455
36278	18	232	22	7	554	23430
45588	27	530	83	71	1597	62991
45097	41	291	81	67	982	49363
3895	13	67	2	0	222	9604
28394	12	397	72	62	1212	24552
18632	21	467	61	54	1143	31493
2325	8	178	15	4	435	3439
25139	26	175	32	25	532	19555
27975	27	299	62	40	882	21228
14483	13	154	58	38	608	23177
13127	16	106	36	19	459	22094
5839	2	189	59	17	578	2342
24069	42	194	68	67	826	38798
3738	5	135	21	14	509	3255
18625	37	201	55	30	717	24261
36341	17	207	54	54	637	18511
24548	38	280	55	35	857	40798
21792	37	260	72	59	830	28893
26263	29	227	41	24	652	21425
23686	32	239	61	58	707	50276
49303	35	333	67	42	954	37643
25659	17	428	76	46	1461	30377
28904	20	230	64	61	672	27126
2781	7	292	3	3	778	13
29236	46	350	63	52	1141	42097
19546	24	186	40	25	680	24451
22818	40	326	69	40	1090	14335
32689	3	155	48	32	616	5084
5752	10	75	8	4	285	9927
22197	37	361	52	49	1145	43527
20055	17	261	66	63	733	27184
25272	28	299	76	67	888	21610
82206	19	300	43	32	849	20484
32073	29	450	39	23	1182	20156
5444	8	183	14	7	528	6012
20154	10	238	61	54	642	18475
36944	15	165	71	37	947	12645
8019	15	234	44	35	819	11017
30884	28	176	60	51	757	37623
19540	17	329	64	39	894	35873




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time5 seconds
R Server'AstonUniversity' @ aston.wessa.net
R Framework error message
The field 'Names of X columns' contains a hard return which cannot be interpreted.
Please, resubmit your request without hard returns in the 'Names of X columns'.

\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 & 5 seconds \tabularnewline
R Server & 'AstonUniversity' @ aston.wessa.net \tabularnewline
R Framework error message & 
The field 'Names of X columns' contains a hard return which cannot be interpreted.
Please, resubmit your request without hard returns in the 'Names of X columns'.
\tabularnewline \hline \end{tabular} %Source: https://freestatistics.org/blog/index.php?pk=159959&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]5 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'AstonUniversity' @ aston.wessa.net[/C][/ROW]
[ROW][C]R Framework error message[/C][C]
The field 'Names of X columns' contains a hard return which cannot be interpreted.
Please, resubmit your request without hard returns in the 'Names of X columns'.
[/C][/ROW] [/TABLE] Source: https://freestatistics.org/blog/index.php?pk=159959&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=159959&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 time5 seconds
R Server'AstonUniversity' @ aston.wessa.net
R Framework error message
The field 'Names of X columns' contains a hard return which cannot be interpreted.
Please, resubmit your request without hard returns in the 'Names of X columns'.







10-Fold Cross Validation
Prediction (training)Prediction (testing)
ActualC1C2CVC1C2CV
C112011010.9224137110.9257
C213411540.896201320.8684
Overall--0.9093--0.8967

\begin{tabular}{lllllllll}
\hline
10-Fold Cross Validation \tabularnewline
 & Prediction (training) & Prediction (testing) \tabularnewline
Actual & C1 & C2 & CV & C1 & C2 & CV \tabularnewline
C1 & 1201 & 101 & 0.9224 & 137 & 11 & 0.9257 \tabularnewline
C2 & 134 & 1154 & 0.896 & 20 & 132 & 0.8684 \tabularnewline
Overall & - & - & 0.9093 & - & - & 0.8967 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=159959&T=1

[TABLE]
[ROW][C]10-Fold Cross Validation[/C][/ROW]
[ROW][C][/C][C]Prediction (training)[/C][C]Prediction (testing)[/C][/ROW]
[ROW][C]Actual[/C][C]C1[/C][C]C2[/C][C]CV[/C][C]C1[/C][C]C2[/C][C]CV[/C][/ROW]
[ROW][C]C1[/C][C]1201[/C][C]101[/C][C]0.9224[/C][C]137[/C][C]11[/C][C]0.9257[/C][/ROW]
[ROW][C]C2[/C][C]134[/C][C]1154[/C][C]0.896[/C][C]20[/C][C]132[/C][C]0.8684[/C][/ROW]
[ROW][C]Overall[/C][C]-[/C][C]-[/C][C]0.9093[/C][C]-[/C][C]-[/C][C]0.8967[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=159959&T=1

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

As an alternative you can also use a QR Code:  

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

10-Fold Cross Validation
Prediction (training)Prediction (testing)
ActualC1C2CVC1C2CV
C112011010.9224137110.9257
C213411540.896201320.8684
Overall--0.9093--0.8967







Confusion Matrix (predicted in columns / actuals in rows)
C1C2
C113213
C213131

\begin{tabular}{lllllllll}
\hline
Confusion Matrix (predicted in columns / actuals in rows) \tabularnewline
 & C1 & C2 \tabularnewline
C1 & 132 & 13 \tabularnewline
C2 & 13 & 131 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=159959&T=2

[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]132[/C][C]13[/C][/ROW]
[ROW][C]C2[/C][C]13[/C][C]131[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=159959&T=2

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

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
C113213
C213131



Parameters (Session):
par1 = 1 ; par2 = quantiles ; par3 = 2 ; par4 = yes ;
Parameters (R input):
par1 = 1 ; par2 = quantiles ; par3 = 2 ; par4 = yes ;
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')
}