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 10:02:30 +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/t1293184802mrya2xdxgzwnd5s.htm/, Retrieved Tue, 30 Apr 2024 04:14:08 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=114681, Retrieved Tue, 30 Apr 2024 04:14:08 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact190
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] [7674ee8f347756742f81ca2ada5c384c] [Current]
-   PD      [Recursive Partitioning (Regression Trees)] [] [2010-12-24 17:31:53] [fa409bd323d47d7cf4d4bfe80571749f]
-    D      [Recursive Partitioning (Regression Trees)] [] [2010-12-24 20:35:12] [58af523ef9b33032fd2497c80088399b]
-    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 time7 seconds
R Server'George Udny Yule' @ 72.249.76.132

\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 & 7 seconds \tabularnewline
R Server & 'George Udny Yule' @ 72.249.76.132 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=114681&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]7 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'George Udny Yule' @ 72.249.76.132[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=114681&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=114681&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 time7 seconds
R Server'George Udny Yule' @ 72.249.76.132







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=114681&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=114681&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=114681&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.0281818181818210
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.73999999999998
13171.07170.310.759999999999962
14171.07170.310.759999999999962
15171.07170.310.759999999999962
16171.11170.310.799999999999983
17170.72170.310.409999999999968
18170.49170.310.179999999999978
19170.48170.310.169999999999959
20170.48170.310.169999999999959
21170.48170.310.169999999999959
22170.57170.310.259999999999962
23170.39170.310.0799999999999557
24170.04170.31-0.270000000000039
25169.67170.31-0.640000000000043
26169.57170.31-0.740000000000038
27169.57170.31-0.740000000000038
28169.53170.31-0.78000000000003
29169.24170.31-1.07000000000002
30169.29170.31-1.02000000000004
31169.21167.9421.26799999999997
32168.58167.9420.637999999999977
33168.58167.9420.637999999999977
34168.55167.9420.607999999999976
35168.46167.9420.517999999999972
36167.39167.942-0.552000000000049
37167.16167.942-0.782000000000039
38167.16167.942-0.782000000000039
39167.16167.942-0.782000000000039
40167.17167.942-0.772000000000048
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.0281818181818210 \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.73999999999998 \tabularnewline
13 & 171.07 & 170.31 & 0.759999999999962 \tabularnewline
14 & 171.07 & 170.31 & 0.759999999999962 \tabularnewline
15 & 171.07 & 170.31 & 0.759999999999962 \tabularnewline
16 & 171.11 & 170.31 & 0.799999999999983 \tabularnewline
17 & 170.72 & 170.31 & 0.409999999999968 \tabularnewline
18 & 170.49 & 170.31 & 0.179999999999978 \tabularnewline
19 & 170.48 & 170.31 & 0.169999999999959 \tabularnewline
20 & 170.48 & 170.31 & 0.169999999999959 \tabularnewline
21 & 170.48 & 170.31 & 0.169999999999959 \tabularnewline
22 & 170.57 & 170.31 & 0.259999999999962 \tabularnewline
23 & 170.39 & 170.31 & 0.0799999999999557 \tabularnewline
24 & 170.04 & 170.31 & -0.270000000000039 \tabularnewline
25 & 169.67 & 170.31 & -0.640000000000043 \tabularnewline
26 & 169.57 & 170.31 & -0.740000000000038 \tabularnewline
27 & 169.57 & 170.31 & -0.740000000000038 \tabularnewline
28 & 169.53 & 170.31 & -0.78000000000003 \tabularnewline
29 & 169.24 & 170.31 & -1.07000000000002 \tabularnewline
30 & 169.29 & 170.31 & -1.02000000000004 \tabularnewline
31 & 169.21 & 167.942 & 1.26799999999997 \tabularnewline
32 & 168.58 & 167.942 & 0.637999999999977 \tabularnewline
33 & 168.58 & 167.942 & 0.637999999999977 \tabularnewline
34 & 168.55 & 167.942 & 0.607999999999976 \tabularnewline
35 & 168.46 & 167.942 & 0.517999999999972 \tabularnewline
36 & 167.39 & 167.942 & -0.552000000000049 \tabularnewline
37 & 167.16 & 167.942 & -0.782000000000039 \tabularnewline
38 & 167.16 & 167.942 & -0.782000000000039 \tabularnewline
39 & 167.16 & 167.942 & -0.782000000000039 \tabularnewline
40 & 167.17 & 167.942 & -0.772000000000048 \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=114681&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.0281818181818210[/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.73999999999998[/C][/ROW]
[ROW][C]13[/C][C]171.07[/C][C]170.31[/C][C]0.759999999999962[/C][/ROW]
[ROW][C]14[/C][C]171.07[/C][C]170.31[/C][C]0.759999999999962[/C][/ROW]
[ROW][C]15[/C][C]171.07[/C][C]170.31[/C][C]0.759999999999962[/C][/ROW]
[ROW][C]16[/C][C]171.11[/C][C]170.31[/C][C]0.799999999999983[/C][/ROW]
[ROW][C]17[/C][C]170.72[/C][C]170.31[/C][C]0.409999999999968[/C][/ROW]
[ROW][C]18[/C][C]170.49[/C][C]170.31[/C][C]0.179999999999978[/C][/ROW]
[ROW][C]19[/C][C]170.48[/C][C]170.31[/C][C]0.169999999999959[/C][/ROW]
[ROW][C]20[/C][C]170.48[/C][C]170.31[/C][C]0.169999999999959[/C][/ROW]
[ROW][C]21[/C][C]170.48[/C][C]170.31[/C][C]0.169999999999959[/C][/ROW]
[ROW][C]22[/C][C]170.57[/C][C]170.31[/C][C]0.259999999999962[/C][/ROW]
[ROW][C]23[/C][C]170.39[/C][C]170.31[/C][C]0.0799999999999557[/C][/ROW]
[ROW][C]24[/C][C]170.04[/C][C]170.31[/C][C]-0.270000000000039[/C][/ROW]
[ROW][C]25[/C][C]169.67[/C][C]170.31[/C][C]-0.640000000000043[/C][/ROW]
[ROW][C]26[/C][C]169.57[/C][C]170.31[/C][C]-0.740000000000038[/C][/ROW]
[ROW][C]27[/C][C]169.57[/C][C]170.31[/C][C]-0.740000000000038[/C][/ROW]
[ROW][C]28[/C][C]169.53[/C][C]170.31[/C][C]-0.78000000000003[/C][/ROW]
[ROW][C]29[/C][C]169.24[/C][C]170.31[/C][C]-1.07000000000002[/C][/ROW]
[ROW][C]30[/C][C]169.29[/C][C]170.31[/C][C]-1.02000000000004[/C][/ROW]
[ROW][C]31[/C][C]169.21[/C][C]167.942[/C][C]1.26799999999997[/C][/ROW]
[ROW][C]32[/C][C]168.58[/C][C]167.942[/C][C]0.637999999999977[/C][/ROW]
[ROW][C]33[/C][C]168.58[/C][C]167.942[/C][C]0.637999999999977[/C][/ROW]
[ROW][C]34[/C][C]168.55[/C][C]167.942[/C][C]0.607999999999976[/C][/ROW]
[ROW][C]35[/C][C]168.46[/C][C]167.942[/C][C]0.517999999999972[/C][/ROW]
[ROW][C]36[/C][C]167.39[/C][C]167.942[/C][C]-0.552000000000049[/C][/ROW]
[ROW][C]37[/C][C]167.16[/C][C]167.942[/C][C]-0.782000000000039[/C][/ROW]
[ROW][C]38[/C][C]167.16[/C][C]167.942[/C][C]-0.782000000000039[/C][/ROW]
[ROW][C]39[/C][C]167.16[/C][C]167.942[/C][C]-0.782000000000039[/C][/ROW]
[ROW][C]40[/C][C]167.17[/C][C]167.942[/C][C]-0.772000000000048[/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=114681&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=114681&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.0281818181818210
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.73999999999998
13171.07170.310.759999999999962
14171.07170.310.759999999999962
15171.07170.310.759999999999962
16171.11170.310.799999999999983
17170.72170.310.409999999999968
18170.49170.310.179999999999978
19170.48170.310.169999999999959
20170.48170.310.169999999999959
21170.48170.310.169999999999959
22170.57170.310.259999999999962
23170.39170.310.0799999999999557
24170.04170.31-0.270000000000039
25169.67170.31-0.640000000000043
26169.57170.31-0.740000000000038
27169.57170.31-0.740000000000038
28169.53170.31-0.78000000000003
29169.24170.31-1.07000000000002
30169.29170.31-1.02000000000004
31169.21167.9421.26799999999997
32168.58167.9420.637999999999977
33168.58167.9420.637999999999977
34168.55167.9420.607999999999976
35168.46167.9420.517999999999972
36167.39167.942-0.552000000000049
37167.16167.942-0.782000000000039
38167.16167.942-0.782000000000039
39167.16167.942-0.782000000000039
40167.17167.942-0.772000000000048
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')
}