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, 14 Dec 2010 17:21:05 +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/14/t1292347148i9owisgjvgvhhw4.htm/, Retrieved Thu, 02 May 2024 17:16:33 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=109917, Retrieved Thu, 02 May 2024 17:16:33 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact140
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)] [Blog 4] [2010-12-14 17:21:05] [47bfda5353cd53c1cf7ea7aa9038654a] [Current]
-   P       [Recursive Partitioning (Regression Trees)] [Blog 5] [2010-12-15 08:35:28] [1aa8d85d6b335d32b1f6be940e33a166]
Feedback Forum

Post a new message
Dataseries X:
3.18	0.22	6.62	3.64
3.14	0.22	6.56	3.62
3.02	0.23	6.59	3.61
3.02	0.24	6.56	3.6
3.03	0.25	6.57	3.6
3.04	0.25	6.62	3.63
3.09	0.24	6.69	3.59
3.06	0.24	6.69	3.55
3.06	0.22	6.64	3.54
3.09	0.21	6.6	3.53
3.11	0.21	6.66	3.53
3.1	0.21	6.62	3.53
3.09	0.2	6.64	3.52
3.19	0.2	6.64	3.52
3.22	0.2	6.73	3.48
3.22	0.2	6.73	3.49
3.25	0.2	6.69	3.47
3.25	0.2	6.78	3.46
3.27	0.2	6.77	3.4
3.28	0.2	6.8	3.36
3.24	0.2	6.8	3.3
3.23	0.2	6.74	3.28
3.2	0.2	6.84	3.28
3.19	0.2	6.83	3.24
3.23	0.2	6.89	3.23
3.19	0.2	6.9	3.2
3.16	0.2	6.86	3.15
3.11	0.2	6.78	3.1
3.11	0.2	6.82	3.07
3.07	0.2	6.81	3.03
3.05	0.21	6.81	2.96
3	0.2	6.78	2.88
2.95	0.2	6.79	2.83
2.9	0.19	6.83	2.8
2.88	0.18	6.9	2.8
2.9	0.18	6.79	2.79
2.89	0.17	6.88	2.79
2.89	0.17	6.89	2.78
2.91	0.17	6.91	2.79
2.9	0.17	6.93	2.78
2.9	0.17	6.89	2.78
2.88	0.16	7	2.74
2.83	0.16	7.01	2.71
2.8	0.16	7.15	2.69
2.77	0.16	7.25	2.68
2.78	0.16	7.33	2.68
2.75	0.16	7.39	2.68
2.74	0.15	7.38	2.69
2.73	0.15	7.38	2.68
2.69	0.15	7.35	2.69
2.67	0.15	7.38	2.68
2.66	0.15	7.34	2.68
2.67	0.16	7.25	2.63
2.65	0.15	7.07	2.58
2.64	0.15	6.73	2.52
2.63	0.15	6.56	2.5




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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=109917&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.9573
R-squared0.9164
RMSE0.0566

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

[TABLE]
[ROW][C]Goodness of Fit[/C][/ROW]
[ROW][C]Correlation[/C][C]0.9573[/C][/ROW]
[ROW][C]R-squared[/C][C]0.9164[/C][/ROW]
[ROW][C]RMSE[/C][C]0.0566[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=109917&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=109917&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.9573
R-squared0.9164
RMSE0.0566







Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
13.183.076153846153850.103846153846154
23.143.076153846153850.0638461538461543
33.023.07615384615385-0.0561538461538458
43.023.07615384615385-0.0561538461538458
53.033.07615384615385-0.046153846153846
63.043.07615384615385-0.0361538461538458
73.093.076153846153850.0138461538461541
83.063.07615384615385-0.0161538461538457
93.063.07615384615385-0.0161538461538457
103.093.076153846153850.0138461538461541
113.113.076153846153850.0338461538461541
123.13.076153846153850.0238461538461543
133.093.18421052631579-0.094210526315789
143.193.184210526315790.00578947368421101
153.223.184210526315790.0357894736842113
163.223.184210526315790.0357894736842113
173.253.184210526315790.065789473684211
183.253.184210526315790.065789473684211
193.273.184210526315790.085789473684211
203.283.184210526315790.0957894736842109
213.243.184210526315790.0557894736842113
223.233.184210526315790.0457894736842110
233.23.184210526315790.0157894736842112
243.193.184210526315790.00578947368421101
253.233.184210526315790.0457894736842110
263.193.184210526315790.00578947368421101
273.163.18421052631579-0.0242105263157888
283.113.18421052631579-0.074210526315789
293.113.18421052631579-0.074210526315789
303.073.18421052631579-0.114210526315789
313.053.07615384615385-0.0261538461538460
3233.18421052631579-0.184210526315789
332.952.893636363636360.0563636363636366
342.92.893636363636360.00636363636363635
352.882.89363636363636-0.0136363636363637
362.92.893636363636360.00636363636363635
372.892.89363636363636-0.00363636363636344
382.892.89363636363636-0.00363636363636344
392.912.893636363636360.0163636363636366
402.92.893636363636360.00636363636363635
412.92.893636363636360.00636363636363635
422.882.89363636363636-0.0136363636363637
432.832.89363636363636-0.0636363636363635
442.82.706153846153850.0938461538461537
452.772.706153846153850.0638461538461539
462.782.706153846153850.0738461538461537
472.752.706153846153850.0438461538461539
482.742.706153846153850.0338461538461541
492.732.706153846153850.0238461538461539
502.692.70615384615385-0.0161538461538462
512.672.70615384615385-0.0361538461538462
522.662.70615384615385-0.046153846153846
532.672.70615384615385-0.0361538461538462
542.652.70615384615385-0.0561538461538462
552.642.70615384615385-0.066153846153846
562.632.70615384615385-0.0761538461538462

\begin{tabular}{lllllllll}
\hline
Actuals, Predictions, and Residuals \tabularnewline
# & Actuals & Forecasts & Residuals \tabularnewline
1 & 3.18 & 3.07615384615385 & 0.103846153846154 \tabularnewline
2 & 3.14 & 3.07615384615385 & 0.0638461538461543 \tabularnewline
3 & 3.02 & 3.07615384615385 & -0.0561538461538458 \tabularnewline
4 & 3.02 & 3.07615384615385 & -0.0561538461538458 \tabularnewline
5 & 3.03 & 3.07615384615385 & -0.046153846153846 \tabularnewline
6 & 3.04 & 3.07615384615385 & -0.0361538461538458 \tabularnewline
7 & 3.09 & 3.07615384615385 & 0.0138461538461541 \tabularnewline
8 & 3.06 & 3.07615384615385 & -0.0161538461538457 \tabularnewline
9 & 3.06 & 3.07615384615385 & -0.0161538461538457 \tabularnewline
10 & 3.09 & 3.07615384615385 & 0.0138461538461541 \tabularnewline
11 & 3.11 & 3.07615384615385 & 0.0338461538461541 \tabularnewline
12 & 3.1 & 3.07615384615385 & 0.0238461538461543 \tabularnewline
13 & 3.09 & 3.18421052631579 & -0.094210526315789 \tabularnewline
14 & 3.19 & 3.18421052631579 & 0.00578947368421101 \tabularnewline
15 & 3.22 & 3.18421052631579 & 0.0357894736842113 \tabularnewline
16 & 3.22 & 3.18421052631579 & 0.0357894736842113 \tabularnewline
17 & 3.25 & 3.18421052631579 & 0.065789473684211 \tabularnewline
18 & 3.25 & 3.18421052631579 & 0.065789473684211 \tabularnewline
19 & 3.27 & 3.18421052631579 & 0.085789473684211 \tabularnewline
20 & 3.28 & 3.18421052631579 & 0.0957894736842109 \tabularnewline
21 & 3.24 & 3.18421052631579 & 0.0557894736842113 \tabularnewline
22 & 3.23 & 3.18421052631579 & 0.0457894736842110 \tabularnewline
23 & 3.2 & 3.18421052631579 & 0.0157894736842112 \tabularnewline
24 & 3.19 & 3.18421052631579 & 0.00578947368421101 \tabularnewline
25 & 3.23 & 3.18421052631579 & 0.0457894736842110 \tabularnewline
26 & 3.19 & 3.18421052631579 & 0.00578947368421101 \tabularnewline
27 & 3.16 & 3.18421052631579 & -0.0242105263157888 \tabularnewline
28 & 3.11 & 3.18421052631579 & -0.074210526315789 \tabularnewline
29 & 3.11 & 3.18421052631579 & -0.074210526315789 \tabularnewline
30 & 3.07 & 3.18421052631579 & -0.114210526315789 \tabularnewline
31 & 3.05 & 3.07615384615385 & -0.0261538461538460 \tabularnewline
32 & 3 & 3.18421052631579 & -0.184210526315789 \tabularnewline
33 & 2.95 & 2.89363636363636 & 0.0563636363636366 \tabularnewline
34 & 2.9 & 2.89363636363636 & 0.00636363636363635 \tabularnewline
35 & 2.88 & 2.89363636363636 & -0.0136363636363637 \tabularnewline
36 & 2.9 & 2.89363636363636 & 0.00636363636363635 \tabularnewline
37 & 2.89 & 2.89363636363636 & -0.00363636363636344 \tabularnewline
38 & 2.89 & 2.89363636363636 & -0.00363636363636344 \tabularnewline
39 & 2.91 & 2.89363636363636 & 0.0163636363636366 \tabularnewline
40 & 2.9 & 2.89363636363636 & 0.00636363636363635 \tabularnewline
41 & 2.9 & 2.89363636363636 & 0.00636363636363635 \tabularnewline
42 & 2.88 & 2.89363636363636 & -0.0136363636363637 \tabularnewline
43 & 2.83 & 2.89363636363636 & -0.0636363636363635 \tabularnewline
44 & 2.8 & 2.70615384615385 & 0.0938461538461537 \tabularnewline
45 & 2.77 & 2.70615384615385 & 0.0638461538461539 \tabularnewline
46 & 2.78 & 2.70615384615385 & 0.0738461538461537 \tabularnewline
47 & 2.75 & 2.70615384615385 & 0.0438461538461539 \tabularnewline
48 & 2.74 & 2.70615384615385 & 0.0338461538461541 \tabularnewline
49 & 2.73 & 2.70615384615385 & 0.0238461538461539 \tabularnewline
50 & 2.69 & 2.70615384615385 & -0.0161538461538462 \tabularnewline
51 & 2.67 & 2.70615384615385 & -0.0361538461538462 \tabularnewline
52 & 2.66 & 2.70615384615385 & -0.046153846153846 \tabularnewline
53 & 2.67 & 2.70615384615385 & -0.0361538461538462 \tabularnewline
54 & 2.65 & 2.70615384615385 & -0.0561538461538462 \tabularnewline
55 & 2.64 & 2.70615384615385 & -0.066153846153846 \tabularnewline
56 & 2.63 & 2.70615384615385 & -0.0761538461538462 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=109917&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]3.18[/C][C]3.07615384615385[/C][C]0.103846153846154[/C][/ROW]
[ROW][C]2[/C][C]3.14[/C][C]3.07615384615385[/C][C]0.0638461538461543[/C][/ROW]
[ROW][C]3[/C][C]3.02[/C][C]3.07615384615385[/C][C]-0.0561538461538458[/C][/ROW]
[ROW][C]4[/C][C]3.02[/C][C]3.07615384615385[/C][C]-0.0561538461538458[/C][/ROW]
[ROW][C]5[/C][C]3.03[/C][C]3.07615384615385[/C][C]-0.046153846153846[/C][/ROW]
[ROW][C]6[/C][C]3.04[/C][C]3.07615384615385[/C][C]-0.0361538461538458[/C][/ROW]
[ROW][C]7[/C][C]3.09[/C][C]3.07615384615385[/C][C]0.0138461538461541[/C][/ROW]
[ROW][C]8[/C][C]3.06[/C][C]3.07615384615385[/C][C]-0.0161538461538457[/C][/ROW]
[ROW][C]9[/C][C]3.06[/C][C]3.07615384615385[/C][C]-0.0161538461538457[/C][/ROW]
[ROW][C]10[/C][C]3.09[/C][C]3.07615384615385[/C][C]0.0138461538461541[/C][/ROW]
[ROW][C]11[/C][C]3.11[/C][C]3.07615384615385[/C][C]0.0338461538461541[/C][/ROW]
[ROW][C]12[/C][C]3.1[/C][C]3.07615384615385[/C][C]0.0238461538461543[/C][/ROW]
[ROW][C]13[/C][C]3.09[/C][C]3.18421052631579[/C][C]-0.094210526315789[/C][/ROW]
[ROW][C]14[/C][C]3.19[/C][C]3.18421052631579[/C][C]0.00578947368421101[/C][/ROW]
[ROW][C]15[/C][C]3.22[/C][C]3.18421052631579[/C][C]0.0357894736842113[/C][/ROW]
[ROW][C]16[/C][C]3.22[/C][C]3.18421052631579[/C][C]0.0357894736842113[/C][/ROW]
[ROW][C]17[/C][C]3.25[/C][C]3.18421052631579[/C][C]0.065789473684211[/C][/ROW]
[ROW][C]18[/C][C]3.25[/C][C]3.18421052631579[/C][C]0.065789473684211[/C][/ROW]
[ROW][C]19[/C][C]3.27[/C][C]3.18421052631579[/C][C]0.085789473684211[/C][/ROW]
[ROW][C]20[/C][C]3.28[/C][C]3.18421052631579[/C][C]0.0957894736842109[/C][/ROW]
[ROW][C]21[/C][C]3.24[/C][C]3.18421052631579[/C][C]0.0557894736842113[/C][/ROW]
[ROW][C]22[/C][C]3.23[/C][C]3.18421052631579[/C][C]0.0457894736842110[/C][/ROW]
[ROW][C]23[/C][C]3.2[/C][C]3.18421052631579[/C][C]0.0157894736842112[/C][/ROW]
[ROW][C]24[/C][C]3.19[/C][C]3.18421052631579[/C][C]0.00578947368421101[/C][/ROW]
[ROW][C]25[/C][C]3.23[/C][C]3.18421052631579[/C][C]0.0457894736842110[/C][/ROW]
[ROW][C]26[/C][C]3.19[/C][C]3.18421052631579[/C][C]0.00578947368421101[/C][/ROW]
[ROW][C]27[/C][C]3.16[/C][C]3.18421052631579[/C][C]-0.0242105263157888[/C][/ROW]
[ROW][C]28[/C][C]3.11[/C][C]3.18421052631579[/C][C]-0.074210526315789[/C][/ROW]
[ROW][C]29[/C][C]3.11[/C][C]3.18421052631579[/C][C]-0.074210526315789[/C][/ROW]
[ROW][C]30[/C][C]3.07[/C][C]3.18421052631579[/C][C]-0.114210526315789[/C][/ROW]
[ROW][C]31[/C][C]3.05[/C][C]3.07615384615385[/C][C]-0.0261538461538460[/C][/ROW]
[ROW][C]32[/C][C]3[/C][C]3.18421052631579[/C][C]-0.184210526315789[/C][/ROW]
[ROW][C]33[/C][C]2.95[/C][C]2.89363636363636[/C][C]0.0563636363636366[/C][/ROW]
[ROW][C]34[/C][C]2.9[/C][C]2.89363636363636[/C][C]0.00636363636363635[/C][/ROW]
[ROW][C]35[/C][C]2.88[/C][C]2.89363636363636[/C][C]-0.0136363636363637[/C][/ROW]
[ROW][C]36[/C][C]2.9[/C][C]2.89363636363636[/C][C]0.00636363636363635[/C][/ROW]
[ROW][C]37[/C][C]2.89[/C][C]2.89363636363636[/C][C]-0.00363636363636344[/C][/ROW]
[ROW][C]38[/C][C]2.89[/C][C]2.89363636363636[/C][C]-0.00363636363636344[/C][/ROW]
[ROW][C]39[/C][C]2.91[/C][C]2.89363636363636[/C][C]0.0163636363636366[/C][/ROW]
[ROW][C]40[/C][C]2.9[/C][C]2.89363636363636[/C][C]0.00636363636363635[/C][/ROW]
[ROW][C]41[/C][C]2.9[/C][C]2.89363636363636[/C][C]0.00636363636363635[/C][/ROW]
[ROW][C]42[/C][C]2.88[/C][C]2.89363636363636[/C][C]-0.0136363636363637[/C][/ROW]
[ROW][C]43[/C][C]2.83[/C][C]2.89363636363636[/C][C]-0.0636363636363635[/C][/ROW]
[ROW][C]44[/C][C]2.8[/C][C]2.70615384615385[/C][C]0.0938461538461537[/C][/ROW]
[ROW][C]45[/C][C]2.77[/C][C]2.70615384615385[/C][C]0.0638461538461539[/C][/ROW]
[ROW][C]46[/C][C]2.78[/C][C]2.70615384615385[/C][C]0.0738461538461537[/C][/ROW]
[ROW][C]47[/C][C]2.75[/C][C]2.70615384615385[/C][C]0.0438461538461539[/C][/ROW]
[ROW][C]48[/C][C]2.74[/C][C]2.70615384615385[/C][C]0.0338461538461541[/C][/ROW]
[ROW][C]49[/C][C]2.73[/C][C]2.70615384615385[/C][C]0.0238461538461539[/C][/ROW]
[ROW][C]50[/C][C]2.69[/C][C]2.70615384615385[/C][C]-0.0161538461538462[/C][/ROW]
[ROW][C]51[/C][C]2.67[/C][C]2.70615384615385[/C][C]-0.0361538461538462[/C][/ROW]
[ROW][C]52[/C][C]2.66[/C][C]2.70615384615385[/C][C]-0.046153846153846[/C][/ROW]
[ROW][C]53[/C][C]2.67[/C][C]2.70615384615385[/C][C]-0.0361538461538462[/C][/ROW]
[ROW][C]54[/C][C]2.65[/C][C]2.70615384615385[/C][C]-0.0561538461538462[/C][/ROW]
[ROW][C]55[/C][C]2.64[/C][C]2.70615384615385[/C][C]-0.066153846153846[/C][/ROW]
[ROW][C]56[/C][C]2.63[/C][C]2.70615384615385[/C][C]-0.0761538461538462[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=109917&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=109917&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
13.183.076153846153850.103846153846154
23.143.076153846153850.0638461538461543
33.023.07615384615385-0.0561538461538458
43.023.07615384615385-0.0561538461538458
53.033.07615384615385-0.046153846153846
63.043.07615384615385-0.0361538461538458
73.093.076153846153850.0138461538461541
83.063.07615384615385-0.0161538461538457
93.063.07615384615385-0.0161538461538457
103.093.076153846153850.0138461538461541
113.113.076153846153850.0338461538461541
123.13.076153846153850.0238461538461543
133.093.18421052631579-0.094210526315789
143.193.184210526315790.00578947368421101
153.223.184210526315790.0357894736842113
163.223.184210526315790.0357894736842113
173.253.184210526315790.065789473684211
183.253.184210526315790.065789473684211
193.273.184210526315790.085789473684211
203.283.184210526315790.0957894736842109
213.243.184210526315790.0557894736842113
223.233.184210526315790.0457894736842110
233.23.184210526315790.0157894736842112
243.193.184210526315790.00578947368421101
253.233.184210526315790.0457894736842110
263.193.184210526315790.00578947368421101
273.163.18421052631579-0.0242105263157888
283.113.18421052631579-0.074210526315789
293.113.18421052631579-0.074210526315789
303.073.18421052631579-0.114210526315789
313.053.07615384615385-0.0261538461538460
3233.18421052631579-0.184210526315789
332.952.893636363636360.0563636363636366
342.92.893636363636360.00636363636363635
352.882.89363636363636-0.0136363636363637
362.92.893636363636360.00636363636363635
372.892.89363636363636-0.00363636363636344
382.892.89363636363636-0.00363636363636344
392.912.893636363636360.0163636363636366
402.92.893636363636360.00636363636363635
412.92.893636363636360.00636363636363635
422.882.89363636363636-0.0136363636363637
432.832.89363636363636-0.0636363636363635
442.82.706153846153850.0938461538461537
452.772.706153846153850.0638461538461539
462.782.706153846153850.0738461538461537
472.752.706153846153850.0438461538461539
482.742.706153846153850.0338461538461541
492.732.706153846153850.0238461538461539
502.692.70615384615385-0.0161538461538462
512.672.70615384615385-0.0361538461538462
522.662.70615384615385-0.046153846153846
532.672.70615384615385-0.0361538461538462
542.652.70615384615385-0.0561538461538462
552.642.70615384615385-0.066153846153846
562.632.70615384615385-0.0761538461538462



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