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 computationSat, 08 Dec 2012 11:28:54 -0500
Cite this page as followsStatistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?v=date/2012/Dec/08/t1354984407yhk2jl4bjpyn5wl.htm/, Retrieved Thu, 28 Mar 2024 22:30:38 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=197677, Retrieved Thu, 28 Mar 2024 22:30:38 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact84
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
-     [Kendall tau Correlation Matrix] [] [2010-12-05 17:44:33] [b98453cac15ba1066b407e146608df68]
- RMPD    [Recursive Partitioning (Regression Trees)] [ws 10 recursive p...] [2012-12-08 16:28:54] [5948b95c00a54abd73f88aac58cf0e09] [Current]
Feedback Forum

Post a new message
Dataseries X:
25 2 10 1.5 0 6 5.70 11.40
 24 2 10 1.5 0 10 17.56 35.12
 30 2 10 1.5 2 6 11.28 22.56
 2 2 10 1.5 2 10 8.39 16.78
 40 2 10 2.5 0 6 16.67 33.34
 37 2 10 2.5 0 10 12.04 24.08
 16 2 10 2.5 2 6 9.22 18.44
 22 2 10 2.5 2 10 3.94 7.88
 33 2 30 1.5 0 6 27.02 18.01
 17 2 30 1.5 0 10 19.46 12.97
 28 2 30 1.5 2 6 18.54 12.36
 27 2 30 1.5 2 10 25.70 17.13
 14 2 30 2.5 0 6 19.02 12.68
 13 2 30 2.5 0 10 22.39 14.93
 4 2 30 2.5 2 6 23.85 15.90
 21 2 30 2.5 2 10 30.12 20.08
 23 6 10 1.5 0 6 13.42 26.84
 35 6 10 1.5 0 10 34.26 68.52
 19 6 10 1.5 2 6 39.74 79.48
 34 6 10 1.5 2 10 10.60 21.20
 31 6 10 2.5 0 6 28.89 57.78
 9 6 10 2.5 0 10 35.61 71.22
 38 6 10 2.5 2 6 17.20 34.40
 15 6 10 2.5 2 10 6.00 12.00
 39 6 30 1.5 0 6 129.45 86.30
 8 6 30 1.5 0 10 107.38 71.59
 26 6 30 1.5 2 6 111.66 74.44
 11 6 30 1.5 2 10 109.10 72.73
 6 6 30 2.5 0 6 100.43 66.95
 20 6 30 2.5 0 10 109.28 72.85
 10 6 30 2.5 2 6 106.46 70.97
 32 6 30 2.5 2 10 134.01 89.34
 1 4 20 2.0 1 8 10.78 10.78
 3 4 20 2.0 1 8 9.39 9.39
 5 4 20 2.0 1 8 9.84 9.84
 7 4 20 2.0 1 8 13.94 13.94
 12 4 20 2.0 1 8 12.33 12.33
 18 4 20 2.0 1 8 7.32 7.32
 29 4 20 2.0 1 8 7.91 7.91
 36 4 20 2.0 1 8 15.58 15.58




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time5 seconds
R Server'George Udny Yule' @ yule.wessa.net

\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 & 5 seconds \tabularnewline
R Server & 'George Udny Yule' @ yule.wessa.net \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=197677&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]5 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'George Udny Yule' @ yule.wessa.net[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=197677&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=197677&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 time5 seconds
R Server'George Udny Yule' @ yule.wessa.net







Goodness of Fit
Correlation0.9332
R-squared0.8708
RMSE9.7281

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

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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=197677&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.9332
R-squared0.8708
RMSE9.7281







Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
111.418.378275862069-6.97827586206896
235.1218.37827586206916.741724137931
322.5618.3782758620694.18172413793103
416.7818.378275862069-1.59827586206896
533.3418.37827586206914.961724137931
624.0818.3782758620695.70172413793103
718.4418.3782758620690.0617241379310371
87.8818.378275862069-10.498275862069
918.0118.378275862069-0.368275862068963
1012.9718.378275862069-5.40827586206896
1112.3618.378275862069-6.01827586206896
1217.1318.378275862069-1.24827586206897
1312.6818.378275862069-5.69827586206896
1414.9318.378275862069-3.44827586206896
1515.918.378275862069-2.47827586206896
1620.0818.3782758620691.70172413793103
1726.8418.3782758620698.46172413793104
1868.5274.9445454545454-6.42454545454545
1979.4874.94454545454544.53545454545456
2021.218.3782758620692.82172413793104
2157.7818.37827586206939.401724137931
2271.2274.9445454545454-3.72454545454545
2334.418.37827586206916.021724137931
241218.378275862069-6.37827586206896
2586.374.944545454545411.3554545454545
2671.5974.9445454545454-3.35454545454544
2774.4474.9445454545454-0.50454545454545
2872.7374.9445454545454-2.21454545454544
2966.9574.9445454545454-7.99454545454545
3072.8574.9445454545454-2.09454545454545
3170.9774.9445454545454-3.97454545454545
3289.3474.944545454545414.3954545454546
3310.7818.378275862069-7.59827586206896
349.3918.378275862069-8.98827586206896
359.8418.378275862069-8.53827586206896
3613.9418.378275862069-4.43827586206896
3712.3318.378275862069-6.04827586206896
387.3218.378275862069-11.058275862069
397.9118.378275862069-10.468275862069
4015.5818.378275862069-2.79827586206896

\begin{tabular}{lllllllll}
\hline
Actuals, Predictions, and Residuals \tabularnewline
# & Actuals & Forecasts & Residuals \tabularnewline
1 & 11.4 & 18.378275862069 & -6.97827586206896 \tabularnewline
2 & 35.12 & 18.378275862069 & 16.741724137931 \tabularnewline
3 & 22.56 & 18.378275862069 & 4.18172413793103 \tabularnewline
4 & 16.78 & 18.378275862069 & -1.59827586206896 \tabularnewline
5 & 33.34 & 18.378275862069 & 14.961724137931 \tabularnewline
6 & 24.08 & 18.378275862069 & 5.70172413793103 \tabularnewline
7 & 18.44 & 18.378275862069 & 0.0617241379310371 \tabularnewline
8 & 7.88 & 18.378275862069 & -10.498275862069 \tabularnewline
9 & 18.01 & 18.378275862069 & -0.368275862068963 \tabularnewline
10 & 12.97 & 18.378275862069 & -5.40827586206896 \tabularnewline
11 & 12.36 & 18.378275862069 & -6.01827586206896 \tabularnewline
12 & 17.13 & 18.378275862069 & -1.24827586206897 \tabularnewline
13 & 12.68 & 18.378275862069 & -5.69827586206896 \tabularnewline
14 & 14.93 & 18.378275862069 & -3.44827586206896 \tabularnewline
15 & 15.9 & 18.378275862069 & -2.47827586206896 \tabularnewline
16 & 20.08 & 18.378275862069 & 1.70172413793103 \tabularnewline
17 & 26.84 & 18.378275862069 & 8.46172413793104 \tabularnewline
18 & 68.52 & 74.9445454545454 & -6.42454545454545 \tabularnewline
19 & 79.48 & 74.9445454545454 & 4.53545454545456 \tabularnewline
20 & 21.2 & 18.378275862069 & 2.82172413793104 \tabularnewline
21 & 57.78 & 18.378275862069 & 39.401724137931 \tabularnewline
22 & 71.22 & 74.9445454545454 & -3.72454545454545 \tabularnewline
23 & 34.4 & 18.378275862069 & 16.021724137931 \tabularnewline
24 & 12 & 18.378275862069 & -6.37827586206896 \tabularnewline
25 & 86.3 & 74.9445454545454 & 11.3554545454545 \tabularnewline
26 & 71.59 & 74.9445454545454 & -3.35454545454544 \tabularnewline
27 & 74.44 & 74.9445454545454 & -0.50454545454545 \tabularnewline
28 & 72.73 & 74.9445454545454 & -2.21454545454544 \tabularnewline
29 & 66.95 & 74.9445454545454 & -7.99454545454545 \tabularnewline
30 & 72.85 & 74.9445454545454 & -2.09454545454545 \tabularnewline
31 & 70.97 & 74.9445454545454 & -3.97454545454545 \tabularnewline
32 & 89.34 & 74.9445454545454 & 14.3954545454546 \tabularnewline
33 & 10.78 & 18.378275862069 & -7.59827586206896 \tabularnewline
34 & 9.39 & 18.378275862069 & -8.98827586206896 \tabularnewline
35 & 9.84 & 18.378275862069 & -8.53827586206896 \tabularnewline
36 & 13.94 & 18.378275862069 & -4.43827586206896 \tabularnewline
37 & 12.33 & 18.378275862069 & -6.04827586206896 \tabularnewline
38 & 7.32 & 18.378275862069 & -11.058275862069 \tabularnewline
39 & 7.91 & 18.378275862069 & -10.468275862069 \tabularnewline
40 & 15.58 & 18.378275862069 & -2.79827586206896 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=197677&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]11.4[/C][C]18.378275862069[/C][C]-6.97827586206896[/C][/ROW]
[ROW][C]2[/C][C]35.12[/C][C]18.378275862069[/C][C]16.741724137931[/C][/ROW]
[ROW][C]3[/C][C]22.56[/C][C]18.378275862069[/C][C]4.18172413793103[/C][/ROW]
[ROW][C]4[/C][C]16.78[/C][C]18.378275862069[/C][C]-1.59827586206896[/C][/ROW]
[ROW][C]5[/C][C]33.34[/C][C]18.378275862069[/C][C]14.961724137931[/C][/ROW]
[ROW][C]6[/C][C]24.08[/C][C]18.378275862069[/C][C]5.70172413793103[/C][/ROW]
[ROW][C]7[/C][C]18.44[/C][C]18.378275862069[/C][C]0.0617241379310371[/C][/ROW]
[ROW][C]8[/C][C]7.88[/C][C]18.378275862069[/C][C]-10.498275862069[/C][/ROW]
[ROW][C]9[/C][C]18.01[/C][C]18.378275862069[/C][C]-0.368275862068963[/C][/ROW]
[ROW][C]10[/C][C]12.97[/C][C]18.378275862069[/C][C]-5.40827586206896[/C][/ROW]
[ROW][C]11[/C][C]12.36[/C][C]18.378275862069[/C][C]-6.01827586206896[/C][/ROW]
[ROW][C]12[/C][C]17.13[/C][C]18.378275862069[/C][C]-1.24827586206897[/C][/ROW]
[ROW][C]13[/C][C]12.68[/C][C]18.378275862069[/C][C]-5.69827586206896[/C][/ROW]
[ROW][C]14[/C][C]14.93[/C][C]18.378275862069[/C][C]-3.44827586206896[/C][/ROW]
[ROW][C]15[/C][C]15.9[/C][C]18.378275862069[/C][C]-2.47827586206896[/C][/ROW]
[ROW][C]16[/C][C]20.08[/C][C]18.378275862069[/C][C]1.70172413793103[/C][/ROW]
[ROW][C]17[/C][C]26.84[/C][C]18.378275862069[/C][C]8.46172413793104[/C][/ROW]
[ROW][C]18[/C][C]68.52[/C][C]74.9445454545454[/C][C]-6.42454545454545[/C][/ROW]
[ROW][C]19[/C][C]79.48[/C][C]74.9445454545454[/C][C]4.53545454545456[/C][/ROW]
[ROW][C]20[/C][C]21.2[/C][C]18.378275862069[/C][C]2.82172413793104[/C][/ROW]
[ROW][C]21[/C][C]57.78[/C][C]18.378275862069[/C][C]39.401724137931[/C][/ROW]
[ROW][C]22[/C][C]71.22[/C][C]74.9445454545454[/C][C]-3.72454545454545[/C][/ROW]
[ROW][C]23[/C][C]34.4[/C][C]18.378275862069[/C][C]16.021724137931[/C][/ROW]
[ROW][C]24[/C][C]12[/C][C]18.378275862069[/C][C]-6.37827586206896[/C][/ROW]
[ROW][C]25[/C][C]86.3[/C][C]74.9445454545454[/C][C]11.3554545454545[/C][/ROW]
[ROW][C]26[/C][C]71.59[/C][C]74.9445454545454[/C][C]-3.35454545454544[/C][/ROW]
[ROW][C]27[/C][C]74.44[/C][C]74.9445454545454[/C][C]-0.50454545454545[/C][/ROW]
[ROW][C]28[/C][C]72.73[/C][C]74.9445454545454[/C][C]-2.21454545454544[/C][/ROW]
[ROW][C]29[/C][C]66.95[/C][C]74.9445454545454[/C][C]-7.99454545454545[/C][/ROW]
[ROW][C]30[/C][C]72.85[/C][C]74.9445454545454[/C][C]-2.09454545454545[/C][/ROW]
[ROW][C]31[/C][C]70.97[/C][C]74.9445454545454[/C][C]-3.97454545454545[/C][/ROW]
[ROW][C]32[/C][C]89.34[/C][C]74.9445454545454[/C][C]14.3954545454546[/C][/ROW]
[ROW][C]33[/C][C]10.78[/C][C]18.378275862069[/C][C]-7.59827586206896[/C][/ROW]
[ROW][C]34[/C][C]9.39[/C][C]18.378275862069[/C][C]-8.98827586206896[/C][/ROW]
[ROW][C]35[/C][C]9.84[/C][C]18.378275862069[/C][C]-8.53827586206896[/C][/ROW]
[ROW][C]36[/C][C]13.94[/C][C]18.378275862069[/C][C]-4.43827586206896[/C][/ROW]
[ROW][C]37[/C][C]12.33[/C][C]18.378275862069[/C][C]-6.04827586206896[/C][/ROW]
[ROW][C]38[/C][C]7.32[/C][C]18.378275862069[/C][C]-11.058275862069[/C][/ROW]
[ROW][C]39[/C][C]7.91[/C][C]18.378275862069[/C][C]-10.468275862069[/C][/ROW]
[ROW][C]40[/C][C]15.58[/C][C]18.378275862069[/C][C]-2.79827586206896[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=197677&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=197677&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
111.418.378275862069-6.97827586206896
235.1218.37827586206916.741724137931
322.5618.3782758620694.18172413793103
416.7818.378275862069-1.59827586206896
533.3418.37827586206914.961724137931
624.0818.3782758620695.70172413793103
718.4418.3782758620690.0617241379310371
87.8818.378275862069-10.498275862069
918.0118.378275862069-0.368275862068963
1012.9718.378275862069-5.40827586206896
1112.3618.378275862069-6.01827586206896
1217.1318.378275862069-1.24827586206897
1312.6818.378275862069-5.69827586206896
1414.9318.378275862069-3.44827586206896
1515.918.378275862069-2.47827586206896
1620.0818.3782758620691.70172413793103
1726.8418.3782758620698.46172413793104
1868.5274.9445454545454-6.42454545454545
1979.4874.94454545454544.53545454545456
2021.218.3782758620692.82172413793104
2157.7818.37827586206939.401724137931
2271.2274.9445454545454-3.72454545454545
2334.418.37827586206916.021724137931
241218.378275862069-6.37827586206896
2586.374.944545454545411.3554545454545
2671.5974.9445454545454-3.35454545454544
2774.4474.9445454545454-0.50454545454545
2872.7374.9445454545454-2.21454545454544
2966.9574.9445454545454-7.99454545454545
3072.8574.9445454545454-2.09454545454545
3170.9774.9445454545454-3.97454545454545
3289.3474.944545454545414.3954545454546
3310.7818.378275862069-7.59827586206896
349.3918.378275862069-8.98827586206896
359.8418.378275862069-8.53827586206896
3613.9418.378275862069-4.43827586206896
3712.3318.378275862069-6.04827586206896
387.3218.378275862069-11.058275862069
397.9118.378275862069-10.468275862069
4015.5818.378275862069-2.79827586206896



Parameters (Session):
par1 = 8 ; par2 = none ; par3 = 0 ; par4 = no ;
Parameters (R input):
par1 = 8 ; par2 = none ; par3 = 0 ; par4 = no ;
R code (references can be found in the software module):
par4 <- 'no'
par3 <- '3'
par2 <- 'none'
par1 <- '8'
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')
}