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 computationTue, 13 Dec 2011 11:59:02 -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/13/t1323795637axa4e4g2konxwsu.htm/, Retrieved Fri, 03 May 2024 02:45:59 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=154543, Retrieved Fri, 03 May 2024 02:45:59 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact306
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 20:30:15] [b98453cac15ba1066b407e146608df68]
- R PD    [Recursive Partitioning (Regression Trees)] [] [2011-12-13 16:59:02] [885a9dbaf162325773a0a0afdf9f947e] [Current]
Feedback Forum

Post a new message
Dataseries X:
58,58527778	145	30	94	112285	14,36009776	1
33,60611111	101	28	103	84786	11,30900293	1
49,03	98	38	93	83123	12,45810893	1
49,81138889	132	30	103	101193	13,50394283	1
34,21805556	60	22	51	38361	7,219358341	1
14,65166667	38	26	70	68504	7,381367182	1
107,0927778	144	25	91	119182	15,26096233	1
9,213888889	5	18	22	22807	3,165415029	1
41,40583333	84	26	93	116174	11,78143911	1
45,95722222	79	25	60	57635	9,277808364	1
65,8925	127	38	123	66198	14,22780485	1
48,14611111	78	44	148	71701	13,3753608	1
36,98083333	60	30	90	57793	9,487750499	1
71,90916667	131	40	124	80444	15,21511671	1
50,02305556	84	34	70	53855	10,42712012	1
90,22194444	133	47	168	97668	17,84978648	1
64,15666667	150	30	115	133824	15,89534882	1
65,77361111	91	31	71	101481	12,55115438	1
37,63138889	132	23	66	99645	11,43396085	1
56,36805556	136	36	134	114789	15,53507626	1
59,76305556	124	36	117	99052	14,52239325	1
95,63805556	118	30	108	67654	13,89331579	1
42,75972222	70	25	84	65553	9,712278591	1
36,92861111	107	39	156	97500	14,12942504	1
48,53444444	119	34	120	69112	12,89537363	1
48,44861111	89	31	114	82753	12,1602659	1
62,65222222	112	31	94	85323	13,01181689	1
62,12	108	33	120	72654	13,29873685	1
34,67138889	52	25	81	30727	7,775415068	1
61,58277778	112	33	110	77873	13,28429728	1
58,54638889	116	35	133	117478	15,11451039	1
47,29611111	123	42	122	74007	13,74797244	1
72,37805556	125	43	158	90183	16,42942616	1
23,57027778	27	30	109	61542	8,584377305	1
81,78444444	162	33	124	101494	16,47410685	1
59,90027778	64	32	92	55813	10,83539947	1
90,3075	92	36	126	79215	14,48035784	1
46,53944444	83	28	70	55461	9,817153316	1
29,55777778	41	14	37	31081	5,345232896	1
73,82472222	120	32	120	83122	14,39310875	1
74,90305556	105	30	93	70106	12,87630593	1
41,42	79	35	95	60578	10,76877965	1
42,46416667	70	28	90	79892	10,49694082	1
31,01805556	55	28	80	49810	8,443671407	1
32,33555556	39	39	31	71570	8,407782836	1
100,6391667	67	34	110	100708	13,94065255	1
21,88888889	21	26	66	33032	6,16326461	1
50,87972222	127	39	138	82875	14,43688293	1
77,2125	152	39	133	139077	17,77583855	1
41,84138889	113	33	113	71595	12,2486023	1
46,89138889	99	28	100	72260	11,45685566	1
6,718888889	7	4	7	5950	1,153093302	1
91,46305556	141	39	140	115762	17,35686844	1
18,06361111	21	18	61	32551	5,224652076	1
28,0825	35	14	41	31701	5,238696901	1
60,81833333	109	29	96	80670	12,60523152	1
67,79222222	133	44	164	143558	17,98404039	1
64,81333333	230	28	102	120733	15,30279334	1
71,23944444	166	35	124	105195	16,2306506	1
57,26694444	68	28	99	73107	11,17728596	1
86,52027778	147	38	129	132068	17,64250157	1
65,5	179	23	62	149193	14,43288916	1
49,4275	61	36	73	46821	9,841441509	1
57,54888889	101	32	114	87011	13,10185804	1
54,59805556	108	29	99	95260	12,78229154	1
48,38444444	90	25	70	55183	9,841353028	1
39,79055556	114	27	104	106671	12,52267132	1
52,09972222	103	36	116	73511	12,85177133	1
52,13361111	142	28	91	92945	13,17889823	1
33,06	79	23	74	78664	9,459926349	1
50,60888889	88	40	138	70054	13,14460233	1
20,435	25	23	67	22618	5,679993974	1
54,16083333	83	40	151	74011	13,621099	1
46,52444444	113	28	72	83737	11,4493559	1
39,93222222	118	34	120	69094	12,45612266	1
76,53916667	110	33	115	93133	14,52255588	1
67,55527778	129	28	105	95536	14,00916003	1
50,83305556	51	34	104	225920	12,87917848	1
37,68027778	93	30	108	62133	10,91453539	1
42,30527778	76	33	98	61370	10,67710167	1
33,39472222	49	22	69	43836	7,500506329	1
96,24583333	118	38	111	106117	15,71511893	1
40,49722222	38	26	99	38692	8,451414364	1
53,70527778	141	35	71	84651	13,04281114	1
22,48694444	58	8	27	56622	5,475735648	1
34,10388889	27	24	69	15986	6,318561991	1
36,27361111	91	29	107	95364	11,67102852	1
79,57444444	63	29	107	89691	12,88262502	1
66,96277778	56	45	93	67267	12,34103121	1
41,235	144	37	129	126846	15,31887313	1
56,86472222	73	33	69	41140	10,00450285	1
50,5775	168	33	118	102860	14,86835659	1
38,98444444	64	25	73	51715	8,706868119	1
61,25444444	97	32	119	55801	12,38401963	1
67,51666667	117	29	104	111813	14,23699191	1
45,2125	100	28	107	120293	12,98177075	1
50,72583333	149	28	99	138599	14,75112225	1
64,48277778	187	31	90	161647	15,68212424	1
73,69944444	127	52	197	115929	18,1400865	1
86,34416667	245	24	85	162901	15,91867058	1
62,51666667	87	41	139	109825	14,96179352	1
64,5325	177	33	106	129838	16,04078615	1
40,26833333	49	32	50	37510	7,958769343	1
12,02416667	49	19	64	43750	6,117022453	1
43,265	73	20	31	40652	7,408636579	1
45,7525	177	31	63	87771	12,70501195	1
56,09444444	94	31	92	85872	12,21180573	1
65,40388889	117	32	106	89275	13,7541755	1
27,62944444	55	23	69	192565	10,16398398	1
27,98611111	58	30	93	140867	11,38027871	1
62,37472222	95	31	114	120662	14,09406222	1
67,64194444	129	42	110	101338	15,38882422	1
6,371666667	11	1	0	1168	0,694512385	1
42,35388889	101	32	83	65567	10,98992814	1
17,1825	28	11	30	25162	3,847727223	1
36,80194444	89	36	98	40735	10,36537965	1
88,165	193	31	82	91413	15,07282766	1
5,848333333	4	0	0	855	0,406821823	1
58,23361111	84	24	60	97068	11,07449882	1
8,726111111	39	8	9	14116	2,651799226	1
67,98583333	101	33	115	76643	13,40079885	1
51,25277778	82	40	140	110681	14,266541	1
35,67305556	36	38	120	92696	11,1935173	1
27,1775	75	24	66	94785	9,43355457	1
10,615	16	8	21	8773	2,298582242	1
41,9725	55	35	124	83209	11,55994194	1
75,68277778	131	43	152	93815	16,70032444	1
47,915	131	43	139	86687	14,84074833	1
91,14083333	144	41	144	105547	17,38403831	1
69,60527778	139	38	120	103487	15,73039586	1
97,51861111	211	45	160	213688	19,36265885	1
43,89305556	78	31	114	71220	11,32605381	1
23,73305556	39	28	78	56926	7,851840967	1
63,67833333	90	31	119	91721	13,30225262	1
97,67194444	166	40	141	115168	17,89762797	1
23,39083333	12	30	101	111194	9,46320715	1
90,16611111	133	37	133	135777	17,41915883	1
36,40805556	69	30	83	51513	9,332238773	1
56,74194444	119	35	116	74163	13,4187927	1
45,98416667	119	32	90	51633	11,37725913	1
39,36722222	65	27	36	75345	8,702323456	1
83,27083333	101	31	97	98952	14,19611665	1
54,39944444	196	31	98	102372	14,3980936	1
48,12777778	15	21	78	37238	7,301383906	1
70,69111111	136	39	117	103772	15,72027262	1
28,99694444	89	41	148	123969	14,03405468	1
55,41	123	32	105	135400	14,75498272	1
62,31388889	163	39	132	130115	17,03707132	1
4,08	5	0	0	6023	0,498724543	1
50,45361111	96	30	73	64466	10,82410397	1
75,51555556	151	37	86	54990	13,99003257	1
1,999722222	6	0	0	1644	0,295218143	1
12,96111111	13	5	13	6179	1,833602184	1
4,874166667	3	1	4	3926	0,59944272	1
26,45194444	23	32	48	34777	6,512322257	1
42,38916667	57	24	46	73224	8,594439161	1
28,23472222	28	11	38	17140	10,17463007	0
28,05861111	32	13	39	27570	11,70685947	0
1,993333333	0	0	0	1423	0,336629956	0
26,82222222	47	17	38	22996	12,81545815	0
48,84	65	20	77	39992	18,48134929	0
94,88055556	123	21	78	117105	19,15	0
28,77694444	26	16	49	23789	11,98976509	0
31,28083333	48	20	73	26706	15,96311694	0
23,77055556	37	21	36	24266	12,36867636	0
61,33361111	60	18	63	44418	17,85359417	0
25,73916667	39	17	41	35232	13,33972078	0
37,03555556	64	20	56	40909	17,43586247	0
17,04472222	26	12	25	13294	7,971763963	0
34,98055556	64	17	65	32387	16,49423975	0
22,86555556	25	10	38	21233	9,589676646	0
28,33611111	26	13	44	44332	13,0201353	0
28,20083333	76	22	87	61056	18,30998406	0
11,54611111	2	9	27	13497	5,311440585	0
27,75638889	36	25	80	32334	16,14544025	0
6,291111111	23	13	28	44339	9,61483208	0
12,97166667	14	13	33	10288	6,97001928	0
36,58277778	78	19	59	65622	17,8328823	0
25,48194444	14	18	49	16563	10,43631816	0
22,18416667	24	22	49	29011	12,49521893	0
30,01194444	39	14	38	34553	13,13014142	0
27,46277778	50	13	39	23517	12,5995365	0
33,45694444	57	16	56	51009	16,89272827	0
32,23555556	61	20	50	33416	15,95822221	0
69,4575	49	18	61	83305	17,44624506	0
37,80111111	40	13	41	27142	13,36096345	0
25,69416667	21	18	55	21399	11,70208318	0
37,71694444	29	14	44	24874	12,6700532	0
20,66888889	35	7	21	34988	9,942922584	0
22,56666667	13	17	50	45549	12,47787034	0
37,04666667	56	16	57	32755	16,1794073	0
27,26277778	14	17	48	27114	11,34269609	0
22,11638889	43	11	32	20760	10,61458743	0
16,44277778	20	24	68	37636	13,63362964	0
38,87277778	72	22	87	65461	19,3	0
32,94777778	87	12	43	30080	14,17862044	0
20,24444444	21	19	67	24094	12,13110302	0
18,1875	56	13	46	69008	14,29122225	0
27,67861111	59	17	46	54968	15,90424527	0
19,99027778	82	15	56	46090	15,30537883	0
21,46444444	43	16	48	27507	12,71711954	0
13,69138889	25	24	44	10672	10,1041787	0
37,53638889	38	15	60	34029	15,10633448	0
30,12388889	25	17	65	46300	14,97472539	0
24,92944444	38	18	55	24760	13,14940394	0
12,30444444	12	20	38	18779	8,803370342	0
21,56888889	29	16	52	21280	11,37671367	0
50,42444444	47	16	60	40662	16,48829016	0
37,2275	45	18	54	28987	15,28690517	0
34,46222222	40	22	86	22827	15,87449367	0
25,73055556	30	8	24	18513	8,991891655	0
33,84666667	41	17	52	30594	14,52069002	0
14,69861111	25	18	49	24006	10,73329293	0
22,74222222	23	16	61	27913	12,11255989	0
16,38361111	14	23	61	42744	13,12039076	0
14,86527778	16	22	81	12934	11,17618446	0
16,89222222	26	13	43	22574	9,852452086	0
15,65972222	21	13	40	41385	10,83826353	0
18,19166667	27	16	40	18653	10,01602482	0
22,48583333	9	16	56	18472	9,98429329	0
21,195	33	20	68	30976	13,90654664	0
28,89194444	42	22	79	63339	17,43829448	0
27,25111111	68	17	47	25568	14,13651406	0
18,88583333	32	18	57	33747	12,95465875	0
8,608055556	6	17	41	4154	6,405875596	0
37,62722222	67	12	29	19474	13,00827743	0
20,41777778	33	7	3	35130	8,843896805	0
17,53416667	77	17	60	39067	14,95275123	0
17,015	46	14	30	13310	9,985399433	0
20,80944444	30	23	79	65892	15,85289071	0
8,826111111	0	17	47	4143	6,304871788	0
22,62138889	36	14	40	28579	11,70744131	0
24,21833333	46	15	48	51776	14,6847188	0
13,91388889	18	17	36	21152	9,063740747	0
18,2625	48	21	42	38084	14,09669644	0
15,73694444	29	18	49	27717	11,45807414	0
43,99972222	28	18	57	32928	14,5766967	0
12,90416667	34	17	12	11342	8,013459929	0
20,45111111	33	17	40	19499	10,91719297	0
10,66527778	34	16	43	16380	9,680449615	0
25,5275	33	15	33	36874	12,30631181	0
38,75722222	80	21	77	48259	19,15	0
14,49	32	16	43	16734	9,974038576	0
14,32416667	30	14	45	28207	10,61396958	0
19,5975	41	15	47	30143	12,39969169	0
23,57111111	41	17	43	41369	13,89235106	0
28,48277778	51	15	45	45833	15,3368091	0
24,07722222	18	15	50	29156	11,27570477	0
23,80805556	34	10	35	35944	11,46890639	0
9,628333333	31	6	7	36278	7,705473469	0
41,82777778	39	22	71	45588	17,80919895	0
27,66972222	54	21	67	45097	17,4519668	0
5,374722222	14	1	0	3895	2,080910919	0
27,60361111	24	18	62	28394	13,09820752	0
23,95277778	24	17	54	18632	11,29135539	0
8,565833333	8	4	4	2325	2,507172277	0
8,807222222	26	10	25	25139	7,823664497	0
24,94611111	19	16	40	27975	10,96662538	0
17,24666667	11	16	38	14483	8,284173862	0
11,15305556	14	9	19	13127	5,69261529	0
7,676111111	1	16	17	5839	4,687276457	0
21,38611111	39	17	67	24069	13,25987215	0
10,40555556	5	7	14	3738	3,580093526	0
15,04361111	37	15	30	18625	9,733116837	0
13,85055556	32	14	54	36341	11,88651299	0
23,42694444	38	14	35	24548	11,3271032	0
17,82638889	47	18	59	21792	12,99614065	0
16,495	47	12	24	26263	10,51715507	0
33,14111111	37	16	58	23686	13,71616844	0
21,30611111	51	21	42	49303	15,32447894	0
28,72916667	45	19	46	25659	13,82274766	0
19,54	21	16	61	28904	11,71158746	0
12,05833333	1	1	3	2781	1,908370816	0
29,12166667	42	16	52	29236	13,82088431	0
17,28194444	26	10	25	19546	8,241327352	0
19,25111111	21	19	40	22818	10,5053078	0
14,75472222	4	12	32	32689	8,180917703	0
5,49	10	2	4	5752	2,322655495	0
24,07777778	43	14	49	22197	12,28598307	0
23,3625	34	17	63	20055	12,54906448	0
21,65138889	31	19	67	25272	13,11109062	0
24,75361111	19	14	32	82206	11,7934321	0
25,27916667	34	11	23	32073	10,81286184	0
11,18	6	4	7	5444	3,068772109	0
17,82972222	11	16	54	20154	9,674855276	0
14,12694444	24	20	37	36944	11,39973018	0
15,72583333	16	12	35	8019	7,166265475	0
17,44222222	72	15	51	30884	13,46103292	0
20,14861111	21	16	39	19540	9,81357389	0




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

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







10-Fold Cross Validation
Prediction (training)Prediction (testing)
ActualC1C2CVC1C2CV
C1582860.871361110.8472
C29418300.9511212050.9071
Overall--0.9306--0.8926

\begin{tabular}{lllllllll}
\hline
10-Fold Cross Validation \tabularnewline
 & Prediction (training) & Prediction (testing) \tabularnewline
Actual & C1 & C2 & CV & C1 & C2 & CV \tabularnewline
C1 & 582 & 86 & 0.8713 & 61 & 11 & 0.8472 \tabularnewline
C2 & 94 & 1830 & 0.9511 & 21 & 205 & 0.9071 \tabularnewline
Overall & - & - & 0.9306 & - & - & 0.8926 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=154543&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]582[/C][C]86[/C][C]0.8713[/C][C]61[/C][C]11[/C][C]0.8472[/C][/ROW]
[ROW][C]C2[/C][C]94[/C][C]1830[/C][C]0.9511[/C][C]21[/C][C]205[/C][C]0.9071[/C][/ROW]
[ROW][C]Overall[/C][C]-[/C][C]-[/C][C]0.9306[/C][C]-[/C][C]-[/C][C]0.8926[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=154543&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=154543&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
C1582860.871361110.8472
C29418300.9511212050.9071
Overall--0.9306--0.8926







Confusion Matrix (predicted in columns / actuals in rows)
C1C2
C15816
C24211

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

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



Parameters (Session):
par1 = 0 ;
Parameters (R input):
par1 = 6 ; par2 = equal ; 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')
}