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 computationThu, 06 Dec 2012 13:05:48 -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/06/t1354817179sqihckym7212c1j.htm/, Retrieved Sat, 27 Apr 2024 02:57:32 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=197193, Retrieved Sat, 27 Apr 2024 02:57:32 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact96
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]
- R PD    [Recursive Partitioning (Regression Trees)] [WS10 Werkloosheid...] [2012-12-06 18:05:48] [4cf5995ff1ac45697158e3095d381e89] [Current]
Feedback Forum

Post a new message
Dataseries X:
132838	312991	5599	47645	15545	575093	30406
129842	301647	5234	45970	15001	557560	29511
129694	305353	5279	48069	14961	564478	30857
130080	313665	5391	53080	15245	580523	33161
131496	322402	5280	57896	15656	596594	34097
131556	318280	5173	54344	15577	586570	32108
128925	292852	4724	40482	14630	536214	24789
127836	287481	4554	37110	14336	523597	23238
129164	295210	4713	39263	14834	536535	23915
129531	295650	4811	38889	14921	536322	23764
128548	292919	4668	39593	14707	532638	23990
127330	290649	4516	39305	14516	528222	24071
123815	281687	4203	40560	14055	516141	24448
124393	270336	4016	38306	13493	501866	23794
123707	271420	3993	40911	13528	506174	25025
123736	278183	3971	44700	13719	517945	26921
124507	284913	3838	50328	14170	533590	28575
125005	283487	3891	47499	14009	528379	27256
121383	256677	3306	34446	13159	477580	21065
121200	252945	3235	31434	12927	469357	20454
125249	264963	3404	34066	13510	490243	21672
125253	265988	3400	35044	13520	492622	22217
127977	274857	3447	37040	14089	507561	23046
128984	279650	3431	38706	14251	516922	24364
126770	276715	3321	40430	13980	514258	25631
126448	273887	3189	39613	13715	509846	25360
127845	282308	3256	44236	14112	527070	27534
128818	289847	3290	47859	14289	541657	29853
132127	301101	3475	53711	15020	564591	31554
132338	297008	3454	50352	14860	555362	29788
126645	268909	2806	36142	13800	498662	22779
130625	278383	2777	34819	14431	511038	22576
133506	286226	2865	37353	14944	525919	23572
135277	288936	2924	37550	15083	531673	24132
137664	298953	3011	40462	15707	548854	25699
139821	305837	3099	41753	15954	560576	26960
138440	301979	2988	43437	15631	557274	28005
139879	306281	3032	44784	15813	565742	29114
142256	317057	3131	49537	16356	587625	31945
146322	334780	3343	54974	17086	619916	35559
146389	335895	3275	58535	17302	625809	36259
147841	333874	3243	54762	17247	619567	34018
146449	311028	2897	40738	16398	572942	26543
147960	311767	2818	38052	16590	572775	25672
148487	312575	2836	38436	16673	574205	25925
149802	315040	2721	36993	16962	579799	28472
151387	320325	2742	39056	17278	590072	29669
151936	321178	2707	39996	17224	593408	30786




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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=197193&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'Gertrude Mary Cox' @ cox.wessa.net







Goodness of Fit
Correlation0.9543
R-squared0.9107
RMSE11160.1606

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

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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=197193&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.9543
R-squared0.9107
RMSE11160.1606







Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
1575093566412.4285714298680.57142857148
2557560566412.428571429-8852.42857142852
3564478566412.428571429-1934.42857142852
4580523566412.42857142914110.5714285715
5596594602445.125-5851.125
6586570602445.125-15875.125
7536214526948.2352941189265.76470588241
8523597526948.235294118-3351.23529411759
9536535526948.2352941189586.76470588241
10536322526948.2352941189373.76470588241
11532638526948.2352941185689.76470588241
12528222526948.2352941181273.76470588241
13516141526948.235294118-10807.2352941176
145018664948796987
1550617449487911295
16517945526948.235294118-9003.23529411759
17533590526948.2352941186641.76470588241
18528379526948.2352941181430.76470588241
19477580494879-17299
20469357494879-25522
21490243494879-4636
22492622494879-2257
2350756149487912682
24516922526948.235294118-10026.2352941176
25514258526948.235294118-12690.2352941176
2650984649487914967
27527070526948.235294118121.764705882408
28541657526948.23529411814708.7647058824
29564591566412.428571429-1821.42857142852
30555362566412.428571429-11050.4285714285
314986624948793783
32511038526948.235294118-15910.2352941176
33525919526948.235294118-1029.23529411759
34531673526948.2352941184724.76470588241
35548854566412.428571429-17558.4285714285
36560576566412.428571429-5836.42857142852
37557274566412.428571429-9138.42857142852
38565742566412.428571429-670.428571428522
39587625602445.125-14820.125
40619916602445.12517470.875
41625809602445.12523363.875
42619567602445.12517121.875
43572942566412.4285714296529.57142857148
44572775566412.4285714296362.57142857148
45574205566412.4285714297792.57142857148
46579799566412.42857142913386.5714285715
47590072602445.125-12373.125
48593408602445.125-9037.125

\begin{tabular}{lllllllll}
\hline
Actuals, Predictions, and Residuals \tabularnewline
# & Actuals & Forecasts & Residuals \tabularnewline
1 & 575093 & 566412.428571429 & 8680.57142857148 \tabularnewline
2 & 557560 & 566412.428571429 & -8852.42857142852 \tabularnewline
3 & 564478 & 566412.428571429 & -1934.42857142852 \tabularnewline
4 & 580523 & 566412.428571429 & 14110.5714285715 \tabularnewline
5 & 596594 & 602445.125 & -5851.125 \tabularnewline
6 & 586570 & 602445.125 & -15875.125 \tabularnewline
7 & 536214 & 526948.235294118 & 9265.76470588241 \tabularnewline
8 & 523597 & 526948.235294118 & -3351.23529411759 \tabularnewline
9 & 536535 & 526948.235294118 & 9586.76470588241 \tabularnewline
10 & 536322 & 526948.235294118 & 9373.76470588241 \tabularnewline
11 & 532638 & 526948.235294118 & 5689.76470588241 \tabularnewline
12 & 528222 & 526948.235294118 & 1273.76470588241 \tabularnewline
13 & 516141 & 526948.235294118 & -10807.2352941176 \tabularnewline
14 & 501866 & 494879 & 6987 \tabularnewline
15 & 506174 & 494879 & 11295 \tabularnewline
16 & 517945 & 526948.235294118 & -9003.23529411759 \tabularnewline
17 & 533590 & 526948.235294118 & 6641.76470588241 \tabularnewline
18 & 528379 & 526948.235294118 & 1430.76470588241 \tabularnewline
19 & 477580 & 494879 & -17299 \tabularnewline
20 & 469357 & 494879 & -25522 \tabularnewline
21 & 490243 & 494879 & -4636 \tabularnewline
22 & 492622 & 494879 & -2257 \tabularnewline
23 & 507561 & 494879 & 12682 \tabularnewline
24 & 516922 & 526948.235294118 & -10026.2352941176 \tabularnewline
25 & 514258 & 526948.235294118 & -12690.2352941176 \tabularnewline
26 & 509846 & 494879 & 14967 \tabularnewline
27 & 527070 & 526948.235294118 & 121.764705882408 \tabularnewline
28 & 541657 & 526948.235294118 & 14708.7647058824 \tabularnewline
29 & 564591 & 566412.428571429 & -1821.42857142852 \tabularnewline
30 & 555362 & 566412.428571429 & -11050.4285714285 \tabularnewline
31 & 498662 & 494879 & 3783 \tabularnewline
32 & 511038 & 526948.235294118 & -15910.2352941176 \tabularnewline
33 & 525919 & 526948.235294118 & -1029.23529411759 \tabularnewline
34 & 531673 & 526948.235294118 & 4724.76470588241 \tabularnewline
35 & 548854 & 566412.428571429 & -17558.4285714285 \tabularnewline
36 & 560576 & 566412.428571429 & -5836.42857142852 \tabularnewline
37 & 557274 & 566412.428571429 & -9138.42857142852 \tabularnewline
38 & 565742 & 566412.428571429 & -670.428571428522 \tabularnewline
39 & 587625 & 602445.125 & -14820.125 \tabularnewline
40 & 619916 & 602445.125 & 17470.875 \tabularnewline
41 & 625809 & 602445.125 & 23363.875 \tabularnewline
42 & 619567 & 602445.125 & 17121.875 \tabularnewline
43 & 572942 & 566412.428571429 & 6529.57142857148 \tabularnewline
44 & 572775 & 566412.428571429 & 6362.57142857148 \tabularnewline
45 & 574205 & 566412.428571429 & 7792.57142857148 \tabularnewline
46 & 579799 & 566412.428571429 & 13386.5714285715 \tabularnewline
47 & 590072 & 602445.125 & -12373.125 \tabularnewline
48 & 593408 & 602445.125 & -9037.125 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=197193&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]575093[/C][C]566412.428571429[/C][C]8680.57142857148[/C][/ROW]
[ROW][C]2[/C][C]557560[/C][C]566412.428571429[/C][C]-8852.42857142852[/C][/ROW]
[ROW][C]3[/C][C]564478[/C][C]566412.428571429[/C][C]-1934.42857142852[/C][/ROW]
[ROW][C]4[/C][C]580523[/C][C]566412.428571429[/C][C]14110.5714285715[/C][/ROW]
[ROW][C]5[/C][C]596594[/C][C]602445.125[/C][C]-5851.125[/C][/ROW]
[ROW][C]6[/C][C]586570[/C][C]602445.125[/C][C]-15875.125[/C][/ROW]
[ROW][C]7[/C][C]536214[/C][C]526948.235294118[/C][C]9265.76470588241[/C][/ROW]
[ROW][C]8[/C][C]523597[/C][C]526948.235294118[/C][C]-3351.23529411759[/C][/ROW]
[ROW][C]9[/C][C]536535[/C][C]526948.235294118[/C][C]9586.76470588241[/C][/ROW]
[ROW][C]10[/C][C]536322[/C][C]526948.235294118[/C][C]9373.76470588241[/C][/ROW]
[ROW][C]11[/C][C]532638[/C][C]526948.235294118[/C][C]5689.76470588241[/C][/ROW]
[ROW][C]12[/C][C]528222[/C][C]526948.235294118[/C][C]1273.76470588241[/C][/ROW]
[ROW][C]13[/C][C]516141[/C][C]526948.235294118[/C][C]-10807.2352941176[/C][/ROW]
[ROW][C]14[/C][C]501866[/C][C]494879[/C][C]6987[/C][/ROW]
[ROW][C]15[/C][C]506174[/C][C]494879[/C][C]11295[/C][/ROW]
[ROW][C]16[/C][C]517945[/C][C]526948.235294118[/C][C]-9003.23529411759[/C][/ROW]
[ROW][C]17[/C][C]533590[/C][C]526948.235294118[/C][C]6641.76470588241[/C][/ROW]
[ROW][C]18[/C][C]528379[/C][C]526948.235294118[/C][C]1430.76470588241[/C][/ROW]
[ROW][C]19[/C][C]477580[/C][C]494879[/C][C]-17299[/C][/ROW]
[ROW][C]20[/C][C]469357[/C][C]494879[/C][C]-25522[/C][/ROW]
[ROW][C]21[/C][C]490243[/C][C]494879[/C][C]-4636[/C][/ROW]
[ROW][C]22[/C][C]492622[/C][C]494879[/C][C]-2257[/C][/ROW]
[ROW][C]23[/C][C]507561[/C][C]494879[/C][C]12682[/C][/ROW]
[ROW][C]24[/C][C]516922[/C][C]526948.235294118[/C][C]-10026.2352941176[/C][/ROW]
[ROW][C]25[/C][C]514258[/C][C]526948.235294118[/C][C]-12690.2352941176[/C][/ROW]
[ROW][C]26[/C][C]509846[/C][C]494879[/C][C]14967[/C][/ROW]
[ROW][C]27[/C][C]527070[/C][C]526948.235294118[/C][C]121.764705882408[/C][/ROW]
[ROW][C]28[/C][C]541657[/C][C]526948.235294118[/C][C]14708.7647058824[/C][/ROW]
[ROW][C]29[/C][C]564591[/C][C]566412.428571429[/C][C]-1821.42857142852[/C][/ROW]
[ROW][C]30[/C][C]555362[/C][C]566412.428571429[/C][C]-11050.4285714285[/C][/ROW]
[ROW][C]31[/C][C]498662[/C][C]494879[/C][C]3783[/C][/ROW]
[ROW][C]32[/C][C]511038[/C][C]526948.235294118[/C][C]-15910.2352941176[/C][/ROW]
[ROW][C]33[/C][C]525919[/C][C]526948.235294118[/C][C]-1029.23529411759[/C][/ROW]
[ROW][C]34[/C][C]531673[/C][C]526948.235294118[/C][C]4724.76470588241[/C][/ROW]
[ROW][C]35[/C][C]548854[/C][C]566412.428571429[/C][C]-17558.4285714285[/C][/ROW]
[ROW][C]36[/C][C]560576[/C][C]566412.428571429[/C][C]-5836.42857142852[/C][/ROW]
[ROW][C]37[/C][C]557274[/C][C]566412.428571429[/C][C]-9138.42857142852[/C][/ROW]
[ROW][C]38[/C][C]565742[/C][C]566412.428571429[/C][C]-670.428571428522[/C][/ROW]
[ROW][C]39[/C][C]587625[/C][C]602445.125[/C][C]-14820.125[/C][/ROW]
[ROW][C]40[/C][C]619916[/C][C]602445.125[/C][C]17470.875[/C][/ROW]
[ROW][C]41[/C][C]625809[/C][C]602445.125[/C][C]23363.875[/C][/ROW]
[ROW][C]42[/C][C]619567[/C][C]602445.125[/C][C]17121.875[/C][/ROW]
[ROW][C]43[/C][C]572942[/C][C]566412.428571429[/C][C]6529.57142857148[/C][/ROW]
[ROW][C]44[/C][C]572775[/C][C]566412.428571429[/C][C]6362.57142857148[/C][/ROW]
[ROW][C]45[/C][C]574205[/C][C]566412.428571429[/C][C]7792.57142857148[/C][/ROW]
[ROW][C]46[/C][C]579799[/C][C]566412.428571429[/C][C]13386.5714285715[/C][/ROW]
[ROW][C]47[/C][C]590072[/C][C]602445.125[/C][C]-12373.125[/C][/ROW]
[ROW][C]48[/C][C]593408[/C][C]602445.125[/C][C]-9037.125[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=197193&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=197193&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
1575093566412.4285714298680.57142857148
2557560566412.428571429-8852.42857142852
3564478566412.428571429-1934.42857142852
4580523566412.42857142914110.5714285715
5596594602445.125-5851.125
6586570602445.125-15875.125
7536214526948.2352941189265.76470588241
8523597526948.235294118-3351.23529411759
9536535526948.2352941189586.76470588241
10536322526948.2352941189373.76470588241
11532638526948.2352941185689.76470588241
12528222526948.2352941181273.76470588241
13516141526948.235294118-10807.2352941176
145018664948796987
1550617449487911295
16517945526948.235294118-9003.23529411759
17533590526948.2352941186641.76470588241
18528379526948.2352941181430.76470588241
19477580494879-17299
20469357494879-25522
21490243494879-4636
22492622494879-2257
2350756149487912682
24516922526948.235294118-10026.2352941176
25514258526948.235294118-12690.2352941176
2650984649487914967
27527070526948.235294118121.764705882408
28541657526948.23529411814708.7647058824
29564591566412.428571429-1821.42857142852
30555362566412.428571429-11050.4285714285
314986624948793783
32511038526948.235294118-15910.2352941176
33525919526948.235294118-1029.23529411759
34531673526948.2352941184724.76470588241
35548854566412.428571429-17558.4285714285
36560576566412.428571429-5836.42857142852
37557274566412.428571429-9138.42857142852
38565742566412.428571429-670.428571428522
39587625602445.125-14820.125
40619916602445.12517470.875
41625809602445.12523363.875
42619567602445.12517121.875
43572942566412.4285714296529.57142857148
44572775566412.4285714296362.57142857148
45574205566412.4285714297792.57142857148
46579799566412.42857142913386.5714285715
47590072602445.125-12373.125
48593408602445.125-9037.125



Parameters (Session):
par1 = 6 ; par2 = none ; par3 = 3 ; par4 = no ;
Parameters (R input):
par1 = 6 ; par2 = none ; par3 = 3 ; 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')
}