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, 22 Dec 2010 12:09:24 +0000
Cite this page as followsStatistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?v=date/2010/Dec/22/t1293019697k55r83d41b7d84e.htm/, Retrieved Mon, 06 May 2024 07:33:34 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=114175, Retrieved Mon, 06 May 2024 07:33:34 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact134
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)] [Workshop 10; PLC:...] [2010-12-14 10:36:10] [8ffb4cfa64b4677df0d2c448735a40bb]
-    D      [Recursive Partitioning (Regression Trees)] [Paper; Recursive ...] [2010-12-22 12:09:24] [50e0b5177c9c80b42996aa89930b928a] [Current]
Feedback Forum

Post a new message
Dataseries X:
108,35	98,68	100,70	104,38	97,72	15.38	31.27
109,87	99,21	99,62	103,97	98,01	15.03	35.83
111,30	99,36	99,83	103,32	97,78	15.21	37.12
115,50	100,72	100,74	105,01	98,04	15.20	36.77
116,22	102,27	100,84	104,88	98,54	14.60	35.17
116,63	102,62	100,85	104,46	98,39	13.79	37.25
116,84	102,97	99,71	104,71	98,58	14.54	33.77
116,63	102,88	100,80	106,09	98,91	14.31	30.59
117,03	102,90	100,06	106,54	98,68	13.93	33.59
117,00	103,01	100,57	104,36	98,59	14.82	37.24
117,14	103,02	99,79	105,31	99,13	14.46	34.81
116,64	103,73	99,90	105,07	98,70	14.85	34.94
117,24	104,18	100,12	105,39	99,00	14.95	34.47
117,52	103,73	100,40	105,65	98,80	14.43	30.48
117,83	103,78	100,51	108,25	98,80	14.84	30.94
119,79	103,61	100,70	107,71	99,29	14.39	30.60
120,86	103,84	100,62	108,58	99,69	15.70	28.42
120,75	103,86	99,70	108,27	100,01	15.34	25.89
120,63	104,14	99,48	107,62	99,85	13.98	26.32
120,89	104,05	99,36	108,80	99,66	14.75	27.18
120,23	104,01	99,39	109,26	101,18	14.81	25.85
121,19	104,49	99,45	108,58	101,47	14.67	26.32
120,79	104,83	99,28	107,05	101,28	15.03	23.07
120,09	104,78	99,40	109,20	101,80	14.34	20.19
120,86	104,95	99,10	109,52	102,48	12.54	18.65
121,10	105,28	99,48	111,12	102,32	11.37	17.74
121,47	105,28	99,74	108,74	102,30	12.58	17.26
122,01	105,91	100,42	110,53	102,84	13.06	16.01
123,94	106,81	100,80	110,44	102,36	12.50	17.94
125,78	106,39	100,66	111,02	102,16	11.11	15.53
125,31	107,02	101,03	111,13	102,57	12.39	14.49
125,79	106,92	101,22	110,90	102,49	12.34	15.35
126,12	107,01	101,23	111,32	104,11	11.54	14.67
125,57	106,79	100,10	109,37	104,78	10.22	12.95
125,44	107,41	99,98	110,18	104,13	8.50	8.81
126,12	107,13	99,91	110,74	104,22	9.06	9.33
126,01	107,54	99,84	111,70	104,73	9.28	9.31
126,50	108,48	99,68	111,33	104,99	7.24	9.03
126,13	108,50	99,74	110,86	104,70	7.58	10.96
126,66	108,27	99,71	109,48	104,69	7.81	14.26
126,33	109,42	99,35	108,77	104,85	8.54	14.20
126,61	110,09	99,21	109,81	104,24	9.27	13.70
126,36	109,98	99,21	109,15	104,74	10.11	17.46
126,83	109,99	99,16	109,63	104,20	9.21	18.73
125,90	109,54	99,20	111,32	105,62	10.71	20.37
126,29	108,85	99,08	109,75	106,08	10.85	18.72
126,37	106,76	98,16	110,37	105,46	11.77	21.60
125,11	107,56	98,00	108,30	105,42	11.81	22.75




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time4 seconds
R Server'RServer@AstonUniversity' @ vre.aston.ac.uk

\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 & 4 seconds \tabularnewline
R Server & 'RServer@AstonUniversity' @ vre.aston.ac.uk \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=114175&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]4 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'RServer@AstonUniversity' @ vre.aston.ac.uk[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=114175&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=114175&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 time4 seconds
R Server'RServer@AstonUniversity' @ vre.aston.ac.uk







Goodness of Fit
Correlation0.9528
R-squared0.9078
RMSE1.4461

\begin{tabular}{lllllllll}
\hline
Goodness of Fit \tabularnewline
Correlation & 0.9528 \tabularnewline
R-squared & 0.9078 \tabularnewline
RMSE & 1.4461 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=114175&T=1

[TABLE]
[ROW][C]Goodness of Fit[/C][/ROW]
[ROW][C]Correlation[/C][C]0.9528[/C][/ROW]
[ROW][C]R-squared[/C][C]0.9078[/C][/ROW]
[ROW][C]RMSE[/C][C]1.4461[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=114175&T=1

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

As an alternative you can also use a QR Code:  

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

Goodness of Fit
Correlation0.9528
R-squared0.9078
RMSE1.4461







Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
1108.35113.5-5.15000000000001
2109.87113.5-3.63
3111.3113.5-2.2
4115.5113.52
5116.22113.52.72
6116.63113.53.13
7116.84117.447777777778-0.60777777777777
8116.63113.53.13
9117.03117.447777777778-0.417777777777772
10117117.447777777778-0.447777777777773
11117.14117.447777777778-0.307777777777773
12116.64117.447777777778-0.807777777777773
13117.24117.447777777778-0.207777777777778
14117.52117.4477777777780.0722222222222229
15117.83117.4477777777780.382222222222225
16119.79117.4477777777782.34222222222223
17120.86120.8054545454550.0545454545454476
18120.75120.805454545455-0.0554545454545519
19120.63120.805454545455-0.175454545454556
20120.89120.8054545454550.0845454545454487
21120.23120.805454545455-0.575454545454548
22121.19120.8054545454550.384545454545446
23120.79120.805454545455-0.0154545454545456
24120.09120.805454545455-0.715454545454548
25120.86120.8054545454550.0545454545454476
26121.1120.8054545454550.294545454545442
27121.47120.8054545454550.664545454545447
28122.01124.95-2.94
29123.94124.95-1.01000000000001
30125.78126.180714285714-0.400714285714287
31125.31124.950.359999999999999
32125.79124.950.840000000000003
33126.12124.951.17
34125.57126.180714285714-0.610714285714295
35125.44126.180714285714-0.74071428571429
36126.12126.180714285714-0.0607142857142833
37126.01126.180714285714-0.170714285714283
38126.5126.1807142857140.319285714285712
39126.13126.180714285714-0.0507142857142924
40126.66126.1807142857140.479285714285709
41126.33126.1807142857140.14928571428571
42126.61126.1807142857140.429285714285712
43126.36126.1807142857140.179285714285712
44126.83126.1807142857140.64928571428571
45125.9126.180714285714-0.280714285714282
46126.29126.1807142857140.109285714285718
47126.37124.951.42
48125.11124.950.159999999999997

\begin{tabular}{lllllllll}
\hline
Actuals, Predictions, and Residuals \tabularnewline
# & Actuals & Forecasts & Residuals \tabularnewline
1 & 108.35 & 113.5 & -5.15000000000001 \tabularnewline
2 & 109.87 & 113.5 & -3.63 \tabularnewline
3 & 111.3 & 113.5 & -2.2 \tabularnewline
4 & 115.5 & 113.5 & 2 \tabularnewline
5 & 116.22 & 113.5 & 2.72 \tabularnewline
6 & 116.63 & 113.5 & 3.13 \tabularnewline
7 & 116.84 & 117.447777777778 & -0.60777777777777 \tabularnewline
8 & 116.63 & 113.5 & 3.13 \tabularnewline
9 & 117.03 & 117.447777777778 & -0.417777777777772 \tabularnewline
10 & 117 & 117.447777777778 & -0.447777777777773 \tabularnewline
11 & 117.14 & 117.447777777778 & -0.307777777777773 \tabularnewline
12 & 116.64 & 117.447777777778 & -0.807777777777773 \tabularnewline
13 & 117.24 & 117.447777777778 & -0.207777777777778 \tabularnewline
14 & 117.52 & 117.447777777778 & 0.0722222222222229 \tabularnewline
15 & 117.83 & 117.447777777778 & 0.382222222222225 \tabularnewline
16 & 119.79 & 117.447777777778 & 2.34222222222223 \tabularnewline
17 & 120.86 & 120.805454545455 & 0.0545454545454476 \tabularnewline
18 & 120.75 & 120.805454545455 & -0.0554545454545519 \tabularnewline
19 & 120.63 & 120.805454545455 & -0.175454545454556 \tabularnewline
20 & 120.89 & 120.805454545455 & 0.0845454545454487 \tabularnewline
21 & 120.23 & 120.805454545455 & -0.575454545454548 \tabularnewline
22 & 121.19 & 120.805454545455 & 0.384545454545446 \tabularnewline
23 & 120.79 & 120.805454545455 & -0.0154545454545456 \tabularnewline
24 & 120.09 & 120.805454545455 & -0.715454545454548 \tabularnewline
25 & 120.86 & 120.805454545455 & 0.0545454545454476 \tabularnewline
26 & 121.1 & 120.805454545455 & 0.294545454545442 \tabularnewline
27 & 121.47 & 120.805454545455 & 0.664545454545447 \tabularnewline
28 & 122.01 & 124.95 & -2.94 \tabularnewline
29 & 123.94 & 124.95 & -1.01000000000001 \tabularnewline
30 & 125.78 & 126.180714285714 & -0.400714285714287 \tabularnewline
31 & 125.31 & 124.95 & 0.359999999999999 \tabularnewline
32 & 125.79 & 124.95 & 0.840000000000003 \tabularnewline
33 & 126.12 & 124.95 & 1.17 \tabularnewline
34 & 125.57 & 126.180714285714 & -0.610714285714295 \tabularnewline
35 & 125.44 & 126.180714285714 & -0.74071428571429 \tabularnewline
36 & 126.12 & 126.180714285714 & -0.0607142857142833 \tabularnewline
37 & 126.01 & 126.180714285714 & -0.170714285714283 \tabularnewline
38 & 126.5 & 126.180714285714 & 0.319285714285712 \tabularnewline
39 & 126.13 & 126.180714285714 & -0.0507142857142924 \tabularnewline
40 & 126.66 & 126.180714285714 & 0.479285714285709 \tabularnewline
41 & 126.33 & 126.180714285714 & 0.14928571428571 \tabularnewline
42 & 126.61 & 126.180714285714 & 0.429285714285712 \tabularnewline
43 & 126.36 & 126.180714285714 & 0.179285714285712 \tabularnewline
44 & 126.83 & 126.180714285714 & 0.64928571428571 \tabularnewline
45 & 125.9 & 126.180714285714 & -0.280714285714282 \tabularnewline
46 & 126.29 & 126.180714285714 & 0.109285714285718 \tabularnewline
47 & 126.37 & 124.95 & 1.42 \tabularnewline
48 & 125.11 & 124.95 & 0.159999999999997 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=114175&T=2

[TABLE]
[ROW][C]Actuals, Predictions, and Residuals[/C][/ROW]
[ROW][C]#[/C][C]Actuals[/C][C]Forecasts[/C][C]Residuals[/C][/ROW]
[ROW][C]1[/C][C]108.35[/C][C]113.5[/C][C]-5.15000000000001[/C][/ROW]
[ROW][C]2[/C][C]109.87[/C][C]113.5[/C][C]-3.63[/C][/ROW]
[ROW][C]3[/C][C]111.3[/C][C]113.5[/C][C]-2.2[/C][/ROW]
[ROW][C]4[/C][C]115.5[/C][C]113.5[/C][C]2[/C][/ROW]
[ROW][C]5[/C][C]116.22[/C][C]113.5[/C][C]2.72[/C][/ROW]
[ROW][C]6[/C][C]116.63[/C][C]113.5[/C][C]3.13[/C][/ROW]
[ROW][C]7[/C][C]116.84[/C][C]117.447777777778[/C][C]-0.60777777777777[/C][/ROW]
[ROW][C]8[/C][C]116.63[/C][C]113.5[/C][C]3.13[/C][/ROW]
[ROW][C]9[/C][C]117.03[/C][C]117.447777777778[/C][C]-0.417777777777772[/C][/ROW]
[ROW][C]10[/C][C]117[/C][C]117.447777777778[/C][C]-0.447777777777773[/C][/ROW]
[ROW][C]11[/C][C]117.14[/C][C]117.447777777778[/C][C]-0.307777777777773[/C][/ROW]
[ROW][C]12[/C][C]116.64[/C][C]117.447777777778[/C][C]-0.807777777777773[/C][/ROW]
[ROW][C]13[/C][C]117.24[/C][C]117.447777777778[/C][C]-0.207777777777778[/C][/ROW]
[ROW][C]14[/C][C]117.52[/C][C]117.447777777778[/C][C]0.0722222222222229[/C][/ROW]
[ROW][C]15[/C][C]117.83[/C][C]117.447777777778[/C][C]0.382222222222225[/C][/ROW]
[ROW][C]16[/C][C]119.79[/C][C]117.447777777778[/C][C]2.34222222222223[/C][/ROW]
[ROW][C]17[/C][C]120.86[/C][C]120.805454545455[/C][C]0.0545454545454476[/C][/ROW]
[ROW][C]18[/C][C]120.75[/C][C]120.805454545455[/C][C]-0.0554545454545519[/C][/ROW]
[ROW][C]19[/C][C]120.63[/C][C]120.805454545455[/C][C]-0.175454545454556[/C][/ROW]
[ROW][C]20[/C][C]120.89[/C][C]120.805454545455[/C][C]0.0845454545454487[/C][/ROW]
[ROW][C]21[/C][C]120.23[/C][C]120.805454545455[/C][C]-0.575454545454548[/C][/ROW]
[ROW][C]22[/C][C]121.19[/C][C]120.805454545455[/C][C]0.384545454545446[/C][/ROW]
[ROW][C]23[/C][C]120.79[/C][C]120.805454545455[/C][C]-0.0154545454545456[/C][/ROW]
[ROW][C]24[/C][C]120.09[/C][C]120.805454545455[/C][C]-0.715454545454548[/C][/ROW]
[ROW][C]25[/C][C]120.86[/C][C]120.805454545455[/C][C]0.0545454545454476[/C][/ROW]
[ROW][C]26[/C][C]121.1[/C][C]120.805454545455[/C][C]0.294545454545442[/C][/ROW]
[ROW][C]27[/C][C]121.47[/C][C]120.805454545455[/C][C]0.664545454545447[/C][/ROW]
[ROW][C]28[/C][C]122.01[/C][C]124.95[/C][C]-2.94[/C][/ROW]
[ROW][C]29[/C][C]123.94[/C][C]124.95[/C][C]-1.01000000000001[/C][/ROW]
[ROW][C]30[/C][C]125.78[/C][C]126.180714285714[/C][C]-0.400714285714287[/C][/ROW]
[ROW][C]31[/C][C]125.31[/C][C]124.95[/C][C]0.359999999999999[/C][/ROW]
[ROW][C]32[/C][C]125.79[/C][C]124.95[/C][C]0.840000000000003[/C][/ROW]
[ROW][C]33[/C][C]126.12[/C][C]124.95[/C][C]1.17[/C][/ROW]
[ROW][C]34[/C][C]125.57[/C][C]126.180714285714[/C][C]-0.610714285714295[/C][/ROW]
[ROW][C]35[/C][C]125.44[/C][C]126.180714285714[/C][C]-0.74071428571429[/C][/ROW]
[ROW][C]36[/C][C]126.12[/C][C]126.180714285714[/C][C]-0.0607142857142833[/C][/ROW]
[ROW][C]37[/C][C]126.01[/C][C]126.180714285714[/C][C]-0.170714285714283[/C][/ROW]
[ROW][C]38[/C][C]126.5[/C][C]126.180714285714[/C][C]0.319285714285712[/C][/ROW]
[ROW][C]39[/C][C]126.13[/C][C]126.180714285714[/C][C]-0.0507142857142924[/C][/ROW]
[ROW][C]40[/C][C]126.66[/C][C]126.180714285714[/C][C]0.479285714285709[/C][/ROW]
[ROW][C]41[/C][C]126.33[/C][C]126.180714285714[/C][C]0.14928571428571[/C][/ROW]
[ROW][C]42[/C][C]126.61[/C][C]126.180714285714[/C][C]0.429285714285712[/C][/ROW]
[ROW][C]43[/C][C]126.36[/C][C]126.180714285714[/C][C]0.179285714285712[/C][/ROW]
[ROW][C]44[/C][C]126.83[/C][C]126.180714285714[/C][C]0.64928571428571[/C][/ROW]
[ROW][C]45[/C][C]125.9[/C][C]126.180714285714[/C][C]-0.280714285714282[/C][/ROW]
[ROW][C]46[/C][C]126.29[/C][C]126.180714285714[/C][C]0.109285714285718[/C][/ROW]
[ROW][C]47[/C][C]126.37[/C][C]124.95[/C][C]1.42[/C][/ROW]
[ROW][C]48[/C][C]125.11[/C][C]124.95[/C][C]0.159999999999997[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=114175&T=2

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

As an alternative you can also use a QR Code:  

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

Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
1108.35113.5-5.15000000000001
2109.87113.5-3.63
3111.3113.5-2.2
4115.5113.52
5116.22113.52.72
6116.63113.53.13
7116.84117.447777777778-0.60777777777777
8116.63113.53.13
9117.03117.447777777778-0.417777777777772
10117117.447777777778-0.447777777777773
11117.14117.447777777778-0.307777777777773
12116.64117.447777777778-0.807777777777773
13117.24117.447777777778-0.207777777777778
14117.52117.4477777777780.0722222222222229
15117.83117.4477777777780.382222222222225
16119.79117.4477777777782.34222222222223
17120.86120.8054545454550.0545454545454476
18120.75120.805454545455-0.0554545454545519
19120.63120.805454545455-0.175454545454556
20120.89120.8054545454550.0845454545454487
21120.23120.805454545455-0.575454545454548
22121.19120.8054545454550.384545454545446
23120.79120.805454545455-0.0154545454545456
24120.09120.805454545455-0.715454545454548
25120.86120.8054545454550.0545454545454476
26121.1120.8054545454550.294545454545442
27121.47120.8054545454550.664545454545447
28122.01124.95-2.94
29123.94124.95-1.01000000000001
30125.78126.180714285714-0.400714285714287
31125.31124.950.359999999999999
32125.79124.950.840000000000003
33126.12124.951.17
34125.57126.180714285714-0.610714285714295
35125.44126.180714285714-0.74071428571429
36126.12126.180714285714-0.0607142857142833
37126.01126.180714285714-0.170714285714283
38126.5126.1807142857140.319285714285712
39126.13126.180714285714-0.0507142857142924
40126.66126.1807142857140.479285714285709
41126.33126.1807142857140.14928571428571
42126.61126.1807142857140.429285714285712
43126.36126.1807142857140.179285714285712
44126.83126.1807142857140.64928571428571
45125.9126.180714285714-0.280714285714282
46126.29126.1807142857140.109285714285718
47126.37124.951.42
48125.11124.950.159999999999997



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