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 computationWed, 29 Dec 2010 06:17:15 +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/29/t1293603315ernl3k69nba9mfu.htm/, Retrieved Fri, 03 May 2024 07:30:54 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=116602, Retrieved Fri, 03 May 2024 07:30:54 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact144
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
-       [Recursive Partitioning (Regression Trees)] [paper RP 2] [2010-12-29 06:17:15] [4c854bb223ec27caaa7bcfc5e77b0dbd] [Current]
Feedback Forum

Post a new message
Dataseries X:
5.2	67.7	32.4	5	7.7	1019	86
7.9	111.5	94.7	6.3	8.4	1010.4	77
8.7	29.4	133.4	3.9	8.7	1022.6	77
8.9	62.3	196.5	3.8	8.1	1015	71
15.3	19	307.3	3	11.2	1019.8	66
15.4	95.5	128.7	2.8	13.5	1013.7	77
18.1	30.4	279.9	3.3	14.5	1019.2	71
19.7	44.3	230.2	2.1	16.4	1018.3	72
13	56.5	92.2	2.9	12.5	1017.2	84
12.6	80	121.3	4	12.4	1010.9	83
6.2	66.1	73.4	3.4	9.1	1013.1	92
3.5	96.7	24	4	7.2	1017.1	89
3.4	83.5	93.8	4.6	6.8	1022.4	85
0	37.7	76.2	3.1	5.7	1017.8	87
9.5	24.6	113.3	3.6	9.3	1013.3	77
8.9	69.4	194.2	3.9	7.2	1016.3	65
10.4	26.9	155.3	2.9	8.7	1021.8	70
13.2	100.3	114	3.3	10.8	1013.1	71
18.9	110.6	193	2.7	15.5	1015.8	72
19	15.7	250.7	2.3	14.9	1019.3	70
16.3	55.7	173	2.5	13.5	1015.6	74
10.6	24.4	112.9	2.6	10.8	1015.6	84
5.8	174.6	63.2	3.9	8.3	1012	89
3.6	70.4	51.3	3.1	6.9	1027.9	85
2.6	30.6	45.7	3.2	6.7	1029.6	88
5	46.1	80.6	3.2	7.6	1023.6	86
7.3	92.8	78.8	3.9	8.5	1014.6	83
9.2	56.5	124.9	3.5	8.7	1012.1	75
15.7	49.3	252.5	3.3	11.7	1017.7	67
16.8	116.7	188.3	2.9	13.9	1014.9	74
18.4	67.6	192.6	2.7	15.7	1015.9	75
18.1	180.5	165	3.2	16.3	1012.4	78
14.6	31.3	139.1	3.2	13.2	1016.6	80
7.8	81.3	106.1	3.5	9.1	1008.7	85
7.6	87.9	46.8	4.2	9.5	1013.5	89
3.8	76	67.5	3.6	7.3	1017.6	89
5.6	84.9	51.8	4.6	8.4	1021.3	86
2.2	26.9	44.4	2.6	6.5	1028.8	91
6.8	4.2	169.2	3.4	7.2	1021.5	71
11.8	32	145.3	3.5	10	1010.2	72
14.9	73.7	200	3.4	12.3	1012.9	71
16.7	66	194.1	3	13.7	1015.5	73
16.7	107.6	167.3	3.2	14.9	1015.3	79
15.9	40.1	167.8	2.7	13.7	1018.4	76
13.6	94	105.9	3.1	13.1	1010.7	85
9.2	84	89.3	3.5	10.1	1013.4	85
2.8	73.2	87.1	3.2	10	1019.9	88
2.5	170.1	15.4	4.7	8.1	1006.9	92
4.8	99.1	38.6	4.5	7.9	1012.1	90
2.8	39.3	52.2	3.2	6.7	1014.4	84
7.8	95.3	104.5	4.5	8.8	1017.3	82
9	52.8	146.9	3.9	9.1	1012.2	77
12.9	69.4	152.9	2.9	11.2	1013.8	77
16.4	55	235.8	3.3	13.3	1019.2	72
21.8	68.6	268.6	2.6	17.6	1017.2	68
17.8	81.2	203.1	2.8	15.2	1015.1	75
13.5	118.7	98.1	3.2	13.5	1013.2	86
10	60.6	128.8	3.3	10.4	1015.2	83
10.4	33.6	62.1	2.9	11.5	1019.1	90
5.5	121.5	50.2	4.3	8.7	1018.7	93
4	143.6	56.2	4.8	7.2	1014.4	88
6.8	100.8	61.7	4.6	7.5	1012.1	85
5.7	76.9	155.3	4.2	6.8	1013.4	75
9.1	51.3	85.2	3.2	9.5	1017.8	81
13.6	60.4	224.3	2.8	10.4	1016.6	67
15	75.1	161.9	2.9	13.1	1018	78
20.9	50.4	243.4	2.7	17.6	1015.5	72
20.4	21.6	271.9	3	15.7	1017.7	67
14	61.8	16.8	3.2	13.1	1012	82
13.7	6	135.8	3	13.5	1020.6	84
7.1	41.4	78.7	3.2	8.7	1017.7	85
0.8	74.1	41.8	3.1	6	1017	89
2.1	15	81.8	3.5	6.3	1013.4	83
1.3	71.8	43.4	3.9	5.7	1013.3	82
3.9	26.1	131.4	3.2	6.3	1017.8	76
10.7	6	209.3	3.1	7.5	1017.7	59
11.1	73.4	96.8	3.4	9.9	1014.2	74
16.4	22.9	239.8	2.7	12.5	1021.1	68
17.1	56	211.6	3.1	13.3	1018.1	69
17.3	231.2	188.1	2.9	14.1	1015	72
12.9	47	147.8	3	11.5	1017.3	79
10.9	45.2	126.1	3	10.7	1017.1	83
5.3	116.7	49.8	3.7	8.4	1010.5	91
0.7	33.3	45.8	3.4	5.9	1014.8	85
-0.2	2.6	74.2	2.9	5.5	1023.2	86
6.5	96.2	42.4	4.7	7.9	1018.7	83
8.6	24.3	108.8	3.1	9.2	1024.3	83
8.5	24.4	200.1	3.3	7.9	1021.5	71
13.3	90.8	229	3.3	11.2	1015.1	74
16.2	91.4	181.8	3.1	13.7	1010.1	75
17.5	74.4	197.5	2.7	15.5	1018.2	77
21.2	52.6	254	2.6	17.6	1016	71
14.8	16.5	195.7	2.6	12.9	1021.9	76
10.3	89.1	146	3.3	10.5	1017.9	80
7.3	63.5	46.5	3.7	9.2	1007.2	88
5.1	74.9	29.7	4.2	8.1	1012.5	90
4.4	73.3	56.3	4.6	7.3	1016.4	85
6.2	14.5	103.8	3	7.9	1025.5	81
7.7	84	71.4	3.9	8.4	1022.5	79
9.3	107.2	93	3.5	9.3	1003.9	80
15.6	35.5	210.1	3	12.4	1016.4	71
16.3	87.7	167.6	3.3	14.3	1015.3	77
16.6	43.8	145.5	3.3	14.5	1013.8	78
17.4	64.7	212.5	2.7	14.5	1018.4	76
15.3	139.1	107.5	3.4	14.4	1010.3	84
9.7	128.7	48.3	4	10.8	1012.4	89
3.7	87.8	79.5	3.1	7.5	1018.4	89
4.6	81.7	30.6	3.8	7.7	1019.8	90
5.4	123.9	59.6	4.3	7.9	1014.5	85
3.1	76.3	63	3.7	6.8	1017.4	87
7.9	71.9	119.1	3.5	8.4	1011.7	80
10.1	71	142.3	3.4	9.9	1013.8	79
15	40	213.2	3.1	12.4	1015.7	72
15.6	83.1	205.6	3.1	13.2	1017.9	76
19.7	34.5	257	3.1	16.3	1017.1	73
18.1	91.2	177	2.7	15.3	1013.4	76
17.7	42.5	162.9	3.1	16	1011.1	81
10.7	47	120.1	3.7	11.2	1016.1	86
6.2	32.7	62.3	3.6	8.5	1021.7	88
4.2	171.9	26.6	4.4	7.7	1010.6	92
4	45.7	54.6	3.5	7.5	1025.1	90
5.9	81.9	89.4	4	7.9	1020.3	86
7.1	56.8	72.6	3.5	8.4	1020.7	84
10.5	65.1	155.1	3.5	9.6	1007.6	76
15.1	86.2	158.9	3	13.6	1015.2	79
16.8	35.1	235	3	14.1	1020	73
15.3	133.8	93.1	2.8	15.2	1013.4	86
18.4	34.5	227.6	2.4	16	1017.8	77
16.1	69.9	127.3	2.9	15.2	1013.7	83
11.3	98.3	87.3	4.1	11.9	1011.7	88
7.9	86.7	49.5	4.7	9.6	1003.4	88
5.6	58.2	41.9	4.2	8.5	1009.1	88
3.4	83.6	68.6	4	7.2	1011.6	91
4.8	83.5	59.4	3.7	7.7	1017.8	88
6.5	112.3	46.8	3.5	8.8	1004.9	88
8.5	134.3	95.4	3.6	9.1	1012.8	82
15.1	30	259.7	3.5	12.1	1017.5	72
15.7	44.5	201.4	2.9	12.8	1017.4	73
18.7	120.1	188.8	2.9	16.7	1014.5	78
19.2	43.4	220.8	2.9	15.5	1015.5	71
12.9	199.4	68.6	3	13.3	1013.4	90
14.4	68.1	113.7	3.6	14.1	1015.4	87
6.2	99.8	70.9	2.7	8.7	1022.9	91
3.3	69.5	61.3	3.3	6.9	1026.1	91
4.6	71.3	63.5	3.9	7.6	1022.8	87
7.2	167.8	76.4	5.3	8.4	1012.1	82
7.8	66.3	124.3	3.6	8	1018.2	75
9.9	41.9	193.1	3.5	8.1	1015.9	68
13.6	57.2	178.8	3.3	12	1013.6	78
17.1	72.3	200.2	2.9	14.5	1016.5	76
17.8	96.5	169.5	3.1	15.7	1016	79
18.6	172.1	152.1	2.3	17.2	1015.9	82
14.7	25.8	135.7	2.7	12.9	1019.8	79
10.5	105.1	91	3.5	10.9	1012.3	85
8.6	92.2	57.9	3.4	10	1008	90
4.4	109.3	37.9	3.8	8	1015.2	90
2.3	101.7	54.4	4	6.7	1016.5	86
2.8	29.1	145.7	3.3	5.7	1020.9	76
8.8	34.6	185.7	3.2	8.3	1023.8	73
10.7	46.7	211.7	3.6	8.7	1016.9	67
13.9	82	187.3	3	12.1	1017	78
19.3	34.4	258.3	2.8	16.1	1016	74
19.5	72.7	235	2.7	16.3	1016	74
20.4	44.4	244.3	2.5	16.7	1017.9	72
15.3	31	208.3	2.4	12.8	1020.3	75
7.9	64	127.1	3.3	9.2	1013.4	85
8.3	65.4	63.2	3.5	9.9	1014.9	89
4.5	64.5	66.8	3.5	7.7	1018.2	89
3.2	153.8	32.9	4.1	7.1	1009.9	89
5	48.8	56.3	3.7	7.3	1020.2	82
6.6	25	136.7	3.5	7.5	1020.7	76
11.1	37.2	142.8	3.4	9.3	1012.9	72
12.8	40.8	216.3	2.7	10.4	1016.3	72
16.3	78.4	200	3	13.7	1018	75
17.4	112.4	204.8	2.8	14.8	1016.7	76
18.9	122.7	159.3	3	16.7	1012.2	78
15.8	82.9	173.5	3.4	13.7	1019.7	77
11.7	67.6	101.6	3.6	11.5	1010.5	83
6.4	78.4	60.3	2.8	8.8	1022.1	90
2.9	65.7	51.9	2.7	7.1	1019.8	92
4.7	44.9	75.3	4	7.4	1022.8	83
2.4	80.9	69.8	3.4	6.2	1020.2	82
7.2	38.8	83.5	3.2	8.4	1016.4	80
10.7	46.1	120.1	3	9.4	1014.6	74
13.4	60	190.3	3.2	10.8	1017.3	71
18.5	53.9	246.8	2.8	13.5	1019	65
18.3	123.5	175.4	2.8	15.9	1015.3	76
16.8	69.5	185	2.6	15.1	1018.1	80
16.6	74.2	189.6	2.6	14.9	1018.4	79
14.1	47	140.3	3.4	13.2	1017	83
6.1	60.9	60.4	3.3	8.9	1016.5	92
3.5	51.4	26.7	3.3	7.3	1018.1	91
1.7	18.7	97.4	3.2	6.1	1024.6	85
2.3	83.1	29.9	3.4	6.5	1015.5	88
4.5	65.3	114.1	3.6	7	1011.2	79
9.3	46	141.3	3.2	8.8	1015.8	76
14.2	115.6	135.6	3.7	12.2	1015	77
17.3	25.8	246.2	2.5	13.4	1021.3	69
23	48.1	308.7	2.8	17.3	1019.7	64
16.3	202.3	94.5	2.9	15.1	1012.7	83
18.4	9.2	160.5	2.9	12.7	1015.1	77
14.2	56.3	108.3	3.5	13.5	1013	84
9.1	71.6	79.3	3.9	10.1	1017.3	87
5.9	93	40	4	8.3	1023	89
7.2	82.3	34.6	4.6	9	1018.4	86
6.8	95.4	48.7	3.6	8.5	1009.8	86
8	61.9	144.6	3.7	8	1015.7	77
14.3	0	284.2	2.8	9.9	1021.1	62
14.6	103.4	164.2	3.5	12.2	1011.5	75
17.5	99.2	130.3	3.1	15.3	1012.5	78
17.2	96.7	178.3	3.4	14.5	1012.8	75
17.2	56.9	150.8	2.8	14.6	1015.8	76
14.1	57.6	130.5	2.7	13	1020.5	81
10.5	65.2	108.5	2.4	11.2	1023.5	87
6.8	71.7	51.3	3.2	8.9	1020.3	89
4.1	89.2	70.3	3.8	7.2	1022.2	84
6.5	70.7	41.8	4.8	8.2	1016.1	83
6.1	35.4	125.7	3.6	6.9	1025	72
6.3	140.5	68.4	4.3	7.5	1007.1	78
9.3	45.4	135	3.2	8	1011.3	69
16.4	53.9	231	3	11.3	1014.8	62
16.1	69.9	184.7	2.8	13	1017.2	73
18	101.9	181.6	2.9	14.1	1015.2	72
17.6	89.3	138.3	3.1	14.4	1012.9	75
14	70.7	157.8	3.3	11.3	1017.7	75
10.5	72.4	122.1	3.1	10.5	1016	85
6.9	67.6	39.6	3.5	8.9	1013.5	90
2.8	43.3	59.8	2.9	6.7	1018.3	91
0.7	62.9	89.1	3.5	5.6	1013.9	86
3.6	57.1	33.1	3.2	6.8	1014.5	87
6.7	68.2	150.5	3.7	7	1015	75
12.5	47.1	196.9	3.1	9	1013.6	70
14.4	43.1	196.6	3.1	11.3	1018.7	72
16.5	64.5	225.2	3.1	12.6	1016.6	69
18.7	73.1	214.2	3.1	14.2	1013.7	70
19.4	37.7	258.3	2.9	13.6	1016.9	66
15.8	29.1	156.9	3.1	13.6	1021	78
11.3	105	89.8	2.9	10.9	1017.1	83
9.7	98	48.2	5.5	9.8	1006.6	84
2.9	80.8	46	4	6.9	1007.1	89




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time15 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 & 15 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=116602&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]15 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=116602&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=116602&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 time15 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'.







10-Fold Cross Validation
Prediction (training)Prediction (testing)
ActualC1C2CVC1C2CV
C11050690.938310380.9279
C24510240.95799920.9109
Overall--0.9479--0.9198

\begin{tabular}{lllllllll}
\hline
10-Fold Cross Validation \tabularnewline
 & Prediction (training) & Prediction (testing) \tabularnewline
Actual & C1 & C2 & CV & C1 & C2 & CV \tabularnewline
C1 & 1050 & 69 & 0.9383 & 103 & 8 & 0.9279 \tabularnewline
C2 & 45 & 1024 & 0.9579 & 9 & 92 & 0.9109 \tabularnewline
Overall & - & - & 0.9479 & - & - & 0.9198 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=116602&T=1

[TABLE]
[ROW][C]10-Fold Cross Validation[/C][/ROW]
[ROW][C][/C][C]Prediction (training)[/C][C]Prediction (testing)[/C][/ROW]
[ROW][C]Actual[/C][C]C1[/C][C]C2[/C][C]CV[/C][C]C1[/C][C]C2[/C][C]CV[/C][/ROW]
[ROW][C]C1[/C][C]1050[/C][C]69[/C][C]0.9383[/C][C]103[/C][C]8[/C][C]0.9279[/C][/ROW]
[ROW][C]C2[/C][C]45[/C][C]1024[/C][C]0.9579[/C][C]9[/C][C]92[/C][C]0.9109[/C][/ROW]
[ROW][C]Overall[/C][C]-[/C][C]-[/C][C]0.9479[/C][C]-[/C][C]-[/C][C]0.9198[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=116602&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=116602&T=1

As an alternative you can also use a QR Code:  

The GUIDs for individual cells are displayed in the table below:

10-Fold Cross Validation
Prediction (training)Prediction (testing)
ActualC1C2CVC1C2CV
C11050690.938310380.9279
C24510240.95799920.9109
Overall--0.9479--0.9198







Confusion Matrix (predicted in columns / actuals in rows)
C1C2
C111013
C20117

\begin{tabular}{lllllllll}
\hline
Confusion Matrix (predicted in columns / actuals in rows) \tabularnewline
 & C1 & C2 \tabularnewline
C1 & 110 & 13 \tabularnewline
C2 & 0 & 117 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=116602&T=2

[TABLE]
[ROW][C]Confusion Matrix (predicted in columns / actuals in rows)[/C][/ROW]
[ROW][C][/C][C]C1[/C][C]C2[/C][/ROW]
[ROW][C]C1[/C][C]110[/C][C]13[/C][/ROW]
[ROW][C]C2[/C][C]0[/C][C]117[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=116602&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=116602&T=2

As an alternative you can also use a QR Code:  

The GUIDs for individual cells are displayed in the table below:

Confusion Matrix (predicted in columns / actuals in rows)
C1C2
C111013
C20117



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