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:59:39 +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/t1293188277zkpr9wjcntrp0q7.htm/, Retrieved Tue, 30 Apr 2024 04:27:24 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=114750, Retrieved Tue, 30 Apr 2024 04:27:24 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact123
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)] [Recursive Partiti...] [2010-12-21 14:46:12] [f1bd7399181c649098ca7b814ee0e027]
-    D      [Recursive Partitioning (Regression Trees)] [Workshop 7] [2010-12-24 10:59:39] [d5e0edb7e0239841e94676417b2a1e2e] [Current]
Feedback Forum

Post a new message
Dataseries X:
6282929	213118	1081	162556
4324047	81767	309	29790
4108272	153198	458	87550
-1212617	-26007	588	84738
1485329	126942	299	54660
1779876	157214	156	42634
1367203	129352	481	40949
2519076	234817	323	42312
912684	60448	452	37704
1443586	47818	109	16275
1220017	245546	115	25830
984885	48020	110	12679
1457425	-1710	239	18014
-572920	32648	247	43556
929144	95350	497	24524
1151176	151352	103	6532
790090	288170	109	7123
774497	114337	502	20813
990576	37884	248	37597
454195	122844	373	17821
876607	82340	119	12988
711969	79801	84	22330
702380	165548	102	13326
264449	116384	295	16189
450033	134028	105	7146
541063	63838	64	15824
588864	74996	267	26088
-37216	31080	129	11326
783310	32168	37	8568
467359	49857	361	14416
688779	87161	28	3369
608419	106113	85	11819
696348	80570	44	6620
597793	102129	49	4519
821730	301670	22	2220
377934	102313	155	18562
651939	88577	91	10327
697458	112477	81	5336
700368	191778	79	2365
225986	79804	145	4069
348695	128294	816	7710
373683	96448	61	13718
501709	93811	226	4525
413743	117520	105	6869
379825	69159	62	4628
336260	101792	24	3653
636765	210568	26	1265
481231	136996	322	7489
469107	121920	84	4901
211928	76403	33	2284




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=114750&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=114750&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=114750&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.4838
R-squared0.2341
RMSE1021557.1061

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

[TABLE]
[ROW][C]Goodness of Fit[/C][/ROW]
[ROW][C]Correlation[/C][C]0.4838[/C][/ROW]
[ROW][C]R-squared[/C][C]0.2341[/C][/ROW]
[ROW][C]RMSE[/C][C]1021557.1061[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=114750&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=114750&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.4838
R-squared0.2341
RMSE1021557.1061







Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
162829291998586.818181824284342.18181818
243240471998586.818181822325460.18181818
341082721998586.818181822109685.18181818
4-12126171998586.81818182-3211203.81818182
514853291998586.81818182-513257.818181818
617798761998586.81818182-218710.818181818
713672031998586.81818182-631383.818181818
825190761998586.81818182520489.181818182
99126841998586.81818182-1085902.81818182
101443586635218.794871795808367.205128205
111220017635218.794871795584798.205128205
12984885635218.794871795349666.205128205
131457425635218.794871795822206.205128205
14-5729201998586.81818182-2571506.81818182
15929144635218.794871795293925.205128205
161151176635218.794871795515957.205128205
17790090635218.794871795154871.205128205
18774497635218.794871795139278.205128205
199905761998586.81818182-1008010.81818182
20454195635218.794871795-181023.794871795
21876607635218.794871795241388.205128205
22711969635218.79487179576750.2051282051
23702380635218.79487179567161.2051282051
24264449635218.794871795-370769.794871795
25450033635218.794871795-185185.794871795
26541063635218.794871795-94155.7948717949
27588864635218.794871795-46354.7948717949
28-37216635218.794871795-672434.794871795
29783310635218.794871795148091.205128205
30467359635218.794871795-167859.794871795
31688779635218.79487179553560.2051282051
32608419635218.794871795-26799.7948717949
33696348635218.79487179561129.2051282051
34597793635218.794871795-37425.7948717949
35821730635218.794871795186511.205128205
36377934635218.794871795-257284.794871795
37651939635218.79487179516720.2051282051
38697458635218.79487179562239.2051282051
39700368635218.79487179565149.2051282051
40225986635218.794871795-409232.794871795
41348695635218.794871795-286523.794871795
42373683635218.794871795-261535.794871795
43501709635218.794871795-133509.794871795
44413743635218.794871795-221475.794871795
45379825635218.794871795-255393.794871795
46336260635218.794871795-298958.794871795
47636765635218.7948717951546.20512820513
48481231635218.794871795-153987.794871795
49469107635218.794871795-166111.794871795
50211928635218.794871795-423290.794871795

\begin{tabular}{lllllllll}
\hline
Actuals, Predictions, and Residuals \tabularnewline
# & Actuals & Forecasts & Residuals \tabularnewline
1 & 6282929 & 1998586.81818182 & 4284342.18181818 \tabularnewline
2 & 4324047 & 1998586.81818182 & 2325460.18181818 \tabularnewline
3 & 4108272 & 1998586.81818182 & 2109685.18181818 \tabularnewline
4 & -1212617 & 1998586.81818182 & -3211203.81818182 \tabularnewline
5 & 1485329 & 1998586.81818182 & -513257.818181818 \tabularnewline
6 & 1779876 & 1998586.81818182 & -218710.818181818 \tabularnewline
7 & 1367203 & 1998586.81818182 & -631383.818181818 \tabularnewline
8 & 2519076 & 1998586.81818182 & 520489.181818182 \tabularnewline
9 & 912684 & 1998586.81818182 & -1085902.81818182 \tabularnewline
10 & 1443586 & 635218.794871795 & 808367.205128205 \tabularnewline
11 & 1220017 & 635218.794871795 & 584798.205128205 \tabularnewline
12 & 984885 & 635218.794871795 & 349666.205128205 \tabularnewline
13 & 1457425 & 635218.794871795 & 822206.205128205 \tabularnewline
14 & -572920 & 1998586.81818182 & -2571506.81818182 \tabularnewline
15 & 929144 & 635218.794871795 & 293925.205128205 \tabularnewline
16 & 1151176 & 635218.794871795 & 515957.205128205 \tabularnewline
17 & 790090 & 635218.794871795 & 154871.205128205 \tabularnewline
18 & 774497 & 635218.794871795 & 139278.205128205 \tabularnewline
19 & 990576 & 1998586.81818182 & -1008010.81818182 \tabularnewline
20 & 454195 & 635218.794871795 & -181023.794871795 \tabularnewline
21 & 876607 & 635218.794871795 & 241388.205128205 \tabularnewline
22 & 711969 & 635218.794871795 & 76750.2051282051 \tabularnewline
23 & 702380 & 635218.794871795 & 67161.2051282051 \tabularnewline
24 & 264449 & 635218.794871795 & -370769.794871795 \tabularnewline
25 & 450033 & 635218.794871795 & -185185.794871795 \tabularnewline
26 & 541063 & 635218.794871795 & -94155.7948717949 \tabularnewline
27 & 588864 & 635218.794871795 & -46354.7948717949 \tabularnewline
28 & -37216 & 635218.794871795 & -672434.794871795 \tabularnewline
29 & 783310 & 635218.794871795 & 148091.205128205 \tabularnewline
30 & 467359 & 635218.794871795 & -167859.794871795 \tabularnewline
31 & 688779 & 635218.794871795 & 53560.2051282051 \tabularnewline
32 & 608419 & 635218.794871795 & -26799.7948717949 \tabularnewline
33 & 696348 & 635218.794871795 & 61129.2051282051 \tabularnewline
34 & 597793 & 635218.794871795 & -37425.7948717949 \tabularnewline
35 & 821730 & 635218.794871795 & 186511.205128205 \tabularnewline
36 & 377934 & 635218.794871795 & -257284.794871795 \tabularnewline
37 & 651939 & 635218.794871795 & 16720.2051282051 \tabularnewline
38 & 697458 & 635218.794871795 & 62239.2051282051 \tabularnewline
39 & 700368 & 635218.794871795 & 65149.2051282051 \tabularnewline
40 & 225986 & 635218.794871795 & -409232.794871795 \tabularnewline
41 & 348695 & 635218.794871795 & -286523.794871795 \tabularnewline
42 & 373683 & 635218.794871795 & -261535.794871795 \tabularnewline
43 & 501709 & 635218.794871795 & -133509.794871795 \tabularnewline
44 & 413743 & 635218.794871795 & -221475.794871795 \tabularnewline
45 & 379825 & 635218.794871795 & -255393.794871795 \tabularnewline
46 & 336260 & 635218.794871795 & -298958.794871795 \tabularnewline
47 & 636765 & 635218.794871795 & 1546.20512820513 \tabularnewline
48 & 481231 & 635218.794871795 & -153987.794871795 \tabularnewline
49 & 469107 & 635218.794871795 & -166111.794871795 \tabularnewline
50 & 211928 & 635218.794871795 & -423290.794871795 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=114750&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]6282929[/C][C]1998586.81818182[/C][C]4284342.18181818[/C][/ROW]
[ROW][C]2[/C][C]4324047[/C][C]1998586.81818182[/C][C]2325460.18181818[/C][/ROW]
[ROW][C]3[/C][C]4108272[/C][C]1998586.81818182[/C][C]2109685.18181818[/C][/ROW]
[ROW][C]4[/C][C]-1212617[/C][C]1998586.81818182[/C][C]-3211203.81818182[/C][/ROW]
[ROW][C]5[/C][C]1485329[/C][C]1998586.81818182[/C][C]-513257.818181818[/C][/ROW]
[ROW][C]6[/C][C]1779876[/C][C]1998586.81818182[/C][C]-218710.818181818[/C][/ROW]
[ROW][C]7[/C][C]1367203[/C][C]1998586.81818182[/C][C]-631383.818181818[/C][/ROW]
[ROW][C]8[/C][C]2519076[/C][C]1998586.81818182[/C][C]520489.181818182[/C][/ROW]
[ROW][C]9[/C][C]912684[/C][C]1998586.81818182[/C][C]-1085902.81818182[/C][/ROW]
[ROW][C]10[/C][C]1443586[/C][C]635218.794871795[/C][C]808367.205128205[/C][/ROW]
[ROW][C]11[/C][C]1220017[/C][C]635218.794871795[/C][C]584798.205128205[/C][/ROW]
[ROW][C]12[/C][C]984885[/C][C]635218.794871795[/C][C]349666.205128205[/C][/ROW]
[ROW][C]13[/C][C]1457425[/C][C]635218.794871795[/C][C]822206.205128205[/C][/ROW]
[ROW][C]14[/C][C]-572920[/C][C]1998586.81818182[/C][C]-2571506.81818182[/C][/ROW]
[ROW][C]15[/C][C]929144[/C][C]635218.794871795[/C][C]293925.205128205[/C][/ROW]
[ROW][C]16[/C][C]1151176[/C][C]635218.794871795[/C][C]515957.205128205[/C][/ROW]
[ROW][C]17[/C][C]790090[/C][C]635218.794871795[/C][C]154871.205128205[/C][/ROW]
[ROW][C]18[/C][C]774497[/C][C]635218.794871795[/C][C]139278.205128205[/C][/ROW]
[ROW][C]19[/C][C]990576[/C][C]1998586.81818182[/C][C]-1008010.81818182[/C][/ROW]
[ROW][C]20[/C][C]454195[/C][C]635218.794871795[/C][C]-181023.794871795[/C][/ROW]
[ROW][C]21[/C][C]876607[/C][C]635218.794871795[/C][C]241388.205128205[/C][/ROW]
[ROW][C]22[/C][C]711969[/C][C]635218.794871795[/C][C]76750.2051282051[/C][/ROW]
[ROW][C]23[/C][C]702380[/C][C]635218.794871795[/C][C]67161.2051282051[/C][/ROW]
[ROW][C]24[/C][C]264449[/C][C]635218.794871795[/C][C]-370769.794871795[/C][/ROW]
[ROW][C]25[/C][C]450033[/C][C]635218.794871795[/C][C]-185185.794871795[/C][/ROW]
[ROW][C]26[/C][C]541063[/C][C]635218.794871795[/C][C]-94155.7948717949[/C][/ROW]
[ROW][C]27[/C][C]588864[/C][C]635218.794871795[/C][C]-46354.7948717949[/C][/ROW]
[ROW][C]28[/C][C]-37216[/C][C]635218.794871795[/C][C]-672434.794871795[/C][/ROW]
[ROW][C]29[/C][C]783310[/C][C]635218.794871795[/C][C]148091.205128205[/C][/ROW]
[ROW][C]30[/C][C]467359[/C][C]635218.794871795[/C][C]-167859.794871795[/C][/ROW]
[ROW][C]31[/C][C]688779[/C][C]635218.794871795[/C][C]53560.2051282051[/C][/ROW]
[ROW][C]32[/C][C]608419[/C][C]635218.794871795[/C][C]-26799.7948717949[/C][/ROW]
[ROW][C]33[/C][C]696348[/C][C]635218.794871795[/C][C]61129.2051282051[/C][/ROW]
[ROW][C]34[/C][C]597793[/C][C]635218.794871795[/C][C]-37425.7948717949[/C][/ROW]
[ROW][C]35[/C][C]821730[/C][C]635218.794871795[/C][C]186511.205128205[/C][/ROW]
[ROW][C]36[/C][C]377934[/C][C]635218.794871795[/C][C]-257284.794871795[/C][/ROW]
[ROW][C]37[/C][C]651939[/C][C]635218.794871795[/C][C]16720.2051282051[/C][/ROW]
[ROW][C]38[/C][C]697458[/C][C]635218.794871795[/C][C]62239.2051282051[/C][/ROW]
[ROW][C]39[/C][C]700368[/C][C]635218.794871795[/C][C]65149.2051282051[/C][/ROW]
[ROW][C]40[/C][C]225986[/C][C]635218.794871795[/C][C]-409232.794871795[/C][/ROW]
[ROW][C]41[/C][C]348695[/C][C]635218.794871795[/C][C]-286523.794871795[/C][/ROW]
[ROW][C]42[/C][C]373683[/C][C]635218.794871795[/C][C]-261535.794871795[/C][/ROW]
[ROW][C]43[/C][C]501709[/C][C]635218.794871795[/C][C]-133509.794871795[/C][/ROW]
[ROW][C]44[/C][C]413743[/C][C]635218.794871795[/C][C]-221475.794871795[/C][/ROW]
[ROW][C]45[/C][C]379825[/C][C]635218.794871795[/C][C]-255393.794871795[/C][/ROW]
[ROW][C]46[/C][C]336260[/C][C]635218.794871795[/C][C]-298958.794871795[/C][/ROW]
[ROW][C]47[/C][C]636765[/C][C]635218.794871795[/C][C]1546.20512820513[/C][/ROW]
[ROW][C]48[/C][C]481231[/C][C]635218.794871795[/C][C]-153987.794871795[/C][/ROW]
[ROW][C]49[/C][C]469107[/C][C]635218.794871795[/C][C]-166111.794871795[/C][/ROW]
[ROW][C]50[/C][C]211928[/C][C]635218.794871795[/C][C]-423290.794871795[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=114750&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=114750&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
162829291998586.818181824284342.18181818
243240471998586.818181822325460.18181818
341082721998586.818181822109685.18181818
4-12126171998586.81818182-3211203.81818182
514853291998586.81818182-513257.818181818
617798761998586.81818182-218710.818181818
713672031998586.81818182-631383.818181818
825190761998586.81818182520489.181818182
99126841998586.81818182-1085902.81818182
101443586635218.794871795808367.205128205
111220017635218.794871795584798.205128205
12984885635218.794871795349666.205128205
131457425635218.794871795822206.205128205
14-5729201998586.81818182-2571506.81818182
15929144635218.794871795293925.205128205
161151176635218.794871795515957.205128205
17790090635218.794871795154871.205128205
18774497635218.794871795139278.205128205
199905761998586.81818182-1008010.81818182
20454195635218.794871795-181023.794871795
21876607635218.794871795241388.205128205
22711969635218.79487179576750.2051282051
23702380635218.79487179567161.2051282051
24264449635218.794871795-370769.794871795
25450033635218.794871795-185185.794871795
26541063635218.794871795-94155.7948717949
27588864635218.794871795-46354.7948717949
28-37216635218.794871795-672434.794871795
29783310635218.794871795148091.205128205
30467359635218.794871795-167859.794871795
31688779635218.79487179553560.2051282051
32608419635218.794871795-26799.7948717949
33696348635218.79487179561129.2051282051
34597793635218.794871795-37425.7948717949
35821730635218.794871795186511.205128205
36377934635218.794871795-257284.794871795
37651939635218.79487179516720.2051282051
38697458635218.79487179562239.2051282051
39700368635218.79487179565149.2051282051
40225986635218.794871795-409232.794871795
41348695635218.794871795-286523.794871795
42373683635218.794871795-261535.794871795
43501709635218.794871795-133509.794871795
44413743635218.794871795-221475.794871795
45379825635218.794871795-255393.794871795
46336260635218.794871795-298958.794871795
47636765635218.7948717951546.20512820513
48481231635218.794871795-153987.794871795
49469107635218.794871795-166111.794871795
50211928635218.794871795-423290.794871795



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