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 15:11:14 +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/t129294431847e9opxcn56ia7j.htm/, Retrieved Sun, 19 May 2024 19:50:06 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=113657, Retrieved Sun, 19 May 2024 19:50:06 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact115
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)] [paper - recursive...] [2010-12-21 15:11:14] [6ea41cf020a5319fc3c331a4158019e5] [Current]
Feedback Forum

Post a new message
Dataseries X:
296.95	17.20
296.84	17.20
287.54	17.20
287.81	17.20
283.99	20.63
275.79	20.63
269.52	20.63
278.35	20.63
283.43	19.32
289.46	19.32
282.30	19.32
293.55	19.32
304.78	12.99
300.99	12.99
315.29	12.99
316.21	12.99
331.79	18.13
329.38	18.13
317.27	18.13
317.98	18.13
340.28	28.37
339.21	28.37
336.71	28.37
340.11	28.37
347.72	24.35
328.68	24.35
303.05	24.35
299.83	24.35
320.04	24.99
317.94	24.99
303.31	24.99
308.85	24.99
319.19	28.84
314.52	28.84
312.39	28.84
315.77	28.84
320.23	37.88
309.45	37.88
296.54	37.88
297.28	37.88
301.39	54.04
306.68	54.04
305.91	54.04
314.76	54.04
323.34	64.93
341.58	64.93
330.12	64.93
318.16	64.93
317.84	71.81
325.39	71.81
327.56	71.81
329.77	71.81
333.29	99.75
346.10	99.75
358.00	99.75
344.82	99.75
313.30	61.25
301.26	61.25
306.38	61.25
319.31	61.25




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time6 seconds
R Server'Sir Ronald Aylmer Fisher' @ 193.190.124.24

\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 & 6 seconds \tabularnewline
R Server & 'Sir Ronald Aylmer Fisher' @ 193.190.124.24 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=113657&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]6 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'Sir Ronald Aylmer Fisher' @ 193.190.124.24[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=113657&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=113657&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 time6 seconds
R Server'Sir Ronald Aylmer Fisher' @ 193.190.124.24







Goodness of Fit
Correlation0.75
R-squared0.5626
RMSE12.9304

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

[TABLE]
[ROW][C]Goodness of Fit[/C][/ROW]
[ROW][C]Correlation[/C][C]0.75[/C][/ROW]
[ROW][C]R-squared[/C][C]0.5626[/C][/ROW]
[ROW][C]RMSE[/C][C]12.9304[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=113657&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=113657&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.75
R-squared0.5626
RMSE12.9304







Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
1296.95308.569166666667-11.6191666666667
2296.84308.569166666667-11.7291666666667
3287.54308.569166666667-21.0291666666666
4287.81308.569166666667-20.7591666666667
5283.99282.048751.94125000000003
6275.79282.04875-6.25874999999996
7269.52282.04875-12.52875
8278.35282.04875-3.69874999999996
9283.43282.048751.38125000000002
10289.46282.048757.41125
11282.3282.048750.251250000000027
12293.55282.0487511.5012500000000
13304.78308.569166666667-3.78916666666669
14300.99308.569166666667-7.57916666666665
15315.29308.5691666666676.72083333333336
16316.21308.5691666666677.64083333333332
17331.79308.56916666666723.2208333333334
18329.38308.56916666666720.8108333333333
19317.27308.5691666666678.70083333333332
20317.98308.5691666666679.41083333333336
21340.28315.717524.5625
22339.21315.717523.4925
23336.71315.717520.9925
24340.11315.717524.3925000000000
25347.72315.717532.0025000000001
26328.68315.717512.9625000000000
27303.05315.7175-12.6675000000000
28299.83315.7175-15.8875
29320.04315.71754.32250000000005
30317.94315.71752.22250000000003
31303.31315.7175-12.4075000000000
32308.85315.7175-6.86749999999995
33319.19315.71753.47250000000003
34314.52315.7175-1.19749999999999
35312.39315.7175-3.32749999999999
36315.77315.71750.0525000000000091
37320.23315.71754.51250000000005
38309.45315.7175-6.26749999999998
39296.54315.7175-19.1775000000000
40297.28315.7175-18.4375
41301.39315.7175-14.3275
42306.68315.7175-9.03749999999997
43305.91315.7175-9.80749999999995
44314.76315.7175-0.957499999999982
45323.34332.9975-9.65750000000003
46341.58332.99758.58249999999998
47330.12332.9975-2.8775
48318.16332.9975-14.8375000000000
49317.84332.9975-15.1575000000000
50325.39332.9975-7.60750000000002
51327.56332.9975-5.4375
52329.77332.9975-3.22750000000002
53333.29332.99750.292500000000018
54346.1332.997513.1025000000000
55358332.997525.0025
56344.82332.997511.8225
57313.3315.7175-2.41749999999996
58301.26315.7175-14.4575000000000
59306.38315.7175-9.33749999999998
60319.31315.71753.59250000000003

\begin{tabular}{lllllllll}
\hline
Actuals, Predictions, and Residuals \tabularnewline
# & Actuals & Forecasts & Residuals \tabularnewline
1 & 296.95 & 308.569166666667 & -11.6191666666667 \tabularnewline
2 & 296.84 & 308.569166666667 & -11.7291666666667 \tabularnewline
3 & 287.54 & 308.569166666667 & -21.0291666666666 \tabularnewline
4 & 287.81 & 308.569166666667 & -20.7591666666667 \tabularnewline
5 & 283.99 & 282.04875 & 1.94125000000003 \tabularnewline
6 & 275.79 & 282.04875 & -6.25874999999996 \tabularnewline
7 & 269.52 & 282.04875 & -12.52875 \tabularnewline
8 & 278.35 & 282.04875 & -3.69874999999996 \tabularnewline
9 & 283.43 & 282.04875 & 1.38125000000002 \tabularnewline
10 & 289.46 & 282.04875 & 7.41125 \tabularnewline
11 & 282.3 & 282.04875 & 0.251250000000027 \tabularnewline
12 & 293.55 & 282.04875 & 11.5012500000000 \tabularnewline
13 & 304.78 & 308.569166666667 & -3.78916666666669 \tabularnewline
14 & 300.99 & 308.569166666667 & -7.57916666666665 \tabularnewline
15 & 315.29 & 308.569166666667 & 6.72083333333336 \tabularnewline
16 & 316.21 & 308.569166666667 & 7.64083333333332 \tabularnewline
17 & 331.79 & 308.569166666667 & 23.2208333333334 \tabularnewline
18 & 329.38 & 308.569166666667 & 20.8108333333333 \tabularnewline
19 & 317.27 & 308.569166666667 & 8.70083333333332 \tabularnewline
20 & 317.98 & 308.569166666667 & 9.41083333333336 \tabularnewline
21 & 340.28 & 315.7175 & 24.5625 \tabularnewline
22 & 339.21 & 315.7175 & 23.4925 \tabularnewline
23 & 336.71 & 315.7175 & 20.9925 \tabularnewline
24 & 340.11 & 315.7175 & 24.3925000000000 \tabularnewline
25 & 347.72 & 315.7175 & 32.0025000000001 \tabularnewline
26 & 328.68 & 315.7175 & 12.9625000000000 \tabularnewline
27 & 303.05 & 315.7175 & -12.6675000000000 \tabularnewline
28 & 299.83 & 315.7175 & -15.8875 \tabularnewline
29 & 320.04 & 315.7175 & 4.32250000000005 \tabularnewline
30 & 317.94 & 315.7175 & 2.22250000000003 \tabularnewline
31 & 303.31 & 315.7175 & -12.4075000000000 \tabularnewline
32 & 308.85 & 315.7175 & -6.86749999999995 \tabularnewline
33 & 319.19 & 315.7175 & 3.47250000000003 \tabularnewline
34 & 314.52 & 315.7175 & -1.19749999999999 \tabularnewline
35 & 312.39 & 315.7175 & -3.32749999999999 \tabularnewline
36 & 315.77 & 315.7175 & 0.0525000000000091 \tabularnewline
37 & 320.23 & 315.7175 & 4.51250000000005 \tabularnewline
38 & 309.45 & 315.7175 & -6.26749999999998 \tabularnewline
39 & 296.54 & 315.7175 & -19.1775000000000 \tabularnewline
40 & 297.28 & 315.7175 & -18.4375 \tabularnewline
41 & 301.39 & 315.7175 & -14.3275 \tabularnewline
42 & 306.68 & 315.7175 & -9.03749999999997 \tabularnewline
43 & 305.91 & 315.7175 & -9.80749999999995 \tabularnewline
44 & 314.76 & 315.7175 & -0.957499999999982 \tabularnewline
45 & 323.34 & 332.9975 & -9.65750000000003 \tabularnewline
46 & 341.58 & 332.9975 & 8.58249999999998 \tabularnewline
47 & 330.12 & 332.9975 & -2.8775 \tabularnewline
48 & 318.16 & 332.9975 & -14.8375000000000 \tabularnewline
49 & 317.84 & 332.9975 & -15.1575000000000 \tabularnewline
50 & 325.39 & 332.9975 & -7.60750000000002 \tabularnewline
51 & 327.56 & 332.9975 & -5.4375 \tabularnewline
52 & 329.77 & 332.9975 & -3.22750000000002 \tabularnewline
53 & 333.29 & 332.9975 & 0.292500000000018 \tabularnewline
54 & 346.1 & 332.9975 & 13.1025000000000 \tabularnewline
55 & 358 & 332.9975 & 25.0025 \tabularnewline
56 & 344.82 & 332.9975 & 11.8225 \tabularnewline
57 & 313.3 & 315.7175 & -2.41749999999996 \tabularnewline
58 & 301.26 & 315.7175 & -14.4575000000000 \tabularnewline
59 & 306.38 & 315.7175 & -9.33749999999998 \tabularnewline
60 & 319.31 & 315.7175 & 3.59250000000003 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=113657&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]296.95[/C][C]308.569166666667[/C][C]-11.6191666666667[/C][/ROW]
[ROW][C]2[/C][C]296.84[/C][C]308.569166666667[/C][C]-11.7291666666667[/C][/ROW]
[ROW][C]3[/C][C]287.54[/C][C]308.569166666667[/C][C]-21.0291666666666[/C][/ROW]
[ROW][C]4[/C][C]287.81[/C][C]308.569166666667[/C][C]-20.7591666666667[/C][/ROW]
[ROW][C]5[/C][C]283.99[/C][C]282.04875[/C][C]1.94125000000003[/C][/ROW]
[ROW][C]6[/C][C]275.79[/C][C]282.04875[/C][C]-6.25874999999996[/C][/ROW]
[ROW][C]7[/C][C]269.52[/C][C]282.04875[/C][C]-12.52875[/C][/ROW]
[ROW][C]8[/C][C]278.35[/C][C]282.04875[/C][C]-3.69874999999996[/C][/ROW]
[ROW][C]9[/C][C]283.43[/C][C]282.04875[/C][C]1.38125000000002[/C][/ROW]
[ROW][C]10[/C][C]289.46[/C][C]282.04875[/C][C]7.41125[/C][/ROW]
[ROW][C]11[/C][C]282.3[/C][C]282.04875[/C][C]0.251250000000027[/C][/ROW]
[ROW][C]12[/C][C]293.55[/C][C]282.04875[/C][C]11.5012500000000[/C][/ROW]
[ROW][C]13[/C][C]304.78[/C][C]308.569166666667[/C][C]-3.78916666666669[/C][/ROW]
[ROW][C]14[/C][C]300.99[/C][C]308.569166666667[/C][C]-7.57916666666665[/C][/ROW]
[ROW][C]15[/C][C]315.29[/C][C]308.569166666667[/C][C]6.72083333333336[/C][/ROW]
[ROW][C]16[/C][C]316.21[/C][C]308.569166666667[/C][C]7.64083333333332[/C][/ROW]
[ROW][C]17[/C][C]331.79[/C][C]308.569166666667[/C][C]23.2208333333334[/C][/ROW]
[ROW][C]18[/C][C]329.38[/C][C]308.569166666667[/C][C]20.8108333333333[/C][/ROW]
[ROW][C]19[/C][C]317.27[/C][C]308.569166666667[/C][C]8.70083333333332[/C][/ROW]
[ROW][C]20[/C][C]317.98[/C][C]308.569166666667[/C][C]9.41083333333336[/C][/ROW]
[ROW][C]21[/C][C]340.28[/C][C]315.7175[/C][C]24.5625[/C][/ROW]
[ROW][C]22[/C][C]339.21[/C][C]315.7175[/C][C]23.4925[/C][/ROW]
[ROW][C]23[/C][C]336.71[/C][C]315.7175[/C][C]20.9925[/C][/ROW]
[ROW][C]24[/C][C]340.11[/C][C]315.7175[/C][C]24.3925000000000[/C][/ROW]
[ROW][C]25[/C][C]347.72[/C][C]315.7175[/C][C]32.0025000000001[/C][/ROW]
[ROW][C]26[/C][C]328.68[/C][C]315.7175[/C][C]12.9625000000000[/C][/ROW]
[ROW][C]27[/C][C]303.05[/C][C]315.7175[/C][C]-12.6675000000000[/C][/ROW]
[ROW][C]28[/C][C]299.83[/C][C]315.7175[/C][C]-15.8875[/C][/ROW]
[ROW][C]29[/C][C]320.04[/C][C]315.7175[/C][C]4.32250000000005[/C][/ROW]
[ROW][C]30[/C][C]317.94[/C][C]315.7175[/C][C]2.22250000000003[/C][/ROW]
[ROW][C]31[/C][C]303.31[/C][C]315.7175[/C][C]-12.4075000000000[/C][/ROW]
[ROW][C]32[/C][C]308.85[/C][C]315.7175[/C][C]-6.86749999999995[/C][/ROW]
[ROW][C]33[/C][C]319.19[/C][C]315.7175[/C][C]3.47250000000003[/C][/ROW]
[ROW][C]34[/C][C]314.52[/C][C]315.7175[/C][C]-1.19749999999999[/C][/ROW]
[ROW][C]35[/C][C]312.39[/C][C]315.7175[/C][C]-3.32749999999999[/C][/ROW]
[ROW][C]36[/C][C]315.77[/C][C]315.7175[/C][C]0.0525000000000091[/C][/ROW]
[ROW][C]37[/C][C]320.23[/C][C]315.7175[/C][C]4.51250000000005[/C][/ROW]
[ROW][C]38[/C][C]309.45[/C][C]315.7175[/C][C]-6.26749999999998[/C][/ROW]
[ROW][C]39[/C][C]296.54[/C][C]315.7175[/C][C]-19.1775000000000[/C][/ROW]
[ROW][C]40[/C][C]297.28[/C][C]315.7175[/C][C]-18.4375[/C][/ROW]
[ROW][C]41[/C][C]301.39[/C][C]315.7175[/C][C]-14.3275[/C][/ROW]
[ROW][C]42[/C][C]306.68[/C][C]315.7175[/C][C]-9.03749999999997[/C][/ROW]
[ROW][C]43[/C][C]305.91[/C][C]315.7175[/C][C]-9.80749999999995[/C][/ROW]
[ROW][C]44[/C][C]314.76[/C][C]315.7175[/C][C]-0.957499999999982[/C][/ROW]
[ROW][C]45[/C][C]323.34[/C][C]332.9975[/C][C]-9.65750000000003[/C][/ROW]
[ROW][C]46[/C][C]341.58[/C][C]332.9975[/C][C]8.58249999999998[/C][/ROW]
[ROW][C]47[/C][C]330.12[/C][C]332.9975[/C][C]-2.8775[/C][/ROW]
[ROW][C]48[/C][C]318.16[/C][C]332.9975[/C][C]-14.8375000000000[/C][/ROW]
[ROW][C]49[/C][C]317.84[/C][C]332.9975[/C][C]-15.1575000000000[/C][/ROW]
[ROW][C]50[/C][C]325.39[/C][C]332.9975[/C][C]-7.60750000000002[/C][/ROW]
[ROW][C]51[/C][C]327.56[/C][C]332.9975[/C][C]-5.4375[/C][/ROW]
[ROW][C]52[/C][C]329.77[/C][C]332.9975[/C][C]-3.22750000000002[/C][/ROW]
[ROW][C]53[/C][C]333.29[/C][C]332.9975[/C][C]0.292500000000018[/C][/ROW]
[ROW][C]54[/C][C]346.1[/C][C]332.9975[/C][C]13.1025000000000[/C][/ROW]
[ROW][C]55[/C][C]358[/C][C]332.9975[/C][C]25.0025[/C][/ROW]
[ROW][C]56[/C][C]344.82[/C][C]332.9975[/C][C]11.8225[/C][/ROW]
[ROW][C]57[/C][C]313.3[/C][C]315.7175[/C][C]-2.41749999999996[/C][/ROW]
[ROW][C]58[/C][C]301.26[/C][C]315.7175[/C][C]-14.4575000000000[/C][/ROW]
[ROW][C]59[/C][C]306.38[/C][C]315.7175[/C][C]-9.33749999999998[/C][/ROW]
[ROW][C]60[/C][C]319.31[/C][C]315.7175[/C][C]3.59250000000003[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=113657&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=113657&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
1296.95308.569166666667-11.6191666666667
2296.84308.569166666667-11.7291666666667
3287.54308.569166666667-21.0291666666666
4287.81308.569166666667-20.7591666666667
5283.99282.048751.94125000000003
6275.79282.04875-6.25874999999996
7269.52282.04875-12.52875
8278.35282.04875-3.69874999999996
9283.43282.048751.38125000000002
10289.46282.048757.41125
11282.3282.048750.251250000000027
12293.55282.0487511.5012500000000
13304.78308.569166666667-3.78916666666669
14300.99308.569166666667-7.57916666666665
15315.29308.5691666666676.72083333333336
16316.21308.5691666666677.64083333333332
17331.79308.56916666666723.2208333333334
18329.38308.56916666666720.8108333333333
19317.27308.5691666666678.70083333333332
20317.98308.5691666666679.41083333333336
21340.28315.717524.5625
22339.21315.717523.4925
23336.71315.717520.9925
24340.11315.717524.3925000000000
25347.72315.717532.0025000000001
26328.68315.717512.9625000000000
27303.05315.7175-12.6675000000000
28299.83315.7175-15.8875
29320.04315.71754.32250000000005
30317.94315.71752.22250000000003
31303.31315.7175-12.4075000000000
32308.85315.7175-6.86749999999995
33319.19315.71753.47250000000003
34314.52315.7175-1.19749999999999
35312.39315.7175-3.32749999999999
36315.77315.71750.0525000000000091
37320.23315.71754.51250000000005
38309.45315.7175-6.26749999999998
39296.54315.7175-19.1775000000000
40297.28315.7175-18.4375
41301.39315.7175-14.3275
42306.68315.7175-9.03749999999997
43305.91315.7175-9.80749999999995
44314.76315.7175-0.957499999999982
45323.34332.9975-9.65750000000003
46341.58332.99758.58249999999998
47330.12332.9975-2.8775
48318.16332.9975-14.8375000000000
49317.84332.9975-15.1575000000000
50325.39332.9975-7.60750000000002
51327.56332.9975-5.4375
52329.77332.9975-3.22750000000002
53333.29332.99750.292500000000018
54346.1332.997513.1025000000000
55358332.997525.0025
56344.82332.997511.8225
57313.3315.7175-2.41749999999996
58301.26315.7175-14.4575000000000
59306.38315.7175-9.33749999999998
60319.31315.71753.59250000000003



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