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 21:03:33 +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/t12923609863te3v8td0m3yitt.htm/, Retrieved Fri, 03 May 2024 01:23:22 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=110203, Retrieved Fri, 03 May 2024 01:23:22 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact120
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)] [recursive partiti...] [2010-12-14 21:03:33] [b47314d83d48c7bf812ec2bcd743b159] [Current]
Feedback Forum

Post a new message
Dataseries X:
113	14.3	15.89
110	14.2	16.93
107	15.9	20.28
103	15.3	22.52
98	15.5	23.51
98	15.1	22.59
137	15	23.51
148	12.1	24.76
147	15.8	26.08
139	16.9	25.29
130	15.1	23.38
128	13.7	25.29
127	14.8	28.42
123	14.7	31.85
118	16	30.1
114	15.4	25.45
108	15	24.95
111	15.5	26.84
151	15.1	27.52
159	11.7	27.94
158	16.3	25.23
148	16.7	26.53
138	15	27.21
137	14.9	28.53
136	14.6	30.35
133	15.3	31.21
126	17.9	32.86
120	16.4	33.2
114	15.4	35.73
116	17.9	34.53
153	15.9	36.54
162	13.9	40.1
161	17.8	40.56
149	17.9	46.14
139	17.4	42.85
135	16.7	38.22
130	16	40.18
127	16.6	42.19
122	19.1	47.56
117	17.8	47.26
112	17.2	44.03
113	18.6	49.83
149	16.3	53.35
157	15.1	58.9
157	19.2	59.64
147	17.7	56.99
137	19.1	53.2
132	18	53.24
125	17.5	57.85
123	17.8	55.69
117	21.1	55.64
114	17.2	62.52
111	19.4	64.4
112	19.8	64.65
144	17.6	67.71
150	16.2	67.21
149	19.5	59.37
134	19.9	53.26
123	20	52.42
116	17.3	55.03




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time6 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 & 6 seconds \tabularnewline
R Server & 'George Udny Yule' @ 72.249.76.132 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=110203&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]'George Udny Yule' @ 72.249.76.132[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=110203&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=110203&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'George Udny Yule' @ 72.249.76.132







Goodness of Fit
CorrelationNA
R-squaredNA
RMSE17.1063

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

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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=110203&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
CorrelationNA
R-squaredNA
RMSE17.1063







Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
1113130.2-17.2
2110130.2-20.2
3107130.2-23.2
4103130.2-27.2
598130.2-32.2
698130.2-32.2
7137130.26.80000000000001
8148130.217.8
9147130.216.8
10139130.28.80000000000001
11130130.2-0.199999999999989
12128130.2-2.19999999999999
13127130.2-3.19999999999999
14123130.2-7.19999999999999
15118130.2-12.2
16114130.2-16.2
17108130.2-22.2
18111130.2-19.2
19151130.220.8
20159130.228.8
21158130.227.8
22148130.217.8
23138130.27.80000000000001
24137130.26.80000000000001
25136130.25.80000000000001
26133130.22.80000000000001
27126130.2-4.19999999999999
28120130.2-10.2000000000000
29114130.2-16.2
30116130.2-14.2
31153130.222.8
32162130.231.8
33161130.230.8
34149130.218.8
35139130.28.80000000000001
36135130.24.80000000000001
37130130.2-0.199999999999989
38127130.2-3.19999999999999
39122130.2-8.19999999999999
40117130.2-13.2
41112130.2-18.2
42113130.2-17.2
43149130.218.8
44157130.226.8
45157130.226.8
46147130.216.8
47137130.26.80000000000001
48132130.21.80000000000001
49125130.2-5.19999999999999
50123130.2-7.19999999999999
51117130.2-13.2
52114130.2-16.2
53111130.2-19.2
54112130.2-18.2
55144130.213.8
56150130.219.8
57149130.218.8
58134130.23.80000000000001
59123130.2-7.19999999999999
60116130.2-14.2

\begin{tabular}{lllllllll}
\hline
Actuals, Predictions, and Residuals \tabularnewline
# & Actuals & Forecasts & Residuals \tabularnewline
1 & 113 & 130.2 & -17.2 \tabularnewline
2 & 110 & 130.2 & -20.2 \tabularnewline
3 & 107 & 130.2 & -23.2 \tabularnewline
4 & 103 & 130.2 & -27.2 \tabularnewline
5 & 98 & 130.2 & -32.2 \tabularnewline
6 & 98 & 130.2 & -32.2 \tabularnewline
7 & 137 & 130.2 & 6.80000000000001 \tabularnewline
8 & 148 & 130.2 & 17.8 \tabularnewline
9 & 147 & 130.2 & 16.8 \tabularnewline
10 & 139 & 130.2 & 8.80000000000001 \tabularnewline
11 & 130 & 130.2 & -0.199999999999989 \tabularnewline
12 & 128 & 130.2 & -2.19999999999999 \tabularnewline
13 & 127 & 130.2 & -3.19999999999999 \tabularnewline
14 & 123 & 130.2 & -7.19999999999999 \tabularnewline
15 & 118 & 130.2 & -12.2 \tabularnewline
16 & 114 & 130.2 & -16.2 \tabularnewline
17 & 108 & 130.2 & -22.2 \tabularnewline
18 & 111 & 130.2 & -19.2 \tabularnewline
19 & 151 & 130.2 & 20.8 \tabularnewline
20 & 159 & 130.2 & 28.8 \tabularnewline
21 & 158 & 130.2 & 27.8 \tabularnewline
22 & 148 & 130.2 & 17.8 \tabularnewline
23 & 138 & 130.2 & 7.80000000000001 \tabularnewline
24 & 137 & 130.2 & 6.80000000000001 \tabularnewline
25 & 136 & 130.2 & 5.80000000000001 \tabularnewline
26 & 133 & 130.2 & 2.80000000000001 \tabularnewline
27 & 126 & 130.2 & -4.19999999999999 \tabularnewline
28 & 120 & 130.2 & -10.2000000000000 \tabularnewline
29 & 114 & 130.2 & -16.2 \tabularnewline
30 & 116 & 130.2 & -14.2 \tabularnewline
31 & 153 & 130.2 & 22.8 \tabularnewline
32 & 162 & 130.2 & 31.8 \tabularnewline
33 & 161 & 130.2 & 30.8 \tabularnewline
34 & 149 & 130.2 & 18.8 \tabularnewline
35 & 139 & 130.2 & 8.80000000000001 \tabularnewline
36 & 135 & 130.2 & 4.80000000000001 \tabularnewline
37 & 130 & 130.2 & -0.199999999999989 \tabularnewline
38 & 127 & 130.2 & -3.19999999999999 \tabularnewline
39 & 122 & 130.2 & -8.19999999999999 \tabularnewline
40 & 117 & 130.2 & -13.2 \tabularnewline
41 & 112 & 130.2 & -18.2 \tabularnewline
42 & 113 & 130.2 & -17.2 \tabularnewline
43 & 149 & 130.2 & 18.8 \tabularnewline
44 & 157 & 130.2 & 26.8 \tabularnewline
45 & 157 & 130.2 & 26.8 \tabularnewline
46 & 147 & 130.2 & 16.8 \tabularnewline
47 & 137 & 130.2 & 6.80000000000001 \tabularnewline
48 & 132 & 130.2 & 1.80000000000001 \tabularnewline
49 & 125 & 130.2 & -5.19999999999999 \tabularnewline
50 & 123 & 130.2 & -7.19999999999999 \tabularnewline
51 & 117 & 130.2 & -13.2 \tabularnewline
52 & 114 & 130.2 & -16.2 \tabularnewline
53 & 111 & 130.2 & -19.2 \tabularnewline
54 & 112 & 130.2 & -18.2 \tabularnewline
55 & 144 & 130.2 & 13.8 \tabularnewline
56 & 150 & 130.2 & 19.8 \tabularnewline
57 & 149 & 130.2 & 18.8 \tabularnewline
58 & 134 & 130.2 & 3.80000000000001 \tabularnewline
59 & 123 & 130.2 & -7.19999999999999 \tabularnewline
60 & 116 & 130.2 & -14.2 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=110203&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]113[/C][C]130.2[/C][C]-17.2[/C][/ROW]
[ROW][C]2[/C][C]110[/C][C]130.2[/C][C]-20.2[/C][/ROW]
[ROW][C]3[/C][C]107[/C][C]130.2[/C][C]-23.2[/C][/ROW]
[ROW][C]4[/C][C]103[/C][C]130.2[/C][C]-27.2[/C][/ROW]
[ROW][C]5[/C][C]98[/C][C]130.2[/C][C]-32.2[/C][/ROW]
[ROW][C]6[/C][C]98[/C][C]130.2[/C][C]-32.2[/C][/ROW]
[ROW][C]7[/C][C]137[/C][C]130.2[/C][C]6.80000000000001[/C][/ROW]
[ROW][C]8[/C][C]148[/C][C]130.2[/C][C]17.8[/C][/ROW]
[ROW][C]9[/C][C]147[/C][C]130.2[/C][C]16.8[/C][/ROW]
[ROW][C]10[/C][C]139[/C][C]130.2[/C][C]8.80000000000001[/C][/ROW]
[ROW][C]11[/C][C]130[/C][C]130.2[/C][C]-0.199999999999989[/C][/ROW]
[ROW][C]12[/C][C]128[/C][C]130.2[/C][C]-2.19999999999999[/C][/ROW]
[ROW][C]13[/C][C]127[/C][C]130.2[/C][C]-3.19999999999999[/C][/ROW]
[ROW][C]14[/C][C]123[/C][C]130.2[/C][C]-7.19999999999999[/C][/ROW]
[ROW][C]15[/C][C]118[/C][C]130.2[/C][C]-12.2[/C][/ROW]
[ROW][C]16[/C][C]114[/C][C]130.2[/C][C]-16.2[/C][/ROW]
[ROW][C]17[/C][C]108[/C][C]130.2[/C][C]-22.2[/C][/ROW]
[ROW][C]18[/C][C]111[/C][C]130.2[/C][C]-19.2[/C][/ROW]
[ROW][C]19[/C][C]151[/C][C]130.2[/C][C]20.8[/C][/ROW]
[ROW][C]20[/C][C]159[/C][C]130.2[/C][C]28.8[/C][/ROW]
[ROW][C]21[/C][C]158[/C][C]130.2[/C][C]27.8[/C][/ROW]
[ROW][C]22[/C][C]148[/C][C]130.2[/C][C]17.8[/C][/ROW]
[ROW][C]23[/C][C]138[/C][C]130.2[/C][C]7.80000000000001[/C][/ROW]
[ROW][C]24[/C][C]137[/C][C]130.2[/C][C]6.80000000000001[/C][/ROW]
[ROW][C]25[/C][C]136[/C][C]130.2[/C][C]5.80000000000001[/C][/ROW]
[ROW][C]26[/C][C]133[/C][C]130.2[/C][C]2.80000000000001[/C][/ROW]
[ROW][C]27[/C][C]126[/C][C]130.2[/C][C]-4.19999999999999[/C][/ROW]
[ROW][C]28[/C][C]120[/C][C]130.2[/C][C]-10.2000000000000[/C][/ROW]
[ROW][C]29[/C][C]114[/C][C]130.2[/C][C]-16.2[/C][/ROW]
[ROW][C]30[/C][C]116[/C][C]130.2[/C][C]-14.2[/C][/ROW]
[ROW][C]31[/C][C]153[/C][C]130.2[/C][C]22.8[/C][/ROW]
[ROW][C]32[/C][C]162[/C][C]130.2[/C][C]31.8[/C][/ROW]
[ROW][C]33[/C][C]161[/C][C]130.2[/C][C]30.8[/C][/ROW]
[ROW][C]34[/C][C]149[/C][C]130.2[/C][C]18.8[/C][/ROW]
[ROW][C]35[/C][C]139[/C][C]130.2[/C][C]8.80000000000001[/C][/ROW]
[ROW][C]36[/C][C]135[/C][C]130.2[/C][C]4.80000000000001[/C][/ROW]
[ROW][C]37[/C][C]130[/C][C]130.2[/C][C]-0.199999999999989[/C][/ROW]
[ROW][C]38[/C][C]127[/C][C]130.2[/C][C]-3.19999999999999[/C][/ROW]
[ROW][C]39[/C][C]122[/C][C]130.2[/C][C]-8.19999999999999[/C][/ROW]
[ROW][C]40[/C][C]117[/C][C]130.2[/C][C]-13.2[/C][/ROW]
[ROW][C]41[/C][C]112[/C][C]130.2[/C][C]-18.2[/C][/ROW]
[ROW][C]42[/C][C]113[/C][C]130.2[/C][C]-17.2[/C][/ROW]
[ROW][C]43[/C][C]149[/C][C]130.2[/C][C]18.8[/C][/ROW]
[ROW][C]44[/C][C]157[/C][C]130.2[/C][C]26.8[/C][/ROW]
[ROW][C]45[/C][C]157[/C][C]130.2[/C][C]26.8[/C][/ROW]
[ROW][C]46[/C][C]147[/C][C]130.2[/C][C]16.8[/C][/ROW]
[ROW][C]47[/C][C]137[/C][C]130.2[/C][C]6.80000000000001[/C][/ROW]
[ROW][C]48[/C][C]132[/C][C]130.2[/C][C]1.80000000000001[/C][/ROW]
[ROW][C]49[/C][C]125[/C][C]130.2[/C][C]-5.19999999999999[/C][/ROW]
[ROW][C]50[/C][C]123[/C][C]130.2[/C][C]-7.19999999999999[/C][/ROW]
[ROW][C]51[/C][C]117[/C][C]130.2[/C][C]-13.2[/C][/ROW]
[ROW][C]52[/C][C]114[/C][C]130.2[/C][C]-16.2[/C][/ROW]
[ROW][C]53[/C][C]111[/C][C]130.2[/C][C]-19.2[/C][/ROW]
[ROW][C]54[/C][C]112[/C][C]130.2[/C][C]-18.2[/C][/ROW]
[ROW][C]55[/C][C]144[/C][C]130.2[/C][C]13.8[/C][/ROW]
[ROW][C]56[/C][C]150[/C][C]130.2[/C][C]19.8[/C][/ROW]
[ROW][C]57[/C][C]149[/C][C]130.2[/C][C]18.8[/C][/ROW]
[ROW][C]58[/C][C]134[/C][C]130.2[/C][C]3.80000000000001[/C][/ROW]
[ROW][C]59[/C][C]123[/C][C]130.2[/C][C]-7.19999999999999[/C][/ROW]
[ROW][C]60[/C][C]116[/C][C]130.2[/C][C]-14.2[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=110203&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=110203&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
1113130.2-17.2
2110130.2-20.2
3107130.2-23.2
4103130.2-27.2
598130.2-32.2
698130.2-32.2
7137130.26.80000000000001
8148130.217.8
9147130.216.8
10139130.28.80000000000001
11130130.2-0.199999999999989
12128130.2-2.19999999999999
13127130.2-3.19999999999999
14123130.2-7.19999999999999
15118130.2-12.2
16114130.2-16.2
17108130.2-22.2
18111130.2-19.2
19151130.220.8
20159130.228.8
21158130.227.8
22148130.217.8
23138130.27.80000000000001
24137130.26.80000000000001
25136130.25.80000000000001
26133130.22.80000000000001
27126130.2-4.19999999999999
28120130.2-10.2000000000000
29114130.2-16.2
30116130.2-14.2
31153130.222.8
32162130.231.8
33161130.230.8
34149130.218.8
35139130.28.80000000000001
36135130.24.80000000000001
37130130.2-0.199999999999989
38127130.2-3.19999999999999
39122130.2-8.19999999999999
40117130.2-13.2
41112130.2-18.2
42113130.2-17.2
43149130.218.8
44157130.226.8
45157130.226.8
46147130.216.8
47137130.26.80000000000001
48132130.21.80000000000001
49125130.2-5.19999999999999
50123130.2-7.19999999999999
51117130.2-13.2
52114130.2-16.2
53111130.2-19.2
54112130.2-18.2
55144130.213.8
56150130.219.8
57149130.218.8
58134130.23.80000000000001
59123130.2-7.19999999999999
60116130.2-14.2



Parameters (Session):
par1 = 1 ; par2 = Do not include Seasonal Dummies ; par3 = No Linear Trend ; par4 = 0 ; par5 = 0 ; par6 = 0 ;
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')
}