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 computationFri, 24 Dec 2010 20:35:12 +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/24/t12932227996neid3oohky9b5v.htm/, Retrieved Tue, 30 Apr 2024 00:58:44 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=115285, Retrieved Tue, 30 Apr 2024 00:58:44 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact149
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]
-   PD  [Recursive Partitioning (Regression Trees)] [] [2010-12-24 10:02:30] [b10d6b9682dfaaa479f495240bcd67cf]
-    D      [Recursive Partitioning (Regression Trees)] [] [2010-12-24 20:35:12] [d8f5affbe903a9e5555c39b0acc22667] [Current]
-    D        [Recursive Partitioning (Regression Trees)] [recursive partiti...] [2010-12-27 10:11:42] [d4d7f64064e581afd5f11cb27d8ab03c]
-    D        [Recursive Partitioning (Regression Trees)] [recursive partiti...] [2010-12-27 10:14:14] [d4d7f64064e581afd5f11cb27d8ab03c]
Feedback Forum

Post a new message
Dataseries X:
172,69	104,31
172,98	103,88
172,98	103,88
172,89	103,86
173,38	103,89
173,20	103,98
173,24	103,98
172,86	104,29
172,86	104,29
172,74	104,24
172,28	103,98
171,05	103,54
171,07	103,44
171,07	103,32
171,07	103,30
171,11	103,26
170,72	103,14
170,49	103,11
170,48	102,91
170,48	103,23
170,48	103,23
170,57	103,14
170,39	102,91
170,04	102,42
169,67	102,10
169,57	102,07
169,57	102,06
169,53	101,98
169,24	101,83
169,29	101,75
169,21	101,56
168,58	101,66
168,58	101,65
168,55	101,61
168,46	101,52
167,39	101,31
167,16	101,19
167,16	101,11
167,16	101,10
167,17	101,07
166,52	100,98
166,35	100,93
166,19	100,92
166,19	101,02
166,19	101,01
166,07	100,97
166,64	100,89
166,26	100,62
166,44	100,53
166,27	100,48
166,27	100,48
166,30	100,47
165,97	100,52
164,58	100,49
164,28	100,47
163,93	100,44




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time5 seconds
R Server'Sir Ronald Aylmer Fisher' @ 193.190.124.24

\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 & 'Sir Ronald Aylmer Fisher' @ 193.190.124.24 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=115285&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]'Sir Ronald Aylmer Fisher' @ 193.190.124.24[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=115285&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=115285&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'Sir Ronald Aylmer Fisher' @ 193.190.124.24







Goodness of Fit
Correlation0.9676
R-squared0.9362
RMSE0.6665

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

[TABLE]
[ROW][C]Goodness of Fit[/C][/ROW]
[ROW][C]Correlation[/C][C]0.9676[/C][/ROW]
[ROW][C]R-squared[/C][C]0.9362[/C][/ROW]
[ROW][C]RMSE[/C][C]0.6665[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=115285&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=115285&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.9676
R-squared0.9362
RMSE0.6665







Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
1172.69172.918181818182-0.228181818181810
2172.98172.9181818181820.0618181818181824
3172.98172.9181818181820.0618181818181824
4172.89172.918181818182-0.028181818181821
5173.38172.9181818181820.461818181818188
6173.2172.9181818181820.281818181818181
7173.24172.9181818181820.321818181818202
8172.86172.918181818182-0.0581818181817937
9172.86172.918181818182-0.0581818181817937
10172.74172.918181818182-0.178181818181798
11172.28172.918181818182-0.638181818181806
12171.05170.310.740000000000009
13171.07170.310.759999999999991
14171.07170.310.759999999999991
15171.07170.310.759999999999991
16171.11170.310.800000000000011
17170.72170.310.409999999999997
18170.49170.310.180000000000007
19170.48170.310.169999999999987
20170.48170.310.169999999999987
21170.48170.310.169999999999987
22170.57170.310.259999999999991
23170.39170.310.0799999999999841
24170.04170.31-0.27000000000001
25169.67170.31-0.640000000000015
26169.57170.31-0.740000000000009
27169.57170.31-0.740000000000009
28169.53170.31-0.780000000000001
29169.24170.31-1.06999999999999
30169.29170.31-1.02000000000001
31169.21167.9421.268
32168.58167.9420.638000000000005
33168.58167.9420.638000000000005
34168.55167.9420.608000000000004
35168.46167.9420.518000000000001
36167.39167.942-0.552000000000021
37167.16167.942-0.78200000000001
38167.16167.942-0.78200000000001
39167.16167.942-0.78200000000001
40167.17167.942-0.77200000000002
41166.52165.9031250.616875000000022
42166.35165.9031250.446875000000006
43166.19165.9031250.286875000000009
44166.19165.9031250.286875000000009
45166.19165.9031250.286875000000009
46166.07165.9031250.166875000000005
47166.64165.9031250.736874999999998
48166.26165.9031250.356875000000002
49166.44165.9031250.536875000000009
50166.27165.9031250.366875000000022
51166.27165.9031250.366875000000022
52166.3165.9031250.396875000000023
53165.97165.9031250.0668750000000102
54164.58165.903125-1.32312499999998
55164.28165.903125-1.62312499999999
56163.93165.903125-1.97312499999998

\begin{tabular}{lllllllll}
\hline
Actuals, Predictions, and Residuals \tabularnewline
# & Actuals & Forecasts & Residuals \tabularnewline
1 & 172.69 & 172.918181818182 & -0.228181818181810 \tabularnewline
2 & 172.98 & 172.918181818182 & 0.0618181818181824 \tabularnewline
3 & 172.98 & 172.918181818182 & 0.0618181818181824 \tabularnewline
4 & 172.89 & 172.918181818182 & -0.028181818181821 \tabularnewline
5 & 173.38 & 172.918181818182 & 0.461818181818188 \tabularnewline
6 & 173.2 & 172.918181818182 & 0.281818181818181 \tabularnewline
7 & 173.24 & 172.918181818182 & 0.321818181818202 \tabularnewline
8 & 172.86 & 172.918181818182 & -0.0581818181817937 \tabularnewline
9 & 172.86 & 172.918181818182 & -0.0581818181817937 \tabularnewline
10 & 172.74 & 172.918181818182 & -0.178181818181798 \tabularnewline
11 & 172.28 & 172.918181818182 & -0.638181818181806 \tabularnewline
12 & 171.05 & 170.31 & 0.740000000000009 \tabularnewline
13 & 171.07 & 170.31 & 0.759999999999991 \tabularnewline
14 & 171.07 & 170.31 & 0.759999999999991 \tabularnewline
15 & 171.07 & 170.31 & 0.759999999999991 \tabularnewline
16 & 171.11 & 170.31 & 0.800000000000011 \tabularnewline
17 & 170.72 & 170.31 & 0.409999999999997 \tabularnewline
18 & 170.49 & 170.31 & 0.180000000000007 \tabularnewline
19 & 170.48 & 170.31 & 0.169999999999987 \tabularnewline
20 & 170.48 & 170.31 & 0.169999999999987 \tabularnewline
21 & 170.48 & 170.31 & 0.169999999999987 \tabularnewline
22 & 170.57 & 170.31 & 0.259999999999991 \tabularnewline
23 & 170.39 & 170.31 & 0.0799999999999841 \tabularnewline
24 & 170.04 & 170.31 & -0.27000000000001 \tabularnewline
25 & 169.67 & 170.31 & -0.640000000000015 \tabularnewline
26 & 169.57 & 170.31 & -0.740000000000009 \tabularnewline
27 & 169.57 & 170.31 & -0.740000000000009 \tabularnewline
28 & 169.53 & 170.31 & -0.780000000000001 \tabularnewline
29 & 169.24 & 170.31 & -1.06999999999999 \tabularnewline
30 & 169.29 & 170.31 & -1.02000000000001 \tabularnewline
31 & 169.21 & 167.942 & 1.268 \tabularnewline
32 & 168.58 & 167.942 & 0.638000000000005 \tabularnewline
33 & 168.58 & 167.942 & 0.638000000000005 \tabularnewline
34 & 168.55 & 167.942 & 0.608000000000004 \tabularnewline
35 & 168.46 & 167.942 & 0.518000000000001 \tabularnewline
36 & 167.39 & 167.942 & -0.552000000000021 \tabularnewline
37 & 167.16 & 167.942 & -0.78200000000001 \tabularnewline
38 & 167.16 & 167.942 & -0.78200000000001 \tabularnewline
39 & 167.16 & 167.942 & -0.78200000000001 \tabularnewline
40 & 167.17 & 167.942 & -0.77200000000002 \tabularnewline
41 & 166.52 & 165.903125 & 0.616875000000022 \tabularnewline
42 & 166.35 & 165.903125 & 0.446875000000006 \tabularnewline
43 & 166.19 & 165.903125 & 0.286875000000009 \tabularnewline
44 & 166.19 & 165.903125 & 0.286875000000009 \tabularnewline
45 & 166.19 & 165.903125 & 0.286875000000009 \tabularnewline
46 & 166.07 & 165.903125 & 0.166875000000005 \tabularnewline
47 & 166.64 & 165.903125 & 0.736874999999998 \tabularnewline
48 & 166.26 & 165.903125 & 0.356875000000002 \tabularnewline
49 & 166.44 & 165.903125 & 0.536875000000009 \tabularnewline
50 & 166.27 & 165.903125 & 0.366875000000022 \tabularnewline
51 & 166.27 & 165.903125 & 0.366875000000022 \tabularnewline
52 & 166.3 & 165.903125 & 0.396875000000023 \tabularnewline
53 & 165.97 & 165.903125 & 0.0668750000000102 \tabularnewline
54 & 164.58 & 165.903125 & -1.32312499999998 \tabularnewline
55 & 164.28 & 165.903125 & -1.62312499999999 \tabularnewline
56 & 163.93 & 165.903125 & -1.97312499999998 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=115285&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]172.69[/C][C]172.918181818182[/C][C]-0.228181818181810[/C][/ROW]
[ROW][C]2[/C][C]172.98[/C][C]172.918181818182[/C][C]0.0618181818181824[/C][/ROW]
[ROW][C]3[/C][C]172.98[/C][C]172.918181818182[/C][C]0.0618181818181824[/C][/ROW]
[ROW][C]4[/C][C]172.89[/C][C]172.918181818182[/C][C]-0.028181818181821[/C][/ROW]
[ROW][C]5[/C][C]173.38[/C][C]172.918181818182[/C][C]0.461818181818188[/C][/ROW]
[ROW][C]6[/C][C]173.2[/C][C]172.918181818182[/C][C]0.281818181818181[/C][/ROW]
[ROW][C]7[/C][C]173.24[/C][C]172.918181818182[/C][C]0.321818181818202[/C][/ROW]
[ROW][C]8[/C][C]172.86[/C][C]172.918181818182[/C][C]-0.0581818181817937[/C][/ROW]
[ROW][C]9[/C][C]172.86[/C][C]172.918181818182[/C][C]-0.0581818181817937[/C][/ROW]
[ROW][C]10[/C][C]172.74[/C][C]172.918181818182[/C][C]-0.178181818181798[/C][/ROW]
[ROW][C]11[/C][C]172.28[/C][C]172.918181818182[/C][C]-0.638181818181806[/C][/ROW]
[ROW][C]12[/C][C]171.05[/C][C]170.31[/C][C]0.740000000000009[/C][/ROW]
[ROW][C]13[/C][C]171.07[/C][C]170.31[/C][C]0.759999999999991[/C][/ROW]
[ROW][C]14[/C][C]171.07[/C][C]170.31[/C][C]0.759999999999991[/C][/ROW]
[ROW][C]15[/C][C]171.07[/C][C]170.31[/C][C]0.759999999999991[/C][/ROW]
[ROW][C]16[/C][C]171.11[/C][C]170.31[/C][C]0.800000000000011[/C][/ROW]
[ROW][C]17[/C][C]170.72[/C][C]170.31[/C][C]0.409999999999997[/C][/ROW]
[ROW][C]18[/C][C]170.49[/C][C]170.31[/C][C]0.180000000000007[/C][/ROW]
[ROW][C]19[/C][C]170.48[/C][C]170.31[/C][C]0.169999999999987[/C][/ROW]
[ROW][C]20[/C][C]170.48[/C][C]170.31[/C][C]0.169999999999987[/C][/ROW]
[ROW][C]21[/C][C]170.48[/C][C]170.31[/C][C]0.169999999999987[/C][/ROW]
[ROW][C]22[/C][C]170.57[/C][C]170.31[/C][C]0.259999999999991[/C][/ROW]
[ROW][C]23[/C][C]170.39[/C][C]170.31[/C][C]0.0799999999999841[/C][/ROW]
[ROW][C]24[/C][C]170.04[/C][C]170.31[/C][C]-0.27000000000001[/C][/ROW]
[ROW][C]25[/C][C]169.67[/C][C]170.31[/C][C]-0.640000000000015[/C][/ROW]
[ROW][C]26[/C][C]169.57[/C][C]170.31[/C][C]-0.740000000000009[/C][/ROW]
[ROW][C]27[/C][C]169.57[/C][C]170.31[/C][C]-0.740000000000009[/C][/ROW]
[ROW][C]28[/C][C]169.53[/C][C]170.31[/C][C]-0.780000000000001[/C][/ROW]
[ROW][C]29[/C][C]169.24[/C][C]170.31[/C][C]-1.06999999999999[/C][/ROW]
[ROW][C]30[/C][C]169.29[/C][C]170.31[/C][C]-1.02000000000001[/C][/ROW]
[ROW][C]31[/C][C]169.21[/C][C]167.942[/C][C]1.268[/C][/ROW]
[ROW][C]32[/C][C]168.58[/C][C]167.942[/C][C]0.638000000000005[/C][/ROW]
[ROW][C]33[/C][C]168.58[/C][C]167.942[/C][C]0.638000000000005[/C][/ROW]
[ROW][C]34[/C][C]168.55[/C][C]167.942[/C][C]0.608000000000004[/C][/ROW]
[ROW][C]35[/C][C]168.46[/C][C]167.942[/C][C]0.518000000000001[/C][/ROW]
[ROW][C]36[/C][C]167.39[/C][C]167.942[/C][C]-0.552000000000021[/C][/ROW]
[ROW][C]37[/C][C]167.16[/C][C]167.942[/C][C]-0.78200000000001[/C][/ROW]
[ROW][C]38[/C][C]167.16[/C][C]167.942[/C][C]-0.78200000000001[/C][/ROW]
[ROW][C]39[/C][C]167.16[/C][C]167.942[/C][C]-0.78200000000001[/C][/ROW]
[ROW][C]40[/C][C]167.17[/C][C]167.942[/C][C]-0.77200000000002[/C][/ROW]
[ROW][C]41[/C][C]166.52[/C][C]165.903125[/C][C]0.616875000000022[/C][/ROW]
[ROW][C]42[/C][C]166.35[/C][C]165.903125[/C][C]0.446875000000006[/C][/ROW]
[ROW][C]43[/C][C]166.19[/C][C]165.903125[/C][C]0.286875000000009[/C][/ROW]
[ROW][C]44[/C][C]166.19[/C][C]165.903125[/C][C]0.286875000000009[/C][/ROW]
[ROW][C]45[/C][C]166.19[/C][C]165.903125[/C][C]0.286875000000009[/C][/ROW]
[ROW][C]46[/C][C]166.07[/C][C]165.903125[/C][C]0.166875000000005[/C][/ROW]
[ROW][C]47[/C][C]166.64[/C][C]165.903125[/C][C]0.736874999999998[/C][/ROW]
[ROW][C]48[/C][C]166.26[/C][C]165.903125[/C][C]0.356875000000002[/C][/ROW]
[ROW][C]49[/C][C]166.44[/C][C]165.903125[/C][C]0.536875000000009[/C][/ROW]
[ROW][C]50[/C][C]166.27[/C][C]165.903125[/C][C]0.366875000000022[/C][/ROW]
[ROW][C]51[/C][C]166.27[/C][C]165.903125[/C][C]0.366875000000022[/C][/ROW]
[ROW][C]52[/C][C]166.3[/C][C]165.903125[/C][C]0.396875000000023[/C][/ROW]
[ROW][C]53[/C][C]165.97[/C][C]165.903125[/C][C]0.0668750000000102[/C][/ROW]
[ROW][C]54[/C][C]164.58[/C][C]165.903125[/C][C]-1.32312499999998[/C][/ROW]
[ROW][C]55[/C][C]164.28[/C][C]165.903125[/C][C]-1.62312499999999[/C][/ROW]
[ROW][C]56[/C][C]163.93[/C][C]165.903125[/C][C]-1.97312499999998[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=115285&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=115285&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
1172.69172.918181818182-0.228181818181810
2172.98172.9181818181820.0618181818181824
3172.98172.9181818181820.0618181818181824
4172.89172.918181818182-0.028181818181821
5173.38172.9181818181820.461818181818188
6173.2172.9181818181820.281818181818181
7173.24172.9181818181820.321818181818202
8172.86172.918181818182-0.0581818181817937
9172.86172.918181818182-0.0581818181817937
10172.74172.918181818182-0.178181818181798
11172.28172.918181818182-0.638181818181806
12171.05170.310.740000000000009
13171.07170.310.759999999999991
14171.07170.310.759999999999991
15171.07170.310.759999999999991
16171.11170.310.800000000000011
17170.72170.310.409999999999997
18170.49170.310.180000000000007
19170.48170.310.169999999999987
20170.48170.310.169999999999987
21170.48170.310.169999999999987
22170.57170.310.259999999999991
23170.39170.310.0799999999999841
24170.04170.31-0.27000000000001
25169.67170.31-0.640000000000015
26169.57170.31-0.740000000000009
27169.57170.31-0.740000000000009
28169.53170.31-0.780000000000001
29169.24170.31-1.06999999999999
30169.29170.31-1.02000000000001
31169.21167.9421.268
32168.58167.9420.638000000000005
33168.58167.9420.638000000000005
34168.55167.9420.608000000000004
35168.46167.9420.518000000000001
36167.39167.942-0.552000000000021
37167.16167.942-0.78200000000001
38167.16167.942-0.78200000000001
39167.16167.942-0.78200000000001
40167.17167.942-0.77200000000002
41166.52165.9031250.616875000000022
42166.35165.9031250.446875000000006
43166.19165.9031250.286875000000009
44166.19165.9031250.286875000000009
45166.19165.9031250.286875000000009
46166.07165.9031250.166875000000005
47166.64165.9031250.736874999999998
48166.26165.9031250.356875000000002
49166.44165.9031250.536875000000009
50166.27165.9031250.366875000000022
51166.27165.9031250.366875000000022
52166.3165.9031250.396875000000023
53165.97165.9031250.0668750000000102
54164.58165.903125-1.32312499999998
55164.28165.903125-1.62312499999999
56163.93165.903125-1.97312499999998



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