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 computationWed, 14 Dec 2011 11:05:28 -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/14/t1323878744ugj19lpp994z7zn.htm/, Retrieved Wed, 01 May 2024 21:13:31 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=155101, Retrieved Wed, 01 May 2024 21:13:31 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact83
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)] [] [2011-12-14 16:05:28] [87b6e955a128bfb8d1e350b3ce0d281e] [Current]
Feedback Forum

Post a new message
Dataseries X:
1587	252101	62	438	85	3	92	34	131	104	124252	25695	165119	147	148
951	134577	59	330	58	4	58	30	117	111	98956	19967	107269	126	124
1669	198520	62	609	51	14	62	38	146	93	98073	14338	93497	108	108
2283	189326	94	1015	131	2	108	34	132	119	106816	34117	100269	145	142
992	137449	43	294	44	1	55	25	80	57	41449	9713	91627	68	66
577	65295	27	164	42	3	8	31	117	80	76173	10024	47552	49	47
3916	439387	103	1912	94	0	134	29	112	107	177551	39981	233933	171	163
381	33186	19	111	46	0	1	18	67	22	22807	1271	6853	5	5
1790	178368	51	698	71	5	64	30	116	103	126938	30207	104380	106	106
1606	186657	38	556	65	0	77	29	107	72	61680	18035	98431	88	87
1886	261949	96	711	74	0	86	38	140	123	72117	21609	156949	145	141
1645	191051	95	495	55	7	93	49	186	164	79738	19836	81817	93	88
1433	138866	57	544	55	7	44	33	109	100	57793	9028	59238	60	60
2370	296878	66	959	98	3	106	46	159	143	91677	21750	101138	145	145
1645	192648	72	540	41	9	63	38	146	79	64631	10038	107158	95	95
4206	333462	162	1486	115	0	160	52	201	183	106385	30276	155499	144	137
1780	243571	58	635	45	4	104	32	124	123	161961	34972	156274	179	177
2352	263451	130	940	80	3	86	35	131	81	112669	19954	121777	102	102
1262	155679	48	452	37	3	93	25	96	74	114029	28113	105037	157	151
2026	227053	70	617	50	7	119	42	163	158	124550	18830	118661	170	156
2109	240028	63	695	93	0	107	40	151	133	105416	37144	131187	140	140
2451	388549	90	1046	93	1	86	35	128	128	72875	17916	145026	133	130
1253	156540	34	405	56	5	50	25	89	84	81964	16186	107016	74	71
1431	148421	43	477	57	9	92	46	184	184	104880	19195	87242	120	116
2631	177732	97	1012	138	0	123	36	136	127	76302	29124	91699	134	129
2293	191441	105	842	67	0	81	35	134	128	96740	29813	110087	108	107
2653	249893	122	994	88	5	93	38	146	118	93071	20270	145447	132	128
1709	236812	76	530	54	0	113	35	130	125	78912	26105	143307	125	119
1360	142329	45	515	47	0	52	28	105	89	35224	9155	61678	66	62
2051	259667	53	766	121	0	113	37	142	122	90694	18113	210080	130	124
1921	231625	65	734	44	3	112	40	155	151	125369	40546	165005	143	140
1623	176062	67	551	73	4	44	42	154	122	80849	10096	97806	150	144
1933	286683	79	718	49	1	123	44	169	162	104434	32338	184471	152	150
849	87485	33	280	36	4	38	33	125	121	65702	2871	27786	28	28
2641	322865	83	1055	61	2	111	35	135	132	108179	36592	184458	190	177
2235	247082	51	950	77	0	77	37	139	110	63583	4914	98765	73	73
2951	346011	106	1038	69	0	92	39	145	135	95066	30190	178441	115	111
1666	191653	74	552	63	2	74	32	124	80	62486	18153	100619	101	98
917	114673	31	275	36	1	33	17	55	46	31081	12558	58391	41	41
2745	284224	161	986	39	2	105	34	131	127	94584	32894	151672	147	139
2897	284195	72	1336	34	10	108	33	125	103	87408	24138	124437	107	107
1413	155363	59	565	65	6	66	35	128	95	68966	16628	79929	103	102
1535	177306	67	571	78	5	69	32	107	100	88766	26369	123064	84	80
1452	144571	49	404	67	5	62	35	130	102	57139	14171	50466	68	66
2369	140319	73	985	82	1	50	45	73	45	90586	8500	100991	52	51
4908	405267	135	1851	780	2	91	38	138	122	109249	11940	79367	70	69
918	78800	42	330	57	2	20	26	82	66	33032	7935	56968	21	21
2085	201970	69	611	72	0	101	45	173	159	96056	19456	106257	155	155
3655	302674	99	1249	112	9	129	44	169	153	146648	21347	178412	165	163
1923	164733	50	812	61	3	93	40	145	131	80613	24095	98520	124	121
1616	194221	68	501	39	0	89	33	134	113	87026	26204	153670	121	118
496	24188	24	218	20	0	8	4	12	7	5950	2694	15049	7	7
2328	342263	279	785	73	8	79	41	151	147	131106	20366	174478	161	154
744	65029	17	255	21	5	21	18	67	61	32551	3597	25109	21	21
1161	101097	64	454	70	3	30	14	52	41	31701	5296	45824	35	35
2598	246088	46	944	118	1	86	33	121	108	91072	29463	116772	125	122
2276	273108	75	600	72	5	116	49	186	184	159803	35838	189150	157	152
3185	282220	160	977	196	5	106	32	120	115	143950	42590	194404	256	255
2135	273495	119	863	58	0	127	37	135	132	112368	38665	185881	192	177
1863	214872	74	690	67	12	75	32	123	113	82124	19442	67508	86	83
3524	335121	124	1176	60	9	138	41	158	141	144068	25515	188597	164	164
2760	267171	106	1013	138	11	114	25	90	65	162627	51318	203618	213	202
2187	187938	88	890	69	9	55	40	157	87	55062	11807	87232	80	77
2161	229512	78	777	45	8	67	35	135	121	95329	24130	110875	122	118
1302	209798	61	521	54	2	45	33	125	112	105612	34053	144756	122	123
1540	201345	60	409	55	0	88	28	110	81	62853	22641	129825	113	109
1618	163833	114	493	46	6	67	31	121	116	125976	18898	92189	128	126
2403	204250	129	757	84	8	75	40	151	132	79146	24539	121158	117	114
1961	197813	67	736	71	2	114	32	123	104	108461	21664	96219	162	161
1402	132955	60	511	56	5	123	25	92	80	99971	21577	84128	87	85
2292	216092	59	789	55	13	86	42	162	145	77826	16643	97960	103	101
893	73566	32	385	39	6	22	23	88	67	22618	3007	23824	26	25
1935	213198	67	644	52	7	67	42	163	159	84892	18798	103515	104	102
1586	181713	49	664	94	2	77	38	133	90	92059	24648	91313	127	126
1494	148698	49	505	57	0	105	34	132	120	77993	20286	85407	132	130
1995	300103	70	878	82	4	119	38	144	126	104155	23999	95871	112	112
1904	251437	78	769	42	3	88	32	124	118	109840	26813	143846	155	150
1711	197295	101	499	45	6	78	37	140	112	238712	14718	155387	57	54
1746	158163	55	546	52	2	112	34	132	123	67486	16963	74429	109	106
1473	155529	57	551	63	0	66	33	122	98	68007	16673	74004	92	90
1538	132672	41	565	38	1	58	25	97	78	48194	14646	71987	57	55
3324	377205	100	1086	108	0	132	40	155	119	134796	31772	150629	145	139
1356	145905	66	649	45	5	30	26	99	99	38692	9648	68580	38	38
1931	223701	86	540	53	2	100	40	106	81	93587	23096	119855	152	148
870	80953	25	437	31	0	49	8	28	27	56622	7905	55792	59	58
1716	130805	47	732	169	0	26	27	101	77	15986	4527	25157	27	27
1091	135082	48	308	60	5	67	32	120	118	113402	37432	90895	104	104
3187	300805	156	1237	271	1	57	33	127	122	97967	21082	117510	80	75
2240	271806	95	783	84	0	95	50	178	103	74844	30437	144774	76	73
2677	150949	96	933	63	1	139	37	141	129	136051	36288	77529	163	157
2038	225805	79	710	54	1	73	33	122	69	50548	12369	103123	89	87
1783	197389	68	563	65	2	134	34	127	121	112215	23774	104669	199	186
1560	156583	56	508	80	6	37	28	102	81	59591	8108	82414	89	88
2540	222599	66	936	84	1	98	32	124	119	59938	15049	82390	107	107
2118	261601	70	838	115	4	58	32	124	116	137639	36021	128446	137	131
1521	178489	35	523	60	3	78	32	124	123	143372	30391	111542	123	123
1460	200657	43	500	62	3	88	31	111	111	138599	30910	136048	152	149
1866	259084	68	691	57	0	142	35	129	100	174110	40656	197257	202	201
3312	313075	130	1060	121	11	127	58	223	221	135062	35070	162079	159	145
3135	346933	100	1232	69	12	139	27	102	95	175681	47250	206286	282	273
2232	246440	104	735	60	8	108	45	174	153	130307	36236	109858	111	111
2061	252444	58	757	81	0	128	37	141	118	139141	29601	182125	197	195
1787	159965	159	574	100	0	62	32	122	50	44244	10443	74168	72	69
602	43287	14	214	43	4	13	19	71	64	43750	7409	19630	49	49
1973	172239	68	661	72	4	89	22	81	34	48029	18213	88634	82	82
1739	183738	120	631	61	0	83	35	131	76	95216	40856	128321	192	193
2282	227681	43	1015	101	0	116	36	139	112	92288	36471	118936	102	102
2339	260464	81	893	50	0	157	36	137	115	94588	26077	127044	127	124
923	106288	54	293	32	0	28	23	91	69	197426	24797	178377	60	59
1389	109632	77	446	74	0	83	36	142	108	151244	6816	69581	61	61
1673	268905	58	538	54	4	72	36	133	130	139206	25527	168019	106	102
2082	266805	78	627	65	0	134	42	155	110	106271	22139	113598	139	138
398	23623	11	156	9	0	12	1	0	0	1168	238	5841	11	11
1605	152474	65	577	45	0	106	32	123	83	71764	24459	93116	114	114
530	61857	25	192	25	4	23	11	32	30	25162	3913	24610	31	28
1503	144889	43	437	102	0	83	40	149	106	45635	9895	60611	132	101
2636	346600	99	1054	59	1	126	34	128	91	101817	25902	226620	210	208
387	21054	16	146	2	0	4	0	0	0	855	338	6622	4	4
1849	224051	45	751	56	5	71	27	99	69	100174	12937	121996	98	93
449	31414	19	200	22	0	18	8	25	9	14116	3988	13155	39	39
2912	261043	105	1050	146	2	98	35	132	123	85008	23370	154158	119	114
1740	197819	57	590	63	7	66	41	155	143	124254	24015	78489	107	104
1401	154984	73	430	91	12	44	40	151	125	105793	3870	22007	41	40
1257	112933	45	467	46	2	29	28	103	81	117129	14648	72530	97	94
568	38214	34	276	52	0	16	8	27	21	8773	1888	13983	16	16
1512	158671	33	528	98	2	56	35	131	124	94747	16768	73397	65	64
2379	302148	70	898	105	0	112	47	178	168	107549	33400	143878	156	154
1180	177918	55	411	57	0	46	46	177	149	97392	23770	119956	158	145
3071	350552	70	1362	126	3	129	42	163	147	126893	34762	181558	160	150
2186	275578	91	743	120	0	139	48	187	145	118850	18793	208236	161	156
3065	368746	106	1069	104	3	136	49	182	172	234853	48186	237085	238	229
1127	172464	31	431	44	0	66	35	135	126	74783	20140	110297	85	84
1045	94381	35	380	48	0	42	32	118	89	66089	8728	61394	50	49
2419	243875	279	788	143	4	70	36	140	137	95684	19060	81420	106	101
3839	382487	153	1367	146	4	97	42	158	149	139537	26880	191154	184	179
1427	114525	40	449	91	14	49	35	132	121	144253	415	11798	15	15
3406	335681	119	1461	129	0	113	37	136	133	153824	38902	135724	155	154
1730	147989	72	651	67	4	55	34	123	93	63995	17375	68614	90	90
1507	216638	45	494	74	0	100	36	134	119	84891	31360	139926	133	133
1907	192862	72	667	168	1	80	36	129	102	61263	15051	105203	136	133
1552	184818	107	510	69	0	29	32	125	45	106221	16785	80338	109	97
3611	336707	105	1472	99	9	95	33	128	104	113587	15886	121376	118	116
1925	215836	76	675	61	1	114	35	129	111	113864	28548	124922	222	221
2035	173260	63	716	37	3	41	21	79	78	37238	2805	10901	16	15
2503	271773	89	814	51	10	128	40	154	120	119906	34012	135471	162	157
1603	130908	52	556	121	5	142	49	188	176	135096	19215	66395	108	105
2272	204009	75	887	48	2	88	33	122	109	151611	34177	134041	153	150
2086	245514	92	663	52	1	147	39	144	132	144645	32990	153554	181	177
2	1	0	0	0	9	0	0	0	0	0	0	0	0	0
207	14688	10	85	0	0	4	0	0	0	6023	2065	7953	5	5
5	98	1	0	0	0	0	0	0	0	0	0	0	0	0
8	455	2	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	1	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1777	195765	75	607	51	2	56	33	120	78	77457	17428	98922	113	111
2781	326038	121	934	98	1	121	42	168	104	62464	19912	165395	165	165
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
4	203	4	0	0	0	0	0	0	0	0	0	0	0	0
151	7199	5	74	0	0	7	0	0	0	1644	556	4245	6	6
474	46660	20	259	7	0	12	5	15	13	6179	2089	21509	13	13
141	17547	5	69	3	0	0	1	4	4	3926	2658	7670	3	3
976	107465	38	267	80	0	37	38	133	65	42087	1801	15167	33	33
29	969	2	0	0	0	0	0	0	0	0	0	0	0	0
1542	173102	58	517	43	2	47	28	101	55	87656	16541	63891	67	63




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

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







Confusion Matrix (predicted in columns / actuals in rows)
C1C2
C14042
C2280

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

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



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