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 computationTue, 21 Dec 2010 18:22:57 +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/21/t12929557191w1hhmvl5cmdrag.htm/, Retrieved Sun, 19 May 2024 21:01:22 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=113803, Retrieved Sun, 19 May 2024 21:01:22 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact100
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
-       [Recursive Partitioning (Regression Trees)] [Paper: Recursive ...] [2010-12-21 18:22:57] [6f3869f9d1e39c73f93153f1f7803f84] [Current]
Feedback Forum

Post a new message
Dataseries X:
695	0	641	696	729	839	627	608
638	0	695	641	696	729	696	651
762	0	638	695	641	696	825	691
635	0	762	638	695	641	677	627
721	0	635	762	638	695	656	634
854	0	721	635	762	638	785	731
418	0	854	721	635	762	412	475
367	0	418	854	721	635	352	337
824	0	367	418	854	721	839	803
687	0	824	367	418	854	729	722
601	0	687	824	367	418	696	590
676	0	601	687	824	367	641	724
740	0	676	601	687	824	695	627
691	0	740	676	601	687	638	696
683	0	691	740	676	601	762	825
594	0	683	691	740	676	635	677
729	0	594	683	691	740	721	656
731	0	729	594	683	691	854	785
386	0	731	729	594	683	418	412
331	0	386	731	729	594	367	352
706	0	331	386	731	729	824	839
715	0	706	331	386	731	687	729
657	0	715	706	331	386	601	696
653	0	657	715	706	331	676	641
642	0	653	657	715	706	740	695
643	0	642	653	657	715	691	638
718	0	643	642	653	657	683	762
654	0	718	643	642	653	594	635
632	0	654	718	643	642	729	721
731	0	632	654	718	643	731	854
392	1	731	632	654	718	386	418
344	1	392	731	632	654	331	367
792	1	344	392	731	632	706	824
852	1	792	344	392	731	715	687
649	1	852	792	344	392	657	601
629	1	649	852	792	344	653	676
685	1	629	649	852	792	642	740
617	1	685	629	649	852	643	691
715	1	617	685	629	649	718	683
715	1	715	617	685	629	654	594
629	1	715	715	617	685	632	729
916	1	629	715	715	617	731	731
531	1	916	629	715	715	392	386
357	1	531	916	629	715	344	331
917	1	357	531	916	629	792	706
828	1	917	357	531	916	852	715
708	1	828	917	357	531	649	657
858	1	708	828	917	357	629	653
775	1	858	708	828	917	685	642
785	1	775	858	708	828	617	643
1006	1	785	775	858	708	715	718
789	1	1006	785	775	858	715	654
734	1	789	1006	785	775	629	632
906	1	734	789	1006	785	916	731
532	1	906	734	789	1006	531	392
387	1	532	906	734	789	357	344
991	1	387	532	906	734	917	792
841	1	991	387	532	906	828	852
892	1	841	991	387	532	708	649
782	1	892	841	991	387	858	629




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time5 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135
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 & 5 seconds \tabularnewline
R Server & 'Gwilym Jenkins' @ 72.249.127.135 \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=113803&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]'Gwilym Jenkins' @ 72.249.127.135[/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=113803&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=113803&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'Gwilym Jenkins' @ 72.249.127.135
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.9036
R-squared0.8165
RMSE67.5998

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

[TABLE]
[ROW][C]Goodness of Fit[/C][/ROW]
[ROW][C]Correlation[/C][C]0.9036[/C][/ROW]
[ROW][C]R-squared[/C][C]0.8165[/C][/ROW]
[ROW][C]RMSE[/C][C]67.5998[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=113803&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=113803&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.9036
R-squared0.8165
RMSE67.5998







Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
1695685.1923076923089.80769230769226
2638685.192307692308-47.1923076923077
3762725.54545454545536.4545454545455
4635685.192307692308-50.1923076923077
5721685.19230769230835.8076923076923
6854725.545454545455128.454545454545
7418404.513.5
8367404.5-37.5
9824725.54545454545598.4545454545455
10687725.545454545455-38.5454545454545
11601685.192307692308-84.1923076923077
12676685.192307692308-9.19230769230774
13740685.19230769230854.8076923076923
14691685.1923076923085.80769230769226
15683725.545454545455-42.5454545454545
16594685.192307692308-91.1923076923077
17729725.5454545454553.4545454545455
18731725.5454545454555.4545454545455
19386404.5-18.5
20331404.5-73.5
21706725.545454545455-19.5454545454545
22715685.19230769230829.8076923076923
23657685.192307692308-28.1923076923077
24653685.192307692308-32.1923076923077
25642725.545454545455-83.5454545454545
26643685.192307692308-42.1923076923077
27718685.19230769230832.8076923076923
28654685.192307692308-31.1923076923077
29632725.545454545455-93.5454545454545
30731725.5454545454555.4545454545455
31392404.5-12.5
32344404.5-60.5
33792863.615384615385-71.6153846153846
34852863.615384615385-11.6153846153846
35649685.192307692308-36.1923076923077
36629685.192307692308-56.1923076923077
37685685.192307692308-0.192307692307736
38617685.192307692308-68.1923076923077
39715863.615384615385-148.615384615385
40715685.19230769230829.8076923076923
41629685.192307692308-56.1923076923077
42916863.61538461538552.3846153846154
43531404.5126.5
44357404.5-47.5
45917863.61538461538553.3846153846154
46828863.615384615385-35.6153846153846
47708685.19230769230822.8076923076923
48858685.192307692308172.807692307692
49775685.19230769230889.8076923076923
50785685.19230769230899.8076923076923
511006863.615384615385142.384615384615
52789863.615384615385-74.6153846153846
53734685.19230769230848.8076923076923
54906863.61538461538542.3846153846154
55532404.5127.5
56387404.5-17.5
57991863.615384615385127.384615384615
58841863.615384615385-22.6153846153846
59892863.61538461538528.3846153846154
60782863.615384615385-81.6153846153846

\begin{tabular}{lllllllll}
\hline
Actuals, Predictions, and Residuals \tabularnewline
# & Actuals & Forecasts & Residuals \tabularnewline
1 & 695 & 685.192307692308 & 9.80769230769226 \tabularnewline
2 & 638 & 685.192307692308 & -47.1923076923077 \tabularnewline
3 & 762 & 725.545454545455 & 36.4545454545455 \tabularnewline
4 & 635 & 685.192307692308 & -50.1923076923077 \tabularnewline
5 & 721 & 685.192307692308 & 35.8076923076923 \tabularnewline
6 & 854 & 725.545454545455 & 128.454545454545 \tabularnewline
7 & 418 & 404.5 & 13.5 \tabularnewline
8 & 367 & 404.5 & -37.5 \tabularnewline
9 & 824 & 725.545454545455 & 98.4545454545455 \tabularnewline
10 & 687 & 725.545454545455 & -38.5454545454545 \tabularnewline
11 & 601 & 685.192307692308 & -84.1923076923077 \tabularnewline
12 & 676 & 685.192307692308 & -9.19230769230774 \tabularnewline
13 & 740 & 685.192307692308 & 54.8076923076923 \tabularnewline
14 & 691 & 685.192307692308 & 5.80769230769226 \tabularnewline
15 & 683 & 725.545454545455 & -42.5454545454545 \tabularnewline
16 & 594 & 685.192307692308 & -91.1923076923077 \tabularnewline
17 & 729 & 725.545454545455 & 3.4545454545455 \tabularnewline
18 & 731 & 725.545454545455 & 5.4545454545455 \tabularnewline
19 & 386 & 404.5 & -18.5 \tabularnewline
20 & 331 & 404.5 & -73.5 \tabularnewline
21 & 706 & 725.545454545455 & -19.5454545454545 \tabularnewline
22 & 715 & 685.192307692308 & 29.8076923076923 \tabularnewline
23 & 657 & 685.192307692308 & -28.1923076923077 \tabularnewline
24 & 653 & 685.192307692308 & -32.1923076923077 \tabularnewline
25 & 642 & 725.545454545455 & -83.5454545454545 \tabularnewline
26 & 643 & 685.192307692308 & -42.1923076923077 \tabularnewline
27 & 718 & 685.192307692308 & 32.8076923076923 \tabularnewline
28 & 654 & 685.192307692308 & -31.1923076923077 \tabularnewline
29 & 632 & 725.545454545455 & -93.5454545454545 \tabularnewline
30 & 731 & 725.545454545455 & 5.4545454545455 \tabularnewline
31 & 392 & 404.5 & -12.5 \tabularnewline
32 & 344 & 404.5 & -60.5 \tabularnewline
33 & 792 & 863.615384615385 & -71.6153846153846 \tabularnewline
34 & 852 & 863.615384615385 & -11.6153846153846 \tabularnewline
35 & 649 & 685.192307692308 & -36.1923076923077 \tabularnewline
36 & 629 & 685.192307692308 & -56.1923076923077 \tabularnewline
37 & 685 & 685.192307692308 & -0.192307692307736 \tabularnewline
38 & 617 & 685.192307692308 & -68.1923076923077 \tabularnewline
39 & 715 & 863.615384615385 & -148.615384615385 \tabularnewline
40 & 715 & 685.192307692308 & 29.8076923076923 \tabularnewline
41 & 629 & 685.192307692308 & -56.1923076923077 \tabularnewline
42 & 916 & 863.615384615385 & 52.3846153846154 \tabularnewline
43 & 531 & 404.5 & 126.5 \tabularnewline
44 & 357 & 404.5 & -47.5 \tabularnewline
45 & 917 & 863.615384615385 & 53.3846153846154 \tabularnewline
46 & 828 & 863.615384615385 & -35.6153846153846 \tabularnewline
47 & 708 & 685.192307692308 & 22.8076923076923 \tabularnewline
48 & 858 & 685.192307692308 & 172.807692307692 \tabularnewline
49 & 775 & 685.192307692308 & 89.8076923076923 \tabularnewline
50 & 785 & 685.192307692308 & 99.8076923076923 \tabularnewline
51 & 1006 & 863.615384615385 & 142.384615384615 \tabularnewline
52 & 789 & 863.615384615385 & -74.6153846153846 \tabularnewline
53 & 734 & 685.192307692308 & 48.8076923076923 \tabularnewline
54 & 906 & 863.615384615385 & 42.3846153846154 \tabularnewline
55 & 532 & 404.5 & 127.5 \tabularnewline
56 & 387 & 404.5 & -17.5 \tabularnewline
57 & 991 & 863.615384615385 & 127.384615384615 \tabularnewline
58 & 841 & 863.615384615385 & -22.6153846153846 \tabularnewline
59 & 892 & 863.615384615385 & 28.3846153846154 \tabularnewline
60 & 782 & 863.615384615385 & -81.6153846153846 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=113803&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]695[/C][C]685.192307692308[/C][C]9.80769230769226[/C][/ROW]
[ROW][C]2[/C][C]638[/C][C]685.192307692308[/C][C]-47.1923076923077[/C][/ROW]
[ROW][C]3[/C][C]762[/C][C]725.545454545455[/C][C]36.4545454545455[/C][/ROW]
[ROW][C]4[/C][C]635[/C][C]685.192307692308[/C][C]-50.1923076923077[/C][/ROW]
[ROW][C]5[/C][C]721[/C][C]685.192307692308[/C][C]35.8076923076923[/C][/ROW]
[ROW][C]6[/C][C]854[/C][C]725.545454545455[/C][C]128.454545454545[/C][/ROW]
[ROW][C]7[/C][C]418[/C][C]404.5[/C][C]13.5[/C][/ROW]
[ROW][C]8[/C][C]367[/C][C]404.5[/C][C]-37.5[/C][/ROW]
[ROW][C]9[/C][C]824[/C][C]725.545454545455[/C][C]98.4545454545455[/C][/ROW]
[ROW][C]10[/C][C]687[/C][C]725.545454545455[/C][C]-38.5454545454545[/C][/ROW]
[ROW][C]11[/C][C]601[/C][C]685.192307692308[/C][C]-84.1923076923077[/C][/ROW]
[ROW][C]12[/C][C]676[/C][C]685.192307692308[/C][C]-9.19230769230774[/C][/ROW]
[ROW][C]13[/C][C]740[/C][C]685.192307692308[/C][C]54.8076923076923[/C][/ROW]
[ROW][C]14[/C][C]691[/C][C]685.192307692308[/C][C]5.80769230769226[/C][/ROW]
[ROW][C]15[/C][C]683[/C][C]725.545454545455[/C][C]-42.5454545454545[/C][/ROW]
[ROW][C]16[/C][C]594[/C][C]685.192307692308[/C][C]-91.1923076923077[/C][/ROW]
[ROW][C]17[/C][C]729[/C][C]725.545454545455[/C][C]3.4545454545455[/C][/ROW]
[ROW][C]18[/C][C]731[/C][C]725.545454545455[/C][C]5.4545454545455[/C][/ROW]
[ROW][C]19[/C][C]386[/C][C]404.5[/C][C]-18.5[/C][/ROW]
[ROW][C]20[/C][C]331[/C][C]404.5[/C][C]-73.5[/C][/ROW]
[ROW][C]21[/C][C]706[/C][C]725.545454545455[/C][C]-19.5454545454545[/C][/ROW]
[ROW][C]22[/C][C]715[/C][C]685.192307692308[/C][C]29.8076923076923[/C][/ROW]
[ROW][C]23[/C][C]657[/C][C]685.192307692308[/C][C]-28.1923076923077[/C][/ROW]
[ROW][C]24[/C][C]653[/C][C]685.192307692308[/C][C]-32.1923076923077[/C][/ROW]
[ROW][C]25[/C][C]642[/C][C]725.545454545455[/C][C]-83.5454545454545[/C][/ROW]
[ROW][C]26[/C][C]643[/C][C]685.192307692308[/C][C]-42.1923076923077[/C][/ROW]
[ROW][C]27[/C][C]718[/C][C]685.192307692308[/C][C]32.8076923076923[/C][/ROW]
[ROW][C]28[/C][C]654[/C][C]685.192307692308[/C][C]-31.1923076923077[/C][/ROW]
[ROW][C]29[/C][C]632[/C][C]725.545454545455[/C][C]-93.5454545454545[/C][/ROW]
[ROW][C]30[/C][C]731[/C][C]725.545454545455[/C][C]5.4545454545455[/C][/ROW]
[ROW][C]31[/C][C]392[/C][C]404.5[/C][C]-12.5[/C][/ROW]
[ROW][C]32[/C][C]344[/C][C]404.5[/C][C]-60.5[/C][/ROW]
[ROW][C]33[/C][C]792[/C][C]863.615384615385[/C][C]-71.6153846153846[/C][/ROW]
[ROW][C]34[/C][C]852[/C][C]863.615384615385[/C][C]-11.6153846153846[/C][/ROW]
[ROW][C]35[/C][C]649[/C][C]685.192307692308[/C][C]-36.1923076923077[/C][/ROW]
[ROW][C]36[/C][C]629[/C][C]685.192307692308[/C][C]-56.1923076923077[/C][/ROW]
[ROW][C]37[/C][C]685[/C][C]685.192307692308[/C][C]-0.192307692307736[/C][/ROW]
[ROW][C]38[/C][C]617[/C][C]685.192307692308[/C][C]-68.1923076923077[/C][/ROW]
[ROW][C]39[/C][C]715[/C][C]863.615384615385[/C][C]-148.615384615385[/C][/ROW]
[ROW][C]40[/C][C]715[/C][C]685.192307692308[/C][C]29.8076923076923[/C][/ROW]
[ROW][C]41[/C][C]629[/C][C]685.192307692308[/C][C]-56.1923076923077[/C][/ROW]
[ROW][C]42[/C][C]916[/C][C]863.615384615385[/C][C]52.3846153846154[/C][/ROW]
[ROW][C]43[/C][C]531[/C][C]404.5[/C][C]126.5[/C][/ROW]
[ROW][C]44[/C][C]357[/C][C]404.5[/C][C]-47.5[/C][/ROW]
[ROW][C]45[/C][C]917[/C][C]863.615384615385[/C][C]53.3846153846154[/C][/ROW]
[ROW][C]46[/C][C]828[/C][C]863.615384615385[/C][C]-35.6153846153846[/C][/ROW]
[ROW][C]47[/C][C]708[/C][C]685.192307692308[/C][C]22.8076923076923[/C][/ROW]
[ROW][C]48[/C][C]858[/C][C]685.192307692308[/C][C]172.807692307692[/C][/ROW]
[ROW][C]49[/C][C]775[/C][C]685.192307692308[/C][C]89.8076923076923[/C][/ROW]
[ROW][C]50[/C][C]785[/C][C]685.192307692308[/C][C]99.8076923076923[/C][/ROW]
[ROW][C]51[/C][C]1006[/C][C]863.615384615385[/C][C]142.384615384615[/C][/ROW]
[ROW][C]52[/C][C]789[/C][C]863.615384615385[/C][C]-74.6153846153846[/C][/ROW]
[ROW][C]53[/C][C]734[/C][C]685.192307692308[/C][C]48.8076923076923[/C][/ROW]
[ROW][C]54[/C][C]906[/C][C]863.615384615385[/C][C]42.3846153846154[/C][/ROW]
[ROW][C]55[/C][C]532[/C][C]404.5[/C][C]127.5[/C][/ROW]
[ROW][C]56[/C][C]387[/C][C]404.5[/C][C]-17.5[/C][/ROW]
[ROW][C]57[/C][C]991[/C][C]863.615384615385[/C][C]127.384615384615[/C][/ROW]
[ROW][C]58[/C][C]841[/C][C]863.615384615385[/C][C]-22.6153846153846[/C][/ROW]
[ROW][C]59[/C][C]892[/C][C]863.615384615385[/C][C]28.3846153846154[/C][/ROW]
[ROW][C]60[/C][C]782[/C][C]863.615384615385[/C][C]-81.6153846153846[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=113803&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=113803&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
1695685.1923076923089.80769230769226
2638685.192307692308-47.1923076923077
3762725.54545454545536.4545454545455
4635685.192307692308-50.1923076923077
5721685.19230769230835.8076923076923
6854725.545454545455128.454545454545
7418404.513.5
8367404.5-37.5
9824725.54545454545598.4545454545455
10687725.545454545455-38.5454545454545
11601685.192307692308-84.1923076923077
12676685.192307692308-9.19230769230774
13740685.19230769230854.8076923076923
14691685.1923076923085.80769230769226
15683725.545454545455-42.5454545454545
16594685.192307692308-91.1923076923077
17729725.5454545454553.4545454545455
18731725.5454545454555.4545454545455
19386404.5-18.5
20331404.5-73.5
21706725.545454545455-19.5454545454545
22715685.19230769230829.8076923076923
23657685.192307692308-28.1923076923077
24653685.192307692308-32.1923076923077
25642725.545454545455-83.5454545454545
26643685.192307692308-42.1923076923077
27718685.19230769230832.8076923076923
28654685.192307692308-31.1923076923077
29632725.545454545455-93.5454545454545
30731725.5454545454555.4545454545455
31392404.5-12.5
32344404.5-60.5
33792863.615384615385-71.6153846153846
34852863.615384615385-11.6153846153846
35649685.192307692308-36.1923076923077
36629685.192307692308-56.1923076923077
37685685.192307692308-0.192307692307736
38617685.192307692308-68.1923076923077
39715863.615384615385-148.615384615385
40715685.19230769230829.8076923076923
41629685.192307692308-56.1923076923077
42916863.61538461538552.3846153846154
43531404.5126.5
44357404.5-47.5
45917863.61538461538553.3846153846154
46828863.615384615385-35.6153846153846
47708685.19230769230822.8076923076923
48858685.192307692308172.807692307692
49775685.19230769230889.8076923076923
50785685.19230769230899.8076923076923
511006863.615384615385142.384615384615
52789863.615384615385-74.6153846153846
53734685.19230769230848.8076923076923
54906863.61538461538542.3846153846154
55532404.5127.5
56387404.5-17.5
57991863.615384615385127.384615384615
58841863.615384615385-22.6153846153846
59892863.61538461538528.3846153846154
60782863.615384615385-81.6153846153846



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')
}