Home » date » 2010 » Dec » 24 »

*The author of this computation has been verified*
R Software Module: /rwasp_regression_trees1.wasp (opens new window with default values)
Title produced by software: Recursive Partitioning (Regression Trees)
Date of computation: Fri, 24 Dec 2010 11:01:47 +0000
 
Cite this page as follows:
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL http://www.freestatistics.org/blog/date/2010/Dec/24/t12931887429jddmf5rns0h355.htm/, Retrieved Fri, 24 Dec 2010 12:05:43 +0100
 
BibTeX entries for LaTeX users:
@Manual{KEY,
    author = {{YOUR NAME}},
    publisher = {Office for Research Development and Education},
    title = {Statistical Computations at FreeStatistics.org, URL http://www.freestatistics.org/blog/date/2010/Dec/24/t12931887429jddmf5rns0h355.htm/},
    year = {2010},
}
@Manual{R,
    title = {R: A Language and Environment for Statistical Computing},
    author = {{R Development Core Team}},
    organization = {R Foundation for Statistical Computing},
    address = {Vienna, Austria},
    year = {2010},
    note = {{ISBN} 3-900051-07-0},
    url = {http://www.R-project.org},
}
 
Original text written by user:
 
IsPrivate?
No (this computation is public)
 
User-defined keywords:
 
Dataseries X:
» Textbox « » Textfile « » CSV «
9,1 4,5 1,0 -1,0 1989,3 9,0 4,3 1,0 3,0 2097,8 9,0 4,3 1,3 2,0 2154,9 8,9 4,2 1,1 3,0 2152,2 8,8 4,0 0,8 5,0 2250,3 8,7 3,8 0,7 5,0 2346,9 8,5 4,1 0,7 3,0 2525,6 8,3 4,2 0,9 2,0 2409,4 8,1 4,0 1,3 1,0 2394,4 7,9 4,3 1,4 -4,0 2401,3 7,8 4,7 1,6 1,0 2354,3 7,6 5,0 2,1 1,0 2450,4 7,4 5,1 0,3 6,0 2504,7 7,2 5,4 2,1 3,0 2661,4 7,0 5,4 2,5 2,0 2880,4 7,0 5,4 2,3 2,0 3064,4 6,8 5,5 2,4 2,0 3141,1 6,8 5,8 3,0 -8,0 3327,7 6,7 5,7 1,7 0,0 3565,0 6,8 5,5 3,5 -2,0 3403,1 6,7 5,6 4,0 3,0 3149,9 6,7 5,6 3,7 5,0 3006,8 6,7 5,5 3,7 8,0 3230,7 6,5 5,5 3,0 8,0 3361,1 6,3 5,7 2,7 9,0 3484,7 6,3 5,6 2,5 11,0 3411,1 6,3 5,6 2,2 13,0 3288,2 6,5 5,4 2,9 12,0 3280,4 6,6 5,2 3,1 13,0 3174,0 6,5 5,1 3,0 15,0 3165,3 6,3 5,1 2,8 13,0 3092,7 6,3 5,0 2,5 16,0 3053,1 6,5 5,3 1,9 10,0 3182,0 7,0 5,4 1,9 14,0 2999,9 7,1 5,3 1,8 14,0 3249,6 7,3 5,1 2,0 15,0 3210,5 7,3 5,0 2,6 13,0 3030,3 7,4 5,0 2,5 8,0 2803,5 7,4 4,6 2,5 7,0 2767,6 7,3 4,8 1,6 3,0 2882,6 7,4 5,1 1,4 3,0 2863,4 7,5 5,1 0,8 4,0 2897,1 etc...
 
Output produced by software:

Enter (or paste) a matrix (table) containing all data (time) series. Every column represents a different variable and must be delimited by a space or Tab. Every row represents a period in time (or category) and must be delimited by hard returns. The easiest way to enter data is to copy and paste a block of spreadsheet cells. Please, do not use commas or spaces to seperate groups of digits!


Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time4 seconds
R Server'RServer@AstonUniversity' @ vre.aston.ac.uk


Goodness of Fit
Correlation0.9236
R-squared0.8531
RMSE0.2726


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
19.17.731578947368421.36842105263158
298.785714285714290.214285714285714
398.785714285714290.214285714285714
48.98.785714285714290.114285714285714
58.88.785714285714290.0142857142857142
68.78.78571428571429-0.0857142857142872
78.58.270.23
88.38.270.0300000000000011
98.18.27-0.17
107.98.27-0.369999999999999
117.87.731578947368420.0684210526315789
127.67.18750.4125
137.47.73157894736842-0.331578947368421
147.26.709523809523810.490476190476191
1576.709523809523810.29047619047619
1676.709523809523810.29047619047619
176.86.709523809523810.0904761904761902
186.86.709523809523810.0904761904761902
196.77.73157894736842-1.03157894736842
206.86.709523809523810.0904761904761902
216.76.70952380952381-0.0095238095238095
226.76.70952380952381-0.0095238095238095
236.76.70952380952381-0.0095238095238095
246.56.70952380952381-0.20952380952381
256.36.70952380952381-0.40952380952381
266.36.70952380952381-0.40952380952381
276.36.70952380952381-0.40952380952381
286.56.70952380952381-0.20952380952381
296.66.70952380952381-0.10952380952381
306.56.70952380952381-0.20952380952381
316.36.70952380952381-0.40952380952381
326.37.1875-0.8875
336.56.70952380952381-0.20952380952381
3476.709523809523810.29047619047619
357.16.709523809523810.39047619047619
367.36.709523809523810.59047619047619
377.37.18750.1125
387.47.18750.2125
397.47.18750.2125
407.37.73157894736842-0.431578947368421
417.47.73157894736842-0.331578947368421
427.57.73157894736842-0.231578947368421
437.77.73157894736842-0.0315789473684207
447.77.73157894736842-0.0315789473684207
457.77.73157894736842-0.0315789473684207
467.77.73157894736842-0.0315789473684207
477.77.73157894736842-0.0315789473684207
487.87.731578947368420.0684210526315789
4987.731578947368420.268421052631579
508.18.064285714285710.0357142857142847
518.17.731578947368420.368421052631579
528.27.731578947368420.468421052631578
538.28.27-0.0700000000000003
548.28.27-0.0700000000000003
558.18.27-0.17
568.18.064285714285710.0357142857142847
578.28.064285714285710.135714285714284
588.38.47272727272727-0.172727272727272
598.38.064285714285710.235714285714286
608.48.064285714285710.335714285714285
618.58.270.23
628.58.270.23
638.48.270.130000000000001
6488.06428571428571-0.064285714285715
657.98.06428571428571-0.164285714285715
668.18.064285714285710.0357142857142847
678.58.50588235294118-0.00588235294117645
688.88.505882352941180.294117647058824
698.88.785714285714290.0142857142857142
708.68.505882352941180.0941176470588232
718.38.50588235294118-0.205882352941176
728.38.78571428571429-0.485714285714286
738.38.50588235294118-0.205882352941176
748.48.50588235294118-0.105882352941176
758.48.50588235294118-0.105882352941176
768.58.50588235294118-0.00588235294117645
778.68.505882352941180.0941176470588232
788.68.505882352941180.0941176470588232
798.68.505882352941180.0941176470588232
808.68.505882352941180.0941176470588232
818.68.505882352941180.0941176470588232
828.58.50588235294118-0.00588235294117645
838.48.50588235294118-0.105882352941176
848.48.50588235294118-0.105882352941176
858.48.47272727272727-0.0727272727272723
868.58.472727272727270.0272727272727273
878.58.472727272727270.0272727272727273
888.68.472727272727270.127272727272727
898.68.472727272727270.127272727272727
908.48.47272727272727-0.0727272727272723
918.28.47272727272727-0.272727272727273
9288.06428571428571-0.064285714285715
9388.06428571428571-0.064285714285715
9488.06428571428571-0.064285714285715
9588.06428571428571-0.064285714285715
967.98.06428571428571-0.164285714285715
977.98.06428571428571-0.164285714285715
987.87.136363636363640.663636363636363
997.88.15-0.350000000000001
10088.15-0.15
1017.88.15-0.350000000000001
1027.47.136363636363640.263636363636364
1037.27.136363636363640.0636363636363635
10477.13636363636364-0.136363636363637
10577.13636363636364-0.136363636363637
1067.27.18750.0125000000000002
1077.27.18750.0125000000000002
1087.27.18750.0125000000000002
10977.1875-0.1875
1106.97.1875-0.2875
1116.87.13636363636364-0.336363636363637
1126.87.13636363636364-0.336363636363637
1136.87.1875-0.3875
1146.97.13636363636364-0.236363636363636
1157.27.136363636363640.0636363636363635
1167.27.136363636363640.0636363636363635
1177.27.136363636363640.0636363636363635
1187.17.1875-0.0875000000000004
1197.27.18750.0125000000000002
1207.37.18750.1125
1217.57.18750.3125
1227.67.18750.4125
1237.77.73157894736842-0.0315789473684207
1247.77.73157894736842-0.0315789473684207
1257.77.73157894736842-0.0315789473684207
1267.88.15-0.350000000000001
12788.15-0.15
1288.18.15-0.0500000000000007
1298.18.15-0.0500000000000007
13088.15-0.15
1318.18.15-0.0500000000000007
1328.28.150.0499999999999989
1338.38.150.15
1348.48.150.25
1358.48.150.25
1368.48.150.25
1378.58.150.35
1388.58.150.35
1398.68.472727272727270.127272727272727
1408.68.472727272727270.127272727272727
1418.58.472727272727270.0272727272727273
1428.58.50588235294118-0.00588235294117645
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/24/t12931887429jddmf5rns0h355/244bv1293188500.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/24/t12931887429jddmf5rns0h355/244bv1293188500.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/24/t12931887429jddmf5rns0h355/344bv1293188500.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/24/t12931887429jddmf5rns0h355/344bv1293188500.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/24/t12931887429jddmf5rns0h355/4fwtg1293188500.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/24/t12931887429jddmf5rns0h355/4fwtg1293188500.ps (open in new window)


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





Copyright

Creative Commons License

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.

Software written by Ed van Stee & Patrick Wessa


Disclaimer

Information provided on this web site is provided "AS IS" without warranty of any kind, either express or implied, including, without limitation, warranties of merchantability, fitness for a particular purpose, and noninfringement. We use reasonable efforts to include accurate and timely information and periodically update the information, and software without notice. However, we make no warranties or representations as to the accuracy or completeness of such information (or software), and we assume no liability or responsibility for errors or omissions in the content of this web site, or any software bugs in online applications. Your use of this web site is AT YOUR OWN RISK. Under no circumstances and under no legal theory shall we be liable to you or any other person for any direct, indirect, special, incidental, exemplary, or consequential damages arising from your access to, or use of, this web site.


Privacy Policy

We may request personal information to be submitted to our servers in order to be able to:

  • personalize online software applications according to your needs
  • enforce strict security rules with respect to the data that you upload (e.g. statistical data)
  • manage user sessions of online applications
  • alert you about important changes or upgrades in resources or applications

We NEVER allow other companies to directly offer registered users information about their products and services. Banner references and hyperlinks of third parties NEVER contain any personal data of the visitor.

We do NOT sell, nor transmit by any means, personal information, nor statistical data series uploaded by you to third parties.

We carefully protect your data from loss, misuse, alteration, and destruction. However, at any time, and under any circumstance you are solely responsible for managing your passwords, and keeping them secret.

We store a unique ANONYMOUS USER ID in the form of a small 'Cookie' on your computer. This allows us to track your progress when using this website which is necessary to create state-dependent features. The cookie is used for NO OTHER PURPOSE. At any time you may opt to disallow cookies from this website - this will not affect other features of this website.

We examine cookies that are used by third-parties (banner and online ads) very closely: abuse from third-parties automatically results in termination of the advertising contract without refund. We have very good reason to believe that the cookies that are produced by third parties (banner ads) do NOT cause any privacy or security risk.

FreeStatistics.org is safe. There is no need to download any software to use the applications and services contained in this website. Hence, your system's security is not compromised by their use, and your personal data - other than data you submit in the account application form, and the user-agent information that is transmitted by your browser - is never transmitted to our servers.

As a general rule, we do not log on-line behavior of individuals (other than normal logging of webserver 'hits'). However, in cases of abuse, hacking, unauthorized access, Denial of Service attacks, illegal copying, hotlinking, non-compliance with international webstandards (such as robots.txt), or any other harmful behavior, our system engineers are empowered to log, track, identify, publish, and ban misbehaving individuals - even if this leads to ban entire blocks of IP addresses, or disclosing user's identity.


FreeStatistics.org is powered by