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 computationMon, 27 Dec 2010 10:11:42 +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/27/t12934446156wzsucyw372gw94.htm/, Retrieved Mon, 06 May 2024 11:41:23 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=115880, Retrieved Mon, 06 May 2024 11:41:23 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywordszonder categorization
Estimated Impact197
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] [58af523ef9b33032fd2497c80088399b]
-    D        [Recursive Partitioning (Regression Trees)] [recursive partiti...] [2010-12-27 10:11:42] [ea05999e24dc6223e14cc730e7a15b1e] [Current]
Feedback Forum

Post a new message
Dataseries X:
14450609152	9119000
15369578496	9166000
16440317952	9218000
17674829824	9283000
19782035456	9367000
21531359232	9448000
23118405632	9508000
24779487232	9557000
26495297536	9590000
29388689408	9613000
32676600000	9638000
35799700000	9673000
40077000000	9709000
45536800000	9738000
53409700000	9768000
59108700000	9795000
67180700000	9811000
72656600000	9822000
78026600000	9830000
83450800000	9837000
90756100000	9847000
95153800000	9852000
102966000000	9856000
109085000000	9856000
117854000000	9853000
125345000000	9858000
131200000000	9862000
136486000000	9870000
146033000000	9902000
158348000000	9938000
167909000000	9967400
175906000000	10004500
184714000000	10045000
190243000000	10084500
200495000000	10115600
207782000000	10136800
211399000000	10157000
221184000000	10181000
229572000000	10203000
238248000000	10226000
251741000000	10252000
258883000000	10287000
267652000000	10333000
274726000000	10376080,14
290825000000	10421120,61
302845000000	10478650
318193000000	10547958
334948000000	10625700
344676000000	10708433
337284000000	10788760




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
R Framework error message
The field 'Names of X columns' contains a hard return which cannot be interpreted.
Please, resubmit your request without hard returns in the 'Names of X columns'.

\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
R Framework error message & 
The field 'Names of X columns' contains a hard return which cannot be interpreted.
Please, resubmit your request without hard returns in the 'Names of X columns'.
\tabularnewline \hline \end{tabular} %Source: https://freestatistics.org/blog/index.php?pk=115880&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]
[ROW][C]R Framework error message[/C][C]
The field 'Names of X columns' contains a hard return which cannot be interpreted.
Please, resubmit your request without hard returns in the 'Names of X columns'.
[/C][/ROW] [/TABLE] Source: https://freestatistics.org/blog/index.php?pk=115880&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=115880&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
R Framework error message
The field 'Names of X columns' contains a hard return which cannot be interpreted.
Please, resubmit your request without hard returns in the 'Names of X columns'.







Goodness of Fit
Correlation0.9228
R-squared0.8515
RMSE147832.6457

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

[TABLE]
[ROW][C]Goodness of Fit[/C][/ROW]
[ROW][C]Correlation[/C][C]0.9228[/C][/ROW]
[ROW][C]R-squared[/C][C]0.8515[/C][/ROW]
[ROW][C]RMSE[/C][C]147832.6457[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=115880&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=115880&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.9228
R-squared0.8515
RMSE147832.6457







Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
191190009333250-214250
291660009333250-167250
392180009333250-115250
492830009333250-50250
59367000933325033750
694480009333250114750
795080009333250174750
895570009333250223750
995900009675571.42857143-85571.4285714291
1096130009675571.42857143-62571.4285714291
1196380009675571.42857143-37571.4285714291
1296730009675571.42857143-2571.4285714291
1397090009675571.4285714333428.5714285709
1497380009675571.4285714362428.5714285709
1597680009675571.4285714392428.5714285709
1697950009868288.23529412-73288.2352941185
1798110009868288.23529412-57288.2352941185
1898220009868288.23529412-46288.2352941185
1998300009868288.23529412-38288.2352941185
2098370009868288.23529412-31288.2352941185
2198470009868288.23529412-21288.2352941185
2298520009868288.23529412-16288.2352941185
2398560009868288.23529412-12288.2352941185
2498560009868288.23529412-12288.2352941185
2598530009868288.23529412-15288.2352941185
2698580009868288.23529412-10288.2352941185
2798620009868288.23529412-6288.23529411852
2898700009868288.235294121711.76470588148
2999020009868288.2352941233711.7647058815
3099380009868288.2352941269711.7647058815
3199674009868288.2352941299111.7647058815
32100045009868288.23529412136211.764705881
331004500010331533.4305556-286533.430555556
341008450010331533.4305556-247033.430555556
351011560010331533.4305556-215933.430555556
361013680010331533.4305556-194733.430555556
371015700010331533.4305556-174533.430555556
381018100010331533.4305556-150533.430555556
391020300010331533.4305556-128533.430555556
401022600010331533.4305556-105533.430555556
411025200010331533.4305556-79533.430555556
421028700010331533.4305556-44533.430555556
431033300010331533.43055561466.56944444403
4410376080.1410331533.430555644546.7094444446
4510421120.6110331533.430555689587.1794444434
461047865010331533.4305556147116.569444444
471054795810331533.4305556216424.569444444
481062570010331533.4305556294166.569444444
491070843310331533.4305556376899.569444444
501078876010331533.4305556457226.569444444

\begin{tabular}{lllllllll}
\hline
Actuals, Predictions, and Residuals \tabularnewline
# & Actuals & Forecasts & Residuals \tabularnewline
1 & 9119000 & 9333250 & -214250 \tabularnewline
2 & 9166000 & 9333250 & -167250 \tabularnewline
3 & 9218000 & 9333250 & -115250 \tabularnewline
4 & 9283000 & 9333250 & -50250 \tabularnewline
5 & 9367000 & 9333250 & 33750 \tabularnewline
6 & 9448000 & 9333250 & 114750 \tabularnewline
7 & 9508000 & 9333250 & 174750 \tabularnewline
8 & 9557000 & 9333250 & 223750 \tabularnewline
9 & 9590000 & 9675571.42857143 & -85571.4285714291 \tabularnewline
10 & 9613000 & 9675571.42857143 & -62571.4285714291 \tabularnewline
11 & 9638000 & 9675571.42857143 & -37571.4285714291 \tabularnewline
12 & 9673000 & 9675571.42857143 & -2571.4285714291 \tabularnewline
13 & 9709000 & 9675571.42857143 & 33428.5714285709 \tabularnewline
14 & 9738000 & 9675571.42857143 & 62428.5714285709 \tabularnewline
15 & 9768000 & 9675571.42857143 & 92428.5714285709 \tabularnewline
16 & 9795000 & 9868288.23529412 & -73288.2352941185 \tabularnewline
17 & 9811000 & 9868288.23529412 & -57288.2352941185 \tabularnewline
18 & 9822000 & 9868288.23529412 & -46288.2352941185 \tabularnewline
19 & 9830000 & 9868288.23529412 & -38288.2352941185 \tabularnewline
20 & 9837000 & 9868288.23529412 & -31288.2352941185 \tabularnewline
21 & 9847000 & 9868288.23529412 & -21288.2352941185 \tabularnewline
22 & 9852000 & 9868288.23529412 & -16288.2352941185 \tabularnewline
23 & 9856000 & 9868288.23529412 & -12288.2352941185 \tabularnewline
24 & 9856000 & 9868288.23529412 & -12288.2352941185 \tabularnewline
25 & 9853000 & 9868288.23529412 & -15288.2352941185 \tabularnewline
26 & 9858000 & 9868288.23529412 & -10288.2352941185 \tabularnewline
27 & 9862000 & 9868288.23529412 & -6288.23529411852 \tabularnewline
28 & 9870000 & 9868288.23529412 & 1711.76470588148 \tabularnewline
29 & 9902000 & 9868288.23529412 & 33711.7647058815 \tabularnewline
30 & 9938000 & 9868288.23529412 & 69711.7647058815 \tabularnewline
31 & 9967400 & 9868288.23529412 & 99111.7647058815 \tabularnewline
32 & 10004500 & 9868288.23529412 & 136211.764705881 \tabularnewline
33 & 10045000 & 10331533.4305556 & -286533.430555556 \tabularnewline
34 & 10084500 & 10331533.4305556 & -247033.430555556 \tabularnewline
35 & 10115600 & 10331533.4305556 & -215933.430555556 \tabularnewline
36 & 10136800 & 10331533.4305556 & -194733.430555556 \tabularnewline
37 & 10157000 & 10331533.4305556 & -174533.430555556 \tabularnewline
38 & 10181000 & 10331533.4305556 & -150533.430555556 \tabularnewline
39 & 10203000 & 10331533.4305556 & -128533.430555556 \tabularnewline
40 & 10226000 & 10331533.4305556 & -105533.430555556 \tabularnewline
41 & 10252000 & 10331533.4305556 & -79533.430555556 \tabularnewline
42 & 10287000 & 10331533.4305556 & -44533.430555556 \tabularnewline
43 & 10333000 & 10331533.4305556 & 1466.56944444403 \tabularnewline
44 & 10376080.14 & 10331533.4305556 & 44546.7094444446 \tabularnewline
45 & 10421120.61 & 10331533.4305556 & 89587.1794444434 \tabularnewline
46 & 10478650 & 10331533.4305556 & 147116.569444444 \tabularnewline
47 & 10547958 & 10331533.4305556 & 216424.569444444 \tabularnewline
48 & 10625700 & 10331533.4305556 & 294166.569444444 \tabularnewline
49 & 10708433 & 10331533.4305556 & 376899.569444444 \tabularnewline
50 & 10788760 & 10331533.4305556 & 457226.569444444 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=115880&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]9119000[/C][C]9333250[/C][C]-214250[/C][/ROW]
[ROW][C]2[/C][C]9166000[/C][C]9333250[/C][C]-167250[/C][/ROW]
[ROW][C]3[/C][C]9218000[/C][C]9333250[/C][C]-115250[/C][/ROW]
[ROW][C]4[/C][C]9283000[/C][C]9333250[/C][C]-50250[/C][/ROW]
[ROW][C]5[/C][C]9367000[/C][C]9333250[/C][C]33750[/C][/ROW]
[ROW][C]6[/C][C]9448000[/C][C]9333250[/C][C]114750[/C][/ROW]
[ROW][C]7[/C][C]9508000[/C][C]9333250[/C][C]174750[/C][/ROW]
[ROW][C]8[/C][C]9557000[/C][C]9333250[/C][C]223750[/C][/ROW]
[ROW][C]9[/C][C]9590000[/C][C]9675571.42857143[/C][C]-85571.4285714291[/C][/ROW]
[ROW][C]10[/C][C]9613000[/C][C]9675571.42857143[/C][C]-62571.4285714291[/C][/ROW]
[ROW][C]11[/C][C]9638000[/C][C]9675571.42857143[/C][C]-37571.4285714291[/C][/ROW]
[ROW][C]12[/C][C]9673000[/C][C]9675571.42857143[/C][C]-2571.4285714291[/C][/ROW]
[ROW][C]13[/C][C]9709000[/C][C]9675571.42857143[/C][C]33428.5714285709[/C][/ROW]
[ROW][C]14[/C][C]9738000[/C][C]9675571.42857143[/C][C]62428.5714285709[/C][/ROW]
[ROW][C]15[/C][C]9768000[/C][C]9675571.42857143[/C][C]92428.5714285709[/C][/ROW]
[ROW][C]16[/C][C]9795000[/C][C]9868288.23529412[/C][C]-73288.2352941185[/C][/ROW]
[ROW][C]17[/C][C]9811000[/C][C]9868288.23529412[/C][C]-57288.2352941185[/C][/ROW]
[ROW][C]18[/C][C]9822000[/C][C]9868288.23529412[/C][C]-46288.2352941185[/C][/ROW]
[ROW][C]19[/C][C]9830000[/C][C]9868288.23529412[/C][C]-38288.2352941185[/C][/ROW]
[ROW][C]20[/C][C]9837000[/C][C]9868288.23529412[/C][C]-31288.2352941185[/C][/ROW]
[ROW][C]21[/C][C]9847000[/C][C]9868288.23529412[/C][C]-21288.2352941185[/C][/ROW]
[ROW][C]22[/C][C]9852000[/C][C]9868288.23529412[/C][C]-16288.2352941185[/C][/ROW]
[ROW][C]23[/C][C]9856000[/C][C]9868288.23529412[/C][C]-12288.2352941185[/C][/ROW]
[ROW][C]24[/C][C]9856000[/C][C]9868288.23529412[/C][C]-12288.2352941185[/C][/ROW]
[ROW][C]25[/C][C]9853000[/C][C]9868288.23529412[/C][C]-15288.2352941185[/C][/ROW]
[ROW][C]26[/C][C]9858000[/C][C]9868288.23529412[/C][C]-10288.2352941185[/C][/ROW]
[ROW][C]27[/C][C]9862000[/C][C]9868288.23529412[/C][C]-6288.23529411852[/C][/ROW]
[ROW][C]28[/C][C]9870000[/C][C]9868288.23529412[/C][C]1711.76470588148[/C][/ROW]
[ROW][C]29[/C][C]9902000[/C][C]9868288.23529412[/C][C]33711.7647058815[/C][/ROW]
[ROW][C]30[/C][C]9938000[/C][C]9868288.23529412[/C][C]69711.7647058815[/C][/ROW]
[ROW][C]31[/C][C]9967400[/C][C]9868288.23529412[/C][C]99111.7647058815[/C][/ROW]
[ROW][C]32[/C][C]10004500[/C][C]9868288.23529412[/C][C]136211.764705881[/C][/ROW]
[ROW][C]33[/C][C]10045000[/C][C]10331533.4305556[/C][C]-286533.430555556[/C][/ROW]
[ROW][C]34[/C][C]10084500[/C][C]10331533.4305556[/C][C]-247033.430555556[/C][/ROW]
[ROW][C]35[/C][C]10115600[/C][C]10331533.4305556[/C][C]-215933.430555556[/C][/ROW]
[ROW][C]36[/C][C]10136800[/C][C]10331533.4305556[/C][C]-194733.430555556[/C][/ROW]
[ROW][C]37[/C][C]10157000[/C][C]10331533.4305556[/C][C]-174533.430555556[/C][/ROW]
[ROW][C]38[/C][C]10181000[/C][C]10331533.4305556[/C][C]-150533.430555556[/C][/ROW]
[ROW][C]39[/C][C]10203000[/C][C]10331533.4305556[/C][C]-128533.430555556[/C][/ROW]
[ROW][C]40[/C][C]10226000[/C][C]10331533.4305556[/C][C]-105533.430555556[/C][/ROW]
[ROW][C]41[/C][C]10252000[/C][C]10331533.4305556[/C][C]-79533.430555556[/C][/ROW]
[ROW][C]42[/C][C]10287000[/C][C]10331533.4305556[/C][C]-44533.430555556[/C][/ROW]
[ROW][C]43[/C][C]10333000[/C][C]10331533.4305556[/C][C]1466.56944444403[/C][/ROW]
[ROW][C]44[/C][C]10376080.14[/C][C]10331533.4305556[/C][C]44546.7094444446[/C][/ROW]
[ROW][C]45[/C][C]10421120.61[/C][C]10331533.4305556[/C][C]89587.1794444434[/C][/ROW]
[ROW][C]46[/C][C]10478650[/C][C]10331533.4305556[/C][C]147116.569444444[/C][/ROW]
[ROW][C]47[/C][C]10547958[/C][C]10331533.4305556[/C][C]216424.569444444[/C][/ROW]
[ROW][C]48[/C][C]10625700[/C][C]10331533.4305556[/C][C]294166.569444444[/C][/ROW]
[ROW][C]49[/C][C]10708433[/C][C]10331533.4305556[/C][C]376899.569444444[/C][/ROW]
[ROW][C]50[/C][C]10788760[/C][C]10331533.4305556[/C][C]457226.569444444[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=115880&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=115880&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
191190009333250-214250
291660009333250-167250
392180009333250-115250
492830009333250-50250
59367000933325033750
694480009333250114750
795080009333250174750
895570009333250223750
995900009675571.42857143-85571.4285714291
1096130009675571.42857143-62571.4285714291
1196380009675571.42857143-37571.4285714291
1296730009675571.42857143-2571.4285714291
1397090009675571.4285714333428.5714285709
1497380009675571.4285714362428.5714285709
1597680009675571.4285714392428.5714285709
1697950009868288.23529412-73288.2352941185
1798110009868288.23529412-57288.2352941185
1898220009868288.23529412-46288.2352941185
1998300009868288.23529412-38288.2352941185
2098370009868288.23529412-31288.2352941185
2198470009868288.23529412-21288.2352941185
2298520009868288.23529412-16288.2352941185
2398560009868288.23529412-12288.2352941185
2498560009868288.23529412-12288.2352941185
2598530009868288.23529412-15288.2352941185
2698580009868288.23529412-10288.2352941185
2798620009868288.23529412-6288.23529411852
2898700009868288.235294121711.76470588148
2999020009868288.2352941233711.7647058815
3099380009868288.2352941269711.7647058815
3199674009868288.2352941299111.7647058815
32100045009868288.23529412136211.764705881
331004500010331533.4305556-286533.430555556
341008450010331533.4305556-247033.430555556
351011560010331533.4305556-215933.430555556
361013680010331533.4305556-194733.430555556
371015700010331533.4305556-174533.430555556
381018100010331533.4305556-150533.430555556
391020300010331533.4305556-128533.430555556
401022600010331533.4305556-105533.430555556
411025200010331533.4305556-79533.430555556
421028700010331533.4305556-44533.430555556
431033300010331533.43055561466.56944444403
4410376080.1410331533.430555644546.7094444446
4510421120.6110331533.430555689587.1794444434
461047865010331533.4305556147116.569444444
471054795810331533.4305556216424.569444444
481062570010331533.4305556294166.569444444
491070843310331533.4305556376899.569444444
501078876010331533.4305556457226.569444444



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