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 14:18: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/21/t1292941048snlf76o8jfiixtc.htm/, Retrieved Fri, 17 May 2024 11:48:12 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=113603, Retrieved Fri, 17 May 2024 11:48:12 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact122
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-14 13:38:09] [7e261c986c934df955dd3ac53e9d45c6]
-   PD      [Recursive Partitioning (Regression Trees)] [Recursive partiti...] [2010-12-21 14:18:39] [7cc6e89f95359dcad314da35cb7f084f] [Current]
Feedback Forum

Post a new message
Dataseries X:
300	2,26	591.000
302	2,57	589.000
400	3,07	584.000
392	2,76	573.000
373	2,51	567.000
379	2,87	569.000
303	3,14	621.000
324	3,11	629.000
353	3,16	628.000
392	2,47	612.000
327	2,57	595.000
376	2,89	597.000
329	2,63	593.000
359	2,38	590.000
413	1,69	580.000
338	1,96	574.000
422	2,19	573.000
390	1,87	573.000
370	1,60	620.000
367	1,63	626.000
406	1,22	620.000
418	1,21	588.000
346	1,49	566.000
350	1,64	557.000
330	1,66	561.000
318	1,77	549.000
382	1,82	532.000
337	1,78	526.000
372	1,28	511.000
422	1,29	499.000
428	1,37	555.000
426	1,12	565.000
396	1,51	542.000
458	2,24	527.000
315	2,94	510.000
337	3,09	514.000
386	3,46	517.000
352	3,64	508.000
383	4,39	493.000
439	4,15	490.000
397	5,21	469.000
453	5,80	478.000
363	5,91	528.000
365	5,39	534.000
474	5,46	518.000
373	4,72	506.000
403	3,14	502.000
384	2,63	516.000
364	2,32	528.000
361	1,93	533.000
419	0,62	536.000
352	0,60	537.000
363	-0,37	524.000
410	-1,10	536.000
361	-1,68	587.000
383	-0,78	597.000
342	-1,19	581.000
369	-0,79	564.000
361	-0,12	558.000
317	0,26	575.000
386	0,62	580.000
318	0,70	575.000
407	1,66	563.000
393	1,80	552.000
404	2,27	537.000
498	2,46	545.000
438	2,57	601.000




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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=113603&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.3194
R-squared0.102
RMSE39.6407

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

[TABLE]
[ROW][C]Goodness of Fit[/C][/ROW]
[ROW][C]Correlation[/C][C]0.3194[/C][/ROW]
[ROW][C]R-squared[/C][C]0.102[/C][/ROW]
[ROW][C]RMSE[/C][C]39.6407[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=113603&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=113603&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.3194
R-squared0.102
RMSE39.6407







Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
1300359.25-59.25
2302359.25-57.25
3400359.2540.75
4392387.1162790697674.88372093023258
5373387.116279069767-14.1162790697674
6379387.116279069767-8.11627906976742
7303359.25-56.25
8324359.25-35.25
9353359.25-6.25
10392359.2532.75
11327359.25-32.25
12376359.2516.75
13329359.25-30.25
14359359.25-0.25
15413359.2553.75
16338359.25-21.25
17422387.11627906976734.8837209302326
18390387.1162790697672.88372093023258
19370359.2510.75
20367359.257.75
21406359.2546.75
22418359.2558.75
23346387.116279069767-41.1162790697674
24350387.116279069767-37.1162790697674
25330387.116279069767-57.1162790697674
26318387.116279069767-69.1162790697674
27382387.116279069767-5.11627906976742
28337387.116279069767-50.1162790697674
29372387.116279069767-15.1162790697674
30422387.11627906976734.8837209302326
31428387.11627906976740.8837209302326
32426387.11627906976738.8837209302326
33396387.1162790697678.88372093023258
34458387.11627906976770.8837209302326
35315387.116279069767-72.1162790697674
36337387.116279069767-50.1162790697674
37386387.116279069767-1.11627906976742
38352387.116279069767-35.1162790697674
39383387.116279069767-4.11627906976742
40439387.11627906976751.8837209302326
41397387.1162790697679.88372093023258
42453387.11627906976765.8837209302326
43363387.116279069767-24.1162790697674
44365387.116279069767-22.1162790697674
45474387.11627906976786.8837209302326
46373387.116279069767-14.1162790697674
47403387.11627906976715.8837209302326
48384387.116279069767-3.11627906976742
49364387.116279069767-23.1162790697674
50361387.116279069767-26.1162790697674
51419387.11627906976731.8837209302326
52352387.116279069767-35.1162790697674
53363387.116279069767-24.1162790697674
54410387.11627906976722.8837209302326
55361359.251.75
56383359.2523.75
57342359.25-17.25
58369387.116279069767-18.1162790697674
59361387.116279069767-26.1162790697674
60317359.25-42.25
61386359.2526.75
62318359.25-41.25
63407387.11627906976719.8837209302326
64393387.1162790697675.88372093023258
65404387.11627906976716.8837209302326
66498387.116279069767110.883720930233
67438359.2578.75

\begin{tabular}{lllllllll}
\hline
Actuals, Predictions, and Residuals \tabularnewline
# & Actuals & Forecasts & Residuals \tabularnewline
1 & 300 & 359.25 & -59.25 \tabularnewline
2 & 302 & 359.25 & -57.25 \tabularnewline
3 & 400 & 359.25 & 40.75 \tabularnewline
4 & 392 & 387.116279069767 & 4.88372093023258 \tabularnewline
5 & 373 & 387.116279069767 & -14.1162790697674 \tabularnewline
6 & 379 & 387.116279069767 & -8.11627906976742 \tabularnewline
7 & 303 & 359.25 & -56.25 \tabularnewline
8 & 324 & 359.25 & -35.25 \tabularnewline
9 & 353 & 359.25 & -6.25 \tabularnewline
10 & 392 & 359.25 & 32.75 \tabularnewline
11 & 327 & 359.25 & -32.25 \tabularnewline
12 & 376 & 359.25 & 16.75 \tabularnewline
13 & 329 & 359.25 & -30.25 \tabularnewline
14 & 359 & 359.25 & -0.25 \tabularnewline
15 & 413 & 359.25 & 53.75 \tabularnewline
16 & 338 & 359.25 & -21.25 \tabularnewline
17 & 422 & 387.116279069767 & 34.8837209302326 \tabularnewline
18 & 390 & 387.116279069767 & 2.88372093023258 \tabularnewline
19 & 370 & 359.25 & 10.75 \tabularnewline
20 & 367 & 359.25 & 7.75 \tabularnewline
21 & 406 & 359.25 & 46.75 \tabularnewline
22 & 418 & 359.25 & 58.75 \tabularnewline
23 & 346 & 387.116279069767 & -41.1162790697674 \tabularnewline
24 & 350 & 387.116279069767 & -37.1162790697674 \tabularnewline
25 & 330 & 387.116279069767 & -57.1162790697674 \tabularnewline
26 & 318 & 387.116279069767 & -69.1162790697674 \tabularnewline
27 & 382 & 387.116279069767 & -5.11627906976742 \tabularnewline
28 & 337 & 387.116279069767 & -50.1162790697674 \tabularnewline
29 & 372 & 387.116279069767 & -15.1162790697674 \tabularnewline
30 & 422 & 387.116279069767 & 34.8837209302326 \tabularnewline
31 & 428 & 387.116279069767 & 40.8837209302326 \tabularnewline
32 & 426 & 387.116279069767 & 38.8837209302326 \tabularnewline
33 & 396 & 387.116279069767 & 8.88372093023258 \tabularnewline
34 & 458 & 387.116279069767 & 70.8837209302326 \tabularnewline
35 & 315 & 387.116279069767 & -72.1162790697674 \tabularnewline
36 & 337 & 387.116279069767 & -50.1162790697674 \tabularnewline
37 & 386 & 387.116279069767 & -1.11627906976742 \tabularnewline
38 & 352 & 387.116279069767 & -35.1162790697674 \tabularnewline
39 & 383 & 387.116279069767 & -4.11627906976742 \tabularnewline
40 & 439 & 387.116279069767 & 51.8837209302326 \tabularnewline
41 & 397 & 387.116279069767 & 9.88372093023258 \tabularnewline
42 & 453 & 387.116279069767 & 65.8837209302326 \tabularnewline
43 & 363 & 387.116279069767 & -24.1162790697674 \tabularnewline
44 & 365 & 387.116279069767 & -22.1162790697674 \tabularnewline
45 & 474 & 387.116279069767 & 86.8837209302326 \tabularnewline
46 & 373 & 387.116279069767 & -14.1162790697674 \tabularnewline
47 & 403 & 387.116279069767 & 15.8837209302326 \tabularnewline
48 & 384 & 387.116279069767 & -3.11627906976742 \tabularnewline
49 & 364 & 387.116279069767 & -23.1162790697674 \tabularnewline
50 & 361 & 387.116279069767 & -26.1162790697674 \tabularnewline
51 & 419 & 387.116279069767 & 31.8837209302326 \tabularnewline
52 & 352 & 387.116279069767 & -35.1162790697674 \tabularnewline
53 & 363 & 387.116279069767 & -24.1162790697674 \tabularnewline
54 & 410 & 387.116279069767 & 22.8837209302326 \tabularnewline
55 & 361 & 359.25 & 1.75 \tabularnewline
56 & 383 & 359.25 & 23.75 \tabularnewline
57 & 342 & 359.25 & -17.25 \tabularnewline
58 & 369 & 387.116279069767 & -18.1162790697674 \tabularnewline
59 & 361 & 387.116279069767 & -26.1162790697674 \tabularnewline
60 & 317 & 359.25 & -42.25 \tabularnewline
61 & 386 & 359.25 & 26.75 \tabularnewline
62 & 318 & 359.25 & -41.25 \tabularnewline
63 & 407 & 387.116279069767 & 19.8837209302326 \tabularnewline
64 & 393 & 387.116279069767 & 5.88372093023258 \tabularnewline
65 & 404 & 387.116279069767 & 16.8837209302326 \tabularnewline
66 & 498 & 387.116279069767 & 110.883720930233 \tabularnewline
67 & 438 & 359.25 & 78.75 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=113603&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]300[/C][C]359.25[/C][C]-59.25[/C][/ROW]
[ROW][C]2[/C][C]302[/C][C]359.25[/C][C]-57.25[/C][/ROW]
[ROW][C]3[/C][C]400[/C][C]359.25[/C][C]40.75[/C][/ROW]
[ROW][C]4[/C][C]392[/C][C]387.116279069767[/C][C]4.88372093023258[/C][/ROW]
[ROW][C]5[/C][C]373[/C][C]387.116279069767[/C][C]-14.1162790697674[/C][/ROW]
[ROW][C]6[/C][C]379[/C][C]387.116279069767[/C][C]-8.11627906976742[/C][/ROW]
[ROW][C]7[/C][C]303[/C][C]359.25[/C][C]-56.25[/C][/ROW]
[ROW][C]8[/C][C]324[/C][C]359.25[/C][C]-35.25[/C][/ROW]
[ROW][C]9[/C][C]353[/C][C]359.25[/C][C]-6.25[/C][/ROW]
[ROW][C]10[/C][C]392[/C][C]359.25[/C][C]32.75[/C][/ROW]
[ROW][C]11[/C][C]327[/C][C]359.25[/C][C]-32.25[/C][/ROW]
[ROW][C]12[/C][C]376[/C][C]359.25[/C][C]16.75[/C][/ROW]
[ROW][C]13[/C][C]329[/C][C]359.25[/C][C]-30.25[/C][/ROW]
[ROW][C]14[/C][C]359[/C][C]359.25[/C][C]-0.25[/C][/ROW]
[ROW][C]15[/C][C]413[/C][C]359.25[/C][C]53.75[/C][/ROW]
[ROW][C]16[/C][C]338[/C][C]359.25[/C][C]-21.25[/C][/ROW]
[ROW][C]17[/C][C]422[/C][C]387.116279069767[/C][C]34.8837209302326[/C][/ROW]
[ROW][C]18[/C][C]390[/C][C]387.116279069767[/C][C]2.88372093023258[/C][/ROW]
[ROW][C]19[/C][C]370[/C][C]359.25[/C][C]10.75[/C][/ROW]
[ROW][C]20[/C][C]367[/C][C]359.25[/C][C]7.75[/C][/ROW]
[ROW][C]21[/C][C]406[/C][C]359.25[/C][C]46.75[/C][/ROW]
[ROW][C]22[/C][C]418[/C][C]359.25[/C][C]58.75[/C][/ROW]
[ROW][C]23[/C][C]346[/C][C]387.116279069767[/C][C]-41.1162790697674[/C][/ROW]
[ROW][C]24[/C][C]350[/C][C]387.116279069767[/C][C]-37.1162790697674[/C][/ROW]
[ROW][C]25[/C][C]330[/C][C]387.116279069767[/C][C]-57.1162790697674[/C][/ROW]
[ROW][C]26[/C][C]318[/C][C]387.116279069767[/C][C]-69.1162790697674[/C][/ROW]
[ROW][C]27[/C][C]382[/C][C]387.116279069767[/C][C]-5.11627906976742[/C][/ROW]
[ROW][C]28[/C][C]337[/C][C]387.116279069767[/C][C]-50.1162790697674[/C][/ROW]
[ROW][C]29[/C][C]372[/C][C]387.116279069767[/C][C]-15.1162790697674[/C][/ROW]
[ROW][C]30[/C][C]422[/C][C]387.116279069767[/C][C]34.8837209302326[/C][/ROW]
[ROW][C]31[/C][C]428[/C][C]387.116279069767[/C][C]40.8837209302326[/C][/ROW]
[ROW][C]32[/C][C]426[/C][C]387.116279069767[/C][C]38.8837209302326[/C][/ROW]
[ROW][C]33[/C][C]396[/C][C]387.116279069767[/C][C]8.88372093023258[/C][/ROW]
[ROW][C]34[/C][C]458[/C][C]387.116279069767[/C][C]70.8837209302326[/C][/ROW]
[ROW][C]35[/C][C]315[/C][C]387.116279069767[/C][C]-72.1162790697674[/C][/ROW]
[ROW][C]36[/C][C]337[/C][C]387.116279069767[/C][C]-50.1162790697674[/C][/ROW]
[ROW][C]37[/C][C]386[/C][C]387.116279069767[/C][C]-1.11627906976742[/C][/ROW]
[ROW][C]38[/C][C]352[/C][C]387.116279069767[/C][C]-35.1162790697674[/C][/ROW]
[ROW][C]39[/C][C]383[/C][C]387.116279069767[/C][C]-4.11627906976742[/C][/ROW]
[ROW][C]40[/C][C]439[/C][C]387.116279069767[/C][C]51.8837209302326[/C][/ROW]
[ROW][C]41[/C][C]397[/C][C]387.116279069767[/C][C]9.88372093023258[/C][/ROW]
[ROW][C]42[/C][C]453[/C][C]387.116279069767[/C][C]65.8837209302326[/C][/ROW]
[ROW][C]43[/C][C]363[/C][C]387.116279069767[/C][C]-24.1162790697674[/C][/ROW]
[ROW][C]44[/C][C]365[/C][C]387.116279069767[/C][C]-22.1162790697674[/C][/ROW]
[ROW][C]45[/C][C]474[/C][C]387.116279069767[/C][C]86.8837209302326[/C][/ROW]
[ROW][C]46[/C][C]373[/C][C]387.116279069767[/C][C]-14.1162790697674[/C][/ROW]
[ROW][C]47[/C][C]403[/C][C]387.116279069767[/C][C]15.8837209302326[/C][/ROW]
[ROW][C]48[/C][C]384[/C][C]387.116279069767[/C][C]-3.11627906976742[/C][/ROW]
[ROW][C]49[/C][C]364[/C][C]387.116279069767[/C][C]-23.1162790697674[/C][/ROW]
[ROW][C]50[/C][C]361[/C][C]387.116279069767[/C][C]-26.1162790697674[/C][/ROW]
[ROW][C]51[/C][C]419[/C][C]387.116279069767[/C][C]31.8837209302326[/C][/ROW]
[ROW][C]52[/C][C]352[/C][C]387.116279069767[/C][C]-35.1162790697674[/C][/ROW]
[ROW][C]53[/C][C]363[/C][C]387.116279069767[/C][C]-24.1162790697674[/C][/ROW]
[ROW][C]54[/C][C]410[/C][C]387.116279069767[/C][C]22.8837209302326[/C][/ROW]
[ROW][C]55[/C][C]361[/C][C]359.25[/C][C]1.75[/C][/ROW]
[ROW][C]56[/C][C]383[/C][C]359.25[/C][C]23.75[/C][/ROW]
[ROW][C]57[/C][C]342[/C][C]359.25[/C][C]-17.25[/C][/ROW]
[ROW][C]58[/C][C]369[/C][C]387.116279069767[/C][C]-18.1162790697674[/C][/ROW]
[ROW][C]59[/C][C]361[/C][C]387.116279069767[/C][C]-26.1162790697674[/C][/ROW]
[ROW][C]60[/C][C]317[/C][C]359.25[/C][C]-42.25[/C][/ROW]
[ROW][C]61[/C][C]386[/C][C]359.25[/C][C]26.75[/C][/ROW]
[ROW][C]62[/C][C]318[/C][C]359.25[/C][C]-41.25[/C][/ROW]
[ROW][C]63[/C][C]407[/C][C]387.116279069767[/C][C]19.8837209302326[/C][/ROW]
[ROW][C]64[/C][C]393[/C][C]387.116279069767[/C][C]5.88372093023258[/C][/ROW]
[ROW][C]65[/C][C]404[/C][C]387.116279069767[/C][C]16.8837209302326[/C][/ROW]
[ROW][C]66[/C][C]498[/C][C]387.116279069767[/C][C]110.883720930233[/C][/ROW]
[ROW][C]67[/C][C]438[/C][C]359.25[/C][C]78.75[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=113603&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=113603&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
1300359.25-59.25
2302359.25-57.25
3400359.2540.75
4392387.1162790697674.88372093023258
5373387.116279069767-14.1162790697674
6379387.116279069767-8.11627906976742
7303359.25-56.25
8324359.25-35.25
9353359.25-6.25
10392359.2532.75
11327359.25-32.25
12376359.2516.75
13329359.25-30.25
14359359.25-0.25
15413359.2553.75
16338359.25-21.25
17422387.11627906976734.8837209302326
18390387.1162790697672.88372093023258
19370359.2510.75
20367359.257.75
21406359.2546.75
22418359.2558.75
23346387.116279069767-41.1162790697674
24350387.116279069767-37.1162790697674
25330387.116279069767-57.1162790697674
26318387.116279069767-69.1162790697674
27382387.116279069767-5.11627906976742
28337387.116279069767-50.1162790697674
29372387.116279069767-15.1162790697674
30422387.11627906976734.8837209302326
31428387.11627906976740.8837209302326
32426387.11627906976738.8837209302326
33396387.1162790697678.88372093023258
34458387.11627906976770.8837209302326
35315387.116279069767-72.1162790697674
36337387.116279069767-50.1162790697674
37386387.116279069767-1.11627906976742
38352387.116279069767-35.1162790697674
39383387.116279069767-4.11627906976742
40439387.11627906976751.8837209302326
41397387.1162790697679.88372093023258
42453387.11627906976765.8837209302326
43363387.116279069767-24.1162790697674
44365387.116279069767-22.1162790697674
45474387.11627906976786.8837209302326
46373387.116279069767-14.1162790697674
47403387.11627906976715.8837209302326
48384387.116279069767-3.11627906976742
49364387.116279069767-23.1162790697674
50361387.116279069767-26.1162790697674
51419387.11627906976731.8837209302326
52352387.116279069767-35.1162790697674
53363387.116279069767-24.1162790697674
54410387.11627906976722.8837209302326
55361359.251.75
56383359.2523.75
57342359.25-17.25
58369387.116279069767-18.1162790697674
59361387.116279069767-26.1162790697674
60317359.25-42.25
61386359.2526.75
62318359.25-41.25
63407387.11627906976719.8837209302326
64393387.1162790697675.88372093023258
65404387.11627906976716.8837209302326
66498387.116279069767110.883720930233
67438359.2578.75



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