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, 06 Dec 2012 08:46:11 -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/2012/Dec/06/t13548018789cvzsjaqm7lbl27.htm/, Retrieved Fri, 29 Mar 2024 08:38:43 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=197079, Retrieved Fri, 29 Mar 2024 08:38:43 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact91
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 19:35:21] [b98453cac15ba1066b407e146608df68]
- R PD    [Recursive Partitioning (Regression Trees)] [WS 10 recursive p...] [2012-12-06 13:46:11] [b5e957cef4f8312b4131adee035e148e] [Current]
Feedback Forum

Post a new message
Dataseries X:
1418	210907	56	3	79	30	115	112285	24188	144	145
869	120982	56	4	58	28	109	84786	18273	103	101
1530	176508	54	12	60	38	146	83123	14130	98	98
2172	179321	89	2	108	30	116	101193	32287	135	132
901	123185	40	1	49	22	68	38361	8654	61	60
463	52746	25	3	0	26	101	68504	9245	39	38
3201	385534	92	0	121	25	96	119182	33251	150	144
371	33170	18	0	1	18	67	22807	1271	5	5
1192	101645	63	0	20	11	44	17140	5279	28	28
1583	149061	44	5	43	26	100	116174	27101	84	84
1439	165446	33	0	69	25	93	57635	16373	80	79
1764	237213	84	0	78	38	140	66198	19716	130	127
1495	173326	88	7	86	44	166	71701	17753	82	78
1373	133131	55	7	44	30	99	57793	9028	60	60
2187	258873	60	3	104	40	139	80444	18653	131	131
1491	180083	66	9	63	34	130	53855	8828	84	84
4041	324799	154	0	158	47	181	97668	29498	140	133
1706	230964	53	4	102	30	116	133824	27563	151	150
2152	236785	119	3	77	31	116	101481	18293	91	91
1036	135473	41	0	82	23	88	99645	22530	138	132
1882	202925	61	7	115	36	139	114789	15977	150	136
1929	215147	58	0	101	36	135	99052	35082	124	124
2242	344297	75	1	80	30	108	67654	16116	119	118
1220	153935	33	5	50	25	89	65553	15849	73	70
1289	132943	40	7	83	39	156	97500	16026	110	107
2515	174724	92	0	123	34	129	69112	26569	123	119
2147	174415	100	0	73	31	118	82753	24785	90	89
2352	225548	112	5	81	31	118	85323	17569	116	112
1638	223632	73	0	105	33	125	72654	23825	113	108
1222	124817	40	0	47	25	95	30727	7869	56	52
1812	221698	45	0	105	33	126	77873	14975	115	112
1677	210767	60	3	94	35	135	117478	37791	119	116
1579	170266	62	4	44	42	154	74007	9605	129	123
1731	260561	75	1	114	43	165	90183	27295	127	125
807	84853	31	4	38	30	113	61542	2746	27	27
2452	294424	77	2	107	33	127	101494	34461	175	162
829	101011	34	0	30	13	52	27570	8098	35	32
1940	215641	46	0	71	32	121	55813	4787	64	64
2662	325107	99	0	84	36	136	79215	24919	96	92
186	7176	17	0	0	0	0	1423	603	0	0
1499	167542	66	2	59	28	108	55461	16329	84	83
865	106408	30	1	33	14	46	31081	12558	41	41
1793	96560	76	0	42	17	54	22996	7784	47	47
2527	265769	146	2	96	32	124	83122	28522	126	120
2747	269651	67	10	106	30	115	70106	22265	105	105
1324	149112	56	6	56	35	128	60578	14459	80	79
2702	175824	107	0	57	20	80	39992	14526	70	65
1383	152871	58	5	59	28	97	79892	22240	73	70
1179	111665	34	4	39	28	104	49810	11802	57	55
2099	116408	61	1	34	39	59	71570	7623	40	39
4308	362301	119	2	76	34	125	100708	11912	68	67
918	78800	42	2	20	26	82	33032	7935	21	21
1831	183167	66	0	91	39	149	82875	18220	127	127
3373	277965	89	8	115	39	149	139077	19199	154	152
1713	150629	44	3	85	33	122	71595	19918	116	113
1438	168809	66	0	76	28	118	72260	21884	102	99
496	24188	24	0	8	4	12	5950	2694	7	7
2253	329267	259	8	79	39	144	115762	15808	148	141
744	65029	17	5	21	18	67	32551	3597	21	21
1161	101097	64	3	30	14	52	31701	5296	35	35
2352	218946	41	1	76	29	108	80670	25239	112	109
2144	244052	68	5	101	44	166	143558	29801	137	133
4691	341570	168	1	94	21	80	117105	18450	135	123
1112	103597	43	1	27	16	60	23789	7132	26	26
2694	233328	132	5	92	28	107	120733	34861	230	230
1973	256462	105	0	123	35	127	105195	35940	181	166
1769	206161	71	12	75	28	107	73107	16688	71	68
3148	311473	112	8	128	38	146	132068	24683	147	147
2474	235800	94	8	105	23	84	149193	46230	190	179
2084	177939	82	8	55	36	141	46821	10387	64	61
1954	207176	70	8	56	32	123	87011	21436	105	101
1226	196553	57	2	41	29	111	95260	30546	107	108
1389	174184	53	0	72	25	98	55183	19746	94	90
1496	143246	103	5	67	27	105	106671	15977	116	114
2269	187559	121	8	75	36	135	73511	22583	106	103
1833	187681	62	2	114	28	107	92945	17274	143	142
1268	119016	52	5	118	23	85	78664	16469	81	79
1943	182192	52	12	77	40	155	70054	14251	89	88
893	73566	32	6	22	23	88	22618	3007	26	25
1762	194979	62	7	66	40	155	74011	16851	84	83
1403	167488	45	2	69	28	104	83737	21113	113	113
1425	143756	46	0	105	34	132	69094	17401	120	118
1857	275541	63	4	116	33	127	93133	23958	110	110
1840	243199	75	3	88	28	108	95536	23567	134	129
1502	182999	88	6	73	34	129	225920	13065	54	51
1441	135649	46	2	99	30	116	62133	15358	96	93
1420	152299	53	0	62	33	122	61370	14587	78	76
1416	120221	37	1	53	22	85	43836	12770	51	49
2970	346485	90	0	118	38	147	106117	24021	121	118
1317	145790	63	5	30	26	99	38692	9648	38	38
1644	193339	78	2	100	35	87	84651	20537	145	141
870	80953	25	0	49	8	28	56622	7905	59	58
1654	122774	45	0	24	24	90	15986	4527	27	27
1054	130585	46	5	67	29	109	95364	30495	91	91
937	112611	41	0	46	20	78	26706	7117	48	48
3004	286468	144	1	57	29	111	89691	17719	68	63
2008	241066	82	0	75	45	158	67267	27056	58	56
2547	148446	91	1	135	37	141	126846	33473	150	144
1885	204713	71	1	68	33	122	41140	9758	74	73
1626	182079	63	2	124	33	124	102860	21115	181	168
1468	140344	53	6	33	25	93	51715	7236	65	64
2445	220516	62	1	98	32	124	55801	13790	97	97
1964	243060	63	4	58	29	112	111813	32902	121	117
1381	162765	32	2	68	28	108	120293	25131	99	100
1369	182613	39	3	81	28	99	138599	30910	152	149
1659	232138	62	0	131	31	117	161647	35947	188	187
2888	265318	117	10	110	52	199	115929	29848	138	127
1290	85574	34	0	37	21	78	24266	6943	40	37
2845	310839	92	9	130	24	91	162901	42705	254	245
1982	225060	93	7	93	41	158	109825	31808	87	87
1904	232317	54	0	118	33	126	129838	26675	178	177
1391	144966	144	0	39	32	122	37510	8435	51	49
602	43287	14	4	13	19	71	43750	7409	49	49
1743	155754	61	4	74	20	75	40652	14993	73	73
1559	164709	109	0	81	31	115	87771	36867	176	177
2014	201940	38	0	109	31	119	85872	33835	94	94
2143	235454	73	0	151	32	124	89275	24164	120	117
2146	220801	75	1	51	18	72	44418	12607	66	60
874	99466	50	0	28	23	91	192565	22609	56	55
1590	92661	61	1	40	17	45	35232	5892	39	39
1590	133328	55	0	56	20	78	40909	17014	66	64
1210	61361	77	0	27	12	39	13294	5394	27	26
2072	125930	75	4	37	17	68	32387	9178	65	64
1281	100750	72	0	83	30	119	140867	6440	58	58
1401	224549	50	4	54	31	117	120662	21916	98	95
834	82316	32	4	27	10	39	21233	4011	25	25
1105	102010	53	3	28	13	50	44332	5818	26	26
1272	101523	42	0	59	22	88	61056	18647	77	76
1944	243511	71	0	133	42	155	101338	20556	130	129
391	22938	10	0	12	1	0	1168	238	11	11
761	41566	35	5	0	9	36	13497	70	2	2
1605	152474	65	0	106	32	123	65567	22392	101	101
530	61857	25	4	23	11	32	25162	3913	31	28
1988	99923	66	0	44	25	99	32334	12237	36	36
1386	132487	41	0	71	36	136	40735	8388	120	89
2395	317394	86	1	116	31	117	91413	22120	195	193
387	21054	16	0	4	0	0	855	338	4	4
1742	209641	42	5	62	24	88	97068	11727	89	84
620	22648	19	0	12	13	39	44339	3704	24	23
449	31414	19	0	18	8	25	14116	3988	39	39
800	46698	45	0	14	13	52	10288	3030	14	14
1684	131698	65	0	60	19	75	65622	13520	78	78
1050	91735	35	0	7	18	71	16563	1421	15	14
2699	244749	95	2	98	33	124	76643	20923	106	101
1606	184510	49	7	64	40	151	110681	20237	83	82
1502	79863	37	1	29	22	71	29011	3219	24	24
1204	128423	64	8	32	38	145	92696	3769	37	36
1138	97839	38	2	25	24	87	94785	12252	77	75
568	38214	34	0	16	8	27	8773	1888	16	16
1459	151101	32	2	48	35	131	83209	14497	56	55
2158	272458	65	0	100	43	162	93815	28864	132	131
1111	172494	52	0	46	43	165	86687	21721	144	131
1421	108043	62	1	45	14	54	34553	4821	40	39
2833	328107	65	3	129	41	159	105547	33644	153	144
1955	250579	83	0	130	38	147	103487	15923	143	139
2922	351067	95	3	136	45	170	213688	42935	220	211
1002	158015	29	0	59	31	119	71220	18864	79	78
1060	98866	18	0	25	13	49	23517	4977	50	50
956	85439	33	0	32	28	104	56926	7785	39	39
2186	229242	247	4	63	31	120	91721	17939	95	90
3604	351619	139	4	95	40	150	115168	23436	169	166
1035	84207	29	11	14	30	112	111194	325	12	12
1417	120445	118	0	36	16	59	51009	13539	63	57
3261	324598	110	0	113	37	136	135777	34538	134	133
1587	131069	67	4	47	30	107	51513	12198	69	69
1424	204271	42	0	92	35	130	74163	26924	119	119
1701	165543	65	1	70	32	115	51633	12716	119	119
1249	141722	94	0	19	27	107	75345	8172	75	65
946	116048	64	0	50	20	75	33416	10855	63	61
1926	250047	81	0	41	18	71	83305	11932	55	49
3352	299775	95	9	91	31	120	98952	14300	103	101
1641	195838	67	1	111	31	116	102372	25515	197	196
2035	173260	63	3	41	21	79	37238	2805	16	15
2312	254488	83	10	120	39	150	103772	29402	140	136
1369	104389	45	5	135	41	156	123969	16440	89	89
1577	136084	30	0	27	13	51	27142	11221	40	40
2201	199476	70	2	87	32	118	135400	28732	125	123
961	92499	32	0	25	18	71	21399	5250	21	21
1900	224330	83	1	131	39	144	130115	28608	167	163
1254	135781	31	2	45	14	47	24874	8092	32	29
1335	74408	67	4	29	7	28	34988	4473	36	35
1597	81240	66	0	58	17	68	45549	1572	13	13
207	14688	10	0	4	0	0	6023	2065	5	5
1645	181633	70	2	47	30	110	64466	14817	96	96
2429	271856	103	1	109	37	147	54990	16714	151	151
151	7199	5	0	7	0	0	1644	556	6	6
474	46660	20	0	12	5	15	6179	2089	13	13
141	17547	5	0	0	1	4	3926	2658	3	3
1639	133368	36	1	37	16	64	32755	10695	57	56
872	95227	34	0	37	32	111	34777	1669	23	23
1318	152601	48	2	46	24	85	73224	16267	61	57
1018	98146	40	0	15	17	68	27114	7768	21	14
1383	79619	43	3	42	11	40	20760	7252	43	43
1314	59194	31	6	7	24	80	37636	6387	20	20
1335	139942	42	0	54	22	88	65461	18715	82	72
1403	118612	46	2	54	12	48	30080	7936	90	87
910	72880	33	0	14	19	76	24094	8643	25	21
616	65475	18	2	16	13	51	69008	7294	60	56
1407	99643	55	1	33	17	67	54968	4570	61	59
771	71965	35	1	32	15	59	46090	7185	85	82
766	77272	59	2	21	16	61	27507	10058	43	43
473	49289	19	1	15	24	76	10672	2342	25	25
1376	135131	66	0	38	15	60	34029	8509	41	38
1232	108446	60	1	22	17	68	46300	13275	26	25
1521	89746	36	3	28	18	71	24760	6816	38	38
572	44296	25	0	10	20	76	18779	1930	12	12
1059	77648	47	0	31	16	62	21280	8086	29	29
1544	181528	54	0	32	16	61	40662	10737	49	47
1230	134019	53	0	32	18	67	28987	8033	46	45
1206	124064	40	1	43	22	88	22827	7058	41	40
1205	92630	40	4	27	8	30	18513	6782	31	30
1255	121848	39	0	37	17	64	30594	5401	41	41
613	52915	14	0	20	18	68	24006	6521	26	25
721	81872	45	0	32	16	64	27913	10856	23	23
1109	58981	36	7	0	23	91	42744	2154	14	14
740	53515	28	2	5	22	88	12934	6117	16	16
1126	60812	44	0	26	13	52	22574	5238	25	26
728	56375	30	7	10	13	49	41385	4820	21	21
689	65490	22	3	27	16	62	18653	5615	32	27
592	80949	17	0	11	16	61	18472	4272	9	9
995	76302	31	0	29	20	76	30976	8702	35	33
1613	104011	55	6	25	22	88	63339	15340	42	42
2048	98104	54	2	55	17	66	25568	8030	68	68
705	67989	21	0	23	18	71	33747	9526	32	32
301	30989	14	0	5	17	68	4154	1278	6	6
1803	135458	81	3	43	12	48	19474	4236	68	67
799	73504	35	0	23	7	25	35130	3023	33	33
861	63123	43	1	34	17	68	39067	7196	84	77
1186	61254	46	1	36	14	41	13310	3394	46	46
1451	74914	30	0	35	23	90	65892	6371	30	30
628	31774	23	1	0	17	66	4143	1574	0	0
1161	81437	38	0	37	14	54	28579	9620	36	36
1463	87186	54	0	28	15	59	51776	6978	47	46
742	50090	20	0	16	17	60	21152	4911	20	18
979	65745	53	0	26	21	77	38084	8645	50	48
675	56653	45	0	38	18	68	27717	8987	30	29
1241	158399	39	0	23	18	72	32928	5544	30	28
676	46455	20	0	22	17	67	11342	3083	34	34
1049	73624	24	0	30	17	64	19499	6909	33	33
620	38395	31	0	16	16	63	16380	3189	34	34
1081	91899	35	0	18	15	59	36874	6745	37	33
1688	139526	151	0	28	21	84	48259	16724	83	80
736	52164	52	0	32	16	64	16734	4850	32	32
617	51567	30	2	21	14	56	28207	7025	30	30
812	70551	31	0	23	15	54	30143	6047	43	41
1051	84856	29	1	29	17	67	41369	7377	41	41
1656	102538	57	1	50	15	58	45833	9078	51	51
705	86678	40	0	12	15	59	29156	4605	19	18
945	85709	44	0	21	10	40	35944	3238	37	34
554	34662	25	0	18	6	22	36278	8100	33	31
1597	150580	77	0	27	22	83	45588	9653	41	39
982	99611	35	0	41	21	81	45097	8914	54	54
222	19349	11	0	13	1	2	3895	786	14	14
1212	99373	63	1	12	18	72	28394	6700	25	24
1143	86230	44	0	21	17	61	18632	5788	25	24
435	30837	19	0	8	4	15	2325	593	8	8
532	31706	13	0	26	10	32	25139	4506	26	26
882	89806	42	0	27	16	62	27975	6382	20	19
608	62088	38	1	13	16	58	14483	5621	11	11
459	40151	29	0	16	9	36	13127	3997	14	14
578	27634	20	0	2	16	59	5839	520	3	1
826	76990	27	0	42	17	68	24069	8891	40	39
509	37460	20	0	5	7	21	3738	999	5	5
717	54157	19	0	37	15	55	18625	7067	38	37
637	49862	37	0	17	14	54	36341	4639	32	32
857	84337	26	0	38	14	55	24548	5654	41	38
830	64175	42	0	37	18	72	21792	6928	46	47
652	59382	49	0	29	12	41	26263	1514	47	47
707	119308	30	0	32	16	61	23686	9238	37	37
954	76702	49	0	35	21	67	49303	8204	51	51
1461	103425	67	1	17	19	76	25659	5926	49	45
672	70344	28	0	20	16	64	28904	5785	21	21
778	43410	19	0	7	1	3	2781	4	1	1
1141	104838	49	1	46	16	63	29236	5930	44	42
680	62215	27	0	24	10	40	19546	3710	26	26
1090	69304	30	6	40	19	69	22818	705	21	21
616	53117	22	3	3	12	48	32689	443	4	4
285	19764	12	1	10	2	8	5752	2416	10	10
1145	86680	31	2	37	14	52	22197	7747	43	43
733	84105	20	0	17	17	66	20055	5432	34	34
888	77945	20	0	28	19	76	25272	4913	32	31
849	89113	39	0	19	14	43	82206	2650	20	19
1182	91005	29	3	29	11	39	32073	2370	34	34
528	40248	16	1	8	4	14	5444	775	6	6
642	64187	27	0	10	16	61	20154	5576	12	11
947	50857	21	0	15	20	71	36944	1352	24	24
819	56613	19	1	15	12	44	8019	3080	16	16
757	62792	35	0	28	15	60	30884	10205	72	72
894	72535	14	0	17	16	64	19540	6095	27	21




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time8 seconds
R Server'Herman Ole Andreas Wold' @ wold.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 & 8 seconds \tabularnewline
R Server & 'Herman Ole Andreas Wold' @ wold.wessa.net \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=197079&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]8 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'Herman Ole Andreas Wold' @ wold.wessa.net[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=197079&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=197079&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 time8 seconds
R Server'Herman Ole Andreas Wold' @ wold.wessa.net







Confusion Matrix (predicted in columns / actuals in rows)
C1C2
C112025
C28136

\begin{tabular}{lllllllll}
\hline
Confusion Matrix (predicted in columns / actuals in rows) \tabularnewline
 & C1 & C2 \tabularnewline
C1 & 120 & 25 \tabularnewline
C2 & 8 & 136 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=197079&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]120[/C][C]25[/C][/ROW]
[ROW][C]C2[/C][C]8[/C][C]136[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=197079&T=1

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



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