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 computationSat, 10 Dec 2011 12:27:18 -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/10/t1323538056wix7r3vge70l2lh.htm/, Retrieved Sat, 04 May 2024 20:02:09 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=153607, Retrieved Sat, 04 May 2024 20:02:09 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact73
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:50:12] [b98453cac15ba1066b407e146608df68]
- R PD    [Recursive Partitioning (Regression Trees)] [Cross Validation] [2011-12-10 17:27:18] [03e2d80b807f43987d5267414f2021cf] [Current]
Feedback Forum

Post a new message
Dataseries X:
94	145	210907,00	112285	56	1418
103	101	120982,00	84786	56	869
93	98	176508,00	83123	54	1530
103	132	179321,00	101193	89	2172
51	60	123185,00	38361	40	901
70	38	52746,00	68504	25	463
91	144	385534,00	119182	92	3201
22	5	33170,00	22807	18	371
38	28	101645,00	17140	63	1192
93	84	149061,00	116174	44	1583
60	79	165446,00	57635	33	1439
123	127	237213,00	66198	84	1764
148	78	173326,00	71701	88	1495
90	60	133131,00	57793	55	1373
124	131	258873,00	80444	60	2187
70	84	180083,00	53855	66	1491
168	133	324799,00	97668	154	4041
115	150	230964,00	133824	53	1706
71	91	236785,00	101481	119	2152
66	132	135473,00	99645	41	1036
134	136	202925,00	114789	61	1882
117	124	215147,00	99052	58	1929
108	118	344297,00	67654	75	2242
84	70	153935,00	65553	33	1220
156	107	132943,00	97500	40	1289
120	119	174724,00	69112	92	2515
114	89	174415,00	82753	100	2147
94	112	225548,00	85323	112	2352
120	108	223632,00	72654	73	1638
81	52	124817,00	30727	40	1222
110	112	221698,00	77873	45	1812
133	116	210767,00	117478	60	1677
122	123	170266,00	74007	62	1579
158	125	260561,00	90183	75	1731
109	27	84853,00	61542	31	807
124	162	294424,00	101494	77	2452
39	32	101011,00	27570	34	829
92	64	215641,00	55813	46	1940
126	92	325107,00	79215	99	2662
0	0	7176,00	1423	17	186
70	83	167542,00	55461	66	1499
37	41	106408,00	31081	30	865
38	47	96560,00	22996	76	1793
120	120	265769,00	83122	146	2527
93	105	269651,00	70106	67	2747
95	79	149112,00	60578	56	1324
77	65	175824,00	39992	107	2702
90	70	152871,00	79892	58	1383
80	55	111665,00	49810	34	1179
31	39	116408,00	71570	61	2099
110	67	362301,00	100708	119	4308
66	21	78800,00	33032	42	918
138	127	183167,00	82875	66	1831
133	152	277965,00	139077	89	3373
113	113	150629,00	71595	44	1713
100	99	168809,00	72260	66	1438
7	7	24188,00	5950	24	496
140	141	329267,00	115762	259	2253
61	21	65029,00	32551	17	744
41	35	101097,00	31701	64	1161
96	109	218946,00	80670	41	2352
164	133	244052,00	143558	68	2144
78	123	341570,00	117105	168	4691
49	26	103597,00	23789	43	1112
102	230	233328,00	120733	132	2694
124	166	256462,00	105195	105	1973
99	68	206161,00	73107	71	1769
129	147	311473,00	132068	112	3148
62	179	235800,00	149193	94	2474
73	61	177939,00	46821	82	2084
114	101	207176,00	87011	70	1954
99	108	196553,00	95260	57	1226
70	90	174184,00	55183	53	1389
104	114	143246,00	106671	103	1496
116	103	187559,00	73511	121	2269
91	142	187681,00	92945	62	1833
74	79	119016,00	78664	52	1268
138	88	182192,00	70054	52	1943
67	25	73566,00	22618	32	893
151	83	194979,00	74011	62	1762
72	113	167488,00	83737	45	1403
120	118	143756,00	69094	46	1425
115	110	275541,00	93133	63	1857
105	129	243199,00	95536	75	1840
104	51	182999,00	225920	88	1502
108	93	135649,00	62133	46	1441
98	76	152299,00	61370	53	1420
69	49	120221,00	43836	37	1416
111	118	346485,00	106117	90	2970
99	38	145790,00	38692	63	1317
71	141	193339,00	84651	78	1644
27	58	80953,00	56622	25	870
69	27	122774,00	15986	45	1654
107	91	130585,00	95364	46	1054
73	48	112611,00	26706	41	937
107	63	286468,00	89691	144	3004
93	56	241066,00	67267	82	2008
129	144	148446,00	126846	91	2547
69	73	204713,00	41140	71	1885
118	168	182079,00	102860	63	1626
73	64	140344,00	51715	53	1468
119	97	220516,00	55801	62	2445
104	117	243060,00	111813	63	1964
107	100	162765,00	120293	32	1381
99	149	182613,00	138599	39	1369
90	187	232138,00	161647	62	1659
197	127	265318,00	115929	117	2888
36	37	85574,00	24266	34	1290
85	245	310839,00	162901	92	2845
139	87	225060,00	109825	93	1982
106	177	232317,00	129838	54	1904
50	49	144966,00	37510	144	1391
64	49	43287,00	43750	14	602
31	73	155754,00	40652	61	1743
63	177	164709,00	87771	109	1559
92	94	201940,00	85872	38	2014
106	117	235454,00	89275	73	2143
63	60	220801,00	44418	75	2146
69	55	99466,00	192565	50	874
41	39	92661,00	35232	61	1590
56	64	133328,00	40909	55	1590
25	26	61361,00	13294	77	1210
65	64	125930,00	32387	75	2072
93	58	100750,00	140867	72	1281
114	95	224549,00	120662	50	1401
38	25	82316,00	21233	32	834
44	26	102010,00	44332	53	1105
87	76	101523,00	61056	42	1272
110	129	243511,00	101338	71	1944
0	11	22938,00	1168	10	391
27	2	41566,00	13497	35	761
83	101	152474,00	65567	65	1605
30	28	61857,00	25162	25	530
80	36	99923,00	32334	66	1988
98	89	132487,00	40735	41	1386
82	193	317394,00	91413	86	2395
0	4	21054,00	855	16	387
60	84	209641,00	97068	42	1742
28	23	22648,00	44339	19	620
9	39	31414,00	14116	19	449
33	14	46698,00	10288	45	800
59	78	131698,00	65622	65	1684
49	14	91735,00	16563	35	1050
115	101	244749,00	76643	95	2699
140	82	184510,00	110681	49	1606
49	24	79863,00	29011	37	1502
120	36	128423,00	92696	64	1204
66	75	97839,00	94785	38	1138
21	16	38214,00	8773	34	568
124	55	151101,00	83209	32	1459
152	131	272458,00	93815	65	2158
139	131	172494,00	86687	52	1111
38	39	108043,00	34553	62	1421
144	144	328107,00	105547	65	2833
120	139	250579,00	103487	83	1955
160	211	351067,00	213688	95	2922
114	78	158015,00	71220	29	1002
39	50	98866,00	23517	18	1060
78	39	85439,00	56926	33	956
119	90	229242,00	91721	247	2186
141	166	351619,00	115168	139	3604
101	12	84207,00	111194	29	1035
56	57	120445,00	51009	118	1417
133	133	324598,00	135777	110	3261
83	69	131069,00	51513	67	1587
116	119	204271,00	74163	42	1424
90	119	165543,00	51633	65	1701
36	65	141722,00	75345	94	1249
50	61	116048,00	33416	64	946
61	49	250047,00	83305	81	1926
97	101	299775,00	98952	95	3352
98	196	195838,00	102372	67	1641
78	15	173260,00	37238	63	2035
117	136	254488,00	103772	83	2312
148	89	104389,00	123969	45	1369
41	40	136084,00	27142	30	1577
105	123	199476,00	135400	70	2201
55	21	92499,00	21399	32	961
132	163	224330,00	130115	83	1900
44	29	135781,00	24874	31	1254
21	35	74408,00	34988	67	1335
50	13	81240,00	45549	66	1597
0	5	14688,00	6023	10	207
73	96	181633,00	64466	70	1645
86	151	271856,00	54990	103	2429
0	6	7199,00	1644	5	151
13	13	46660,00	6179	20	474
4	3	17547,00	3926	5	141
57	56	133368,00	32755	36	1639
48	23	95227,00	34777	34	872
46	57	152601,00	73224	48	1318
48	14	98146,00	27114	40	1018
32	43	79619,00	20760	43	1383
68	20	59194,00	37636	31	1314
87	72	139942,00	65461	42	1335
43	87	118612,00	30080	46	1403
67	21	72880,00	24094	33	910
46	56	65475,00	69008	18	616
46	59	99643,00	54968	55	1407
56	82	71965,00	46090	35	771
48	43	77272,00	27507	59	766
44	25	49289,00	10672	19	473
60	38	135131,00	34029	66	1376
65	25	108446,00	46300	60	1232
55	38	89746,00	24760	36	1521
38	12	44296,00	18779	25	572
52	29	77648,00	21280	47	1059
60	47	181528,00	40662	54	1544
54	45	134019,00	28987	53	1230
86	40	124064,00	22827	40	1206
24	30	92630,00	18513	40	1205
52	41	121848,00	30594	39	1255
49	25	52915,00	24006	14	613
61	23	81872,00	27913	45	721
61	14	58981,00	42744	36	1109
81	16	53515,00	12934	28	740
43	26	60812,00	22574	44	1126
40	21	56375,00	41385	30	728
40	27	65490,00	18653	22	689
56	9	80949,00	18472	17	592
68	33	76302,00	30976	31	995
79	42	104011,00	63339	55	1613
47	68	98104,00	25568	54	2048
57	32	67989,00	33747	21	705
41	6	30989,00	4154	14	301
29	67	135458,00	19474	81	1803
3	33	73504,00	35130	35	799
60	77	63123,00	39067	43	861
30	46	61254,00	13310	46	1186
79	30	74914,00	65892	30	1451
47	0	31774,00	4143	23	628
40	36	81437,00	28579	38	1161
48	46	87186,00	51776	54	1463
36	18	50090,00	21152	20	742
42	48	65745,00	38084	53	979
49	29	56653,00	27717	45	675
57	28	158399,00	32928	39	1241
12	34	46455,00	11342	20	676
40	33	73624,00	19499	24	1049
43	34	38395,00	16380	31	620
33	33	91899,00	36874	35	1081
77	80	139526,00	48259	151	1688
43	32	52164,00	16734	52	736
45	30	51567,00	28207	30	617
47	41	70551,00	30143	31	812
43	41	84856,00	41369	29	1051
45	51	102538,00	45833	57	1656
50	18	86678,00	29156	40	705
35	34	85709,00	35944	44	945
7	31	34662,00	36278	25	554
71	39	150580,00	45588	77	1597
67	54	99611,00	45097	35	982
0	14	19349,00	3895	11	222
62	24	99373,00	28394	63	1212
54	24	86230,00	18632	44	1143
4	8	30837,00	2325	19	435
25	26	31706,00	25139	13	532
40	19	89806,00	27975	42	882
38	11	62088,00	14483	38	608
19	14	40151,00	13127	29	459
17	1	27634,00	5839	20	578
67	39	76990,00	24069	27	826
14	5	37460,00	3738	20	509
30	37	54157,00	18625	19	717
54	32	49862,00	36341	37	637
35	38	84337,00	24548	26	857
59	47	64175,00	21792	42	830
24	47	59382,00	26263	49	652
58	37	119308,00	23686	30	707
42	51	76702,00	49303	49	954
46	45	103425,00	25659	67	1461
61	21	70344,00	28904	28	672
3	1	43410,00	2781	19	778
52	42	104838,00	29236	49	1141
25	26	62215,00	19546	27	680
40	21	69304,00	22818	30	1090
32	4	53117,00	32689	22	616
4	10	19764,00	5752	12	285
49	43	86680,00	22197	31	1145
63	34	84105,00	20055	20	733
67	31	77945,00	25272	20	888
32	19	89113,00	82206	39	849
23	34	91005,00	32073	29	1182
7	6	40248,00	5444	16	528
54	11	64187,00	20154	27	642
37	24	50857,00	36944	21	947
35	16	56613,00	8019	19	819
51	72	62792,00	30884	35	757
39	21	72535,00	19540	14	894




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

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







10-Fold Cross Validation
Prediction (training)Prediction (testing)
ActualC1C2CVC1C2CV
C111391720.8688116230.8345
C226010450.800843920.6815
Overall--0.8349--0.7591

\begin{tabular}{lllllllll}
\hline
10-Fold Cross Validation \tabularnewline
 & Prediction (training) & Prediction (testing) \tabularnewline
Actual & C1 & C2 & CV & C1 & C2 & CV \tabularnewline
C1 & 1139 & 172 & 0.8688 & 116 & 23 & 0.8345 \tabularnewline
C2 & 260 & 1045 & 0.8008 & 43 & 92 & 0.6815 \tabularnewline
Overall & - & - & 0.8349 & - & - & 0.7591 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=153607&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]1139[/C][C]172[/C][C]0.8688[/C][C]116[/C][C]23[/C][C]0.8345[/C][/ROW]
[ROW][C]C2[/C][C]260[/C][C]1045[/C][C]0.8008[/C][C]43[/C][C]92[/C][C]0.6815[/C][/ROW]
[ROW][C]Overall[/C][C]-[/C][C]-[/C][C]0.8349[/C][C]-[/C][C]-[/C][C]0.7591[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=153607&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=153607&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
C111391720.8688116230.8345
C226010450.800843920.6815
Overall--0.8349--0.7591







Confusion Matrix (predicted in columns / actuals in rows)
C1C2
C113510
C240104

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

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



Parameters (Session):
par1 = 1 ; par2 = Do not include Seasonal Dummies ; par3 = No Linear Trend ;
Parameters (R input):
par1 = 5 ; 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')
}