Home » date » 2010 » Dec » 29 »

*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: Wed, 29 Dec 2010 17:48:19 +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/29/t12936447693d0wpa3d6k3toek.htm/, Retrieved Wed, 29 Dec 2010 18:46:10 +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/29/t12936447693d0wpa3d6k3toek.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 «
40 1 27 5 26 49 35 45 1 36 4 25 45 34 38 1 25 4 17 54 13 28 1 27 3 37 36 35 NA 2 25 3 35 36 28 38 2 44 3 15 53 32 39 1 50 4 27 46 35 37 1 41 4 36 42 36 30 1 48 5 25 41 27 30 2 43 4 30 45 29 30 2 47 2 27 47 27 26 2 41 3 33 42 28 29 1 44 2 29 45 29 31 2 47 5 30 40 28 27 2 40 3 25 45 30 25 2 46 3 23 40 25 39 1 28 3 26 42 15 35 1 56 3 24 45 33 27 2 49 4 35 47 31 40 2 25 4 39 31 37 34 2 41 4 23 46 37 32 2 26 3 32 34 34 34 1 50 5 29 43 32 38 1 47 4 26 45 21 21 1 52 2 21 42 25 33 2 37 5 35 51 32 27 2 41 3 23 44 28 35 1 45 4 21 47 22 33 2 26 4 28 47 25 36 1 NA 3 30 41 26 NA 1 52 4 21 44 34 37 1 46 2 29 51 34 37 1 58 3 28 46 36 37 1 54 5 19 47 36 32 1 29 3 26 46 26 25 2 50 3 33 38 26 31 1 43 2 34 50 34 33 2 30 3 33 48 33 18 2 47 2 40 36 31 42 1 45 3 24 51 33 26 2 48 1 35 35 22 26 2 48 3 35 49 29 32 2 26 4 32 38 24 31 1 46 5 20 47 37 29 2 NA 3 35 36 32 35 2 50 3 35 47 23 44 1 25 4 21 46 29 35 1 47 2 33 43 35 30 2 47 2 40 53 20 32 1 41 3 22 55 28 24 2 45 2 35 39 26 34 2 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 time5 seconds
R Server'RServer@AstonUniversity' @ vre.aston.ac.uk


Goodness of Fit
Correlation0.4206
R-squared0.1769
RMSE6.2634


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
14033.66666666666676.33333333333334
24533.666666666666711.3333333333333
33835.66666666666672.33333333333334
42833.6666666666667-5.66666666666666
53835.66666666666672.33333333333334
63933.66666666666675.33333333333334
73733.66666666666673.33333333333334
83033.6666666666667-3.66666666666666
93029.8734177215190.126582278481013
103029.8734177215190.126582278481013
112629.873417721519-3.87341772151899
122933.6666666666667-4.66666666666666
133129.8734177215191.12658227848101
142729.873417721519-2.87341772151899
152526.8611111111111-1.86111111111111
163926.861111111111112.1388888888889
173533.66666666666671.33333333333334
182729.873417721519-2.87341772151899
194029.87341772151910.126582278481
203429.8734177215194.12658227848101
213229.8734177215192.12658227848101
223433.66666666666670.333333333333336
233826.861111111111111.1388888888889
242126.8611111111111-5.86111111111111
253335.6666666666667-2.66666666666666
262729.873417721519-2.87341772151899
273526.86111111111118.13888888888889
283326.86111111111116.13888888888889
293633.66666666666672.33333333333334
303735.66666666666671.33333333333334
313733.66666666666673.33333333333334
323733.66666666666673.33333333333334
333233.6666666666667-1.66666666666666
342529.873417721519-4.87341772151899
353133.6666666666667-2.66666666666666
363329.8734177215193.12658227848101
371829.873417721519-11.873417721519
384235.66666666666676.33333333333334
392626.8611111111111-0.86111111111111
402629.873417721519-3.87341772151899
413226.86111111111115.13888888888889
423133.6666666666667-2.66666666666666
432929.873417721519-0.873417721518987
443526.86111111111118.13888888888889
454433.666666666666710.3333333333333
463533.66666666666671.33333333333334
473035.6666666666667-5.66666666666666
483235.6666666666667-3.66666666666666
492429.873417721519-5.87341772151899
503435.6666666666667-1.66666666666666
512729.873417721519-2.87341772151899
523129.8734177215191.12658227848101
533835.66666666666672.33333333333334
544129.87341772151911.126582278481
554035.66666666666674.33333333333334
562529.873417721519-4.87341772151899
571926.8611111111111-7.86111111111111
583335.6666666666667-2.66666666666666
592729.873417721519-2.87341772151899
604533.666666666666711.3333333333333
612729.873417721519-2.87341772151899
623029.8734177215190.126582278481013
634235.66666666666676.33333333333334
642129.873417721519-8.87341772151899
653229.8734177215192.12658227848101
663129.8734177215191.12658227848101
673629.8734177215196.12658227848101
683433.66666666666670.333333333333336
691126.8611111111111-15.8611111111111
703526.86111111111118.13888888888889
713933.66666666666675.33333333333334
723233.6666666666667-1.66666666666666
732829.873417721519-1.87341772151899
744535.66666666666679.33333333333334
751826.8611111111111-8.86111111111111
763535.6666666666667-0.666666666666664
773535.6666666666667-0.666666666666664
783629.8734177215196.12658227848101
793433.66666666666670.333333333333336
803433.66666666666670.333333333333336
813829.8734177215198.12658227848101
822829.873417721519-1.87341772151899
832329.873417721519-6.87341772151899
843735.66666666666671.33333333333334
852929.873417721519-0.873417721518987
862833.6666666666667-5.66666666666666
873033.6666666666667-3.66666666666666
882429.873417721519-5.87341772151899
893633.66666666666672.33333333333334
904033.66666666666676.33333333333334
913729.8734177215197.12658227848101
922729.873417721519-2.87341772151899
932529.873417721519-4.87341772151899
942226.8611111111111-4.86111111111111
952129.873417721519-8.87341772151899
962833.6666666666667-5.66666666666666
973435.6666666666667-1.66666666666666
983229.8734177215192.12658227848101
992326.8611111111111-3.86111111111111
1002933.6666666666667-4.66666666666666
1013526.86111111111118.13888888888889
1023129.8734177215191.12658227848101
1033626.86111111111119.13888888888889
1043226.86111111111115.13888888888889
1053526.86111111111118.13888888888889
1064533.666666666666711.3333333333333
1072929.873417721519-0.873417721518987
1084135.66666666666675.33333333333334
1093629.8734177215196.12658227848101
1103733.66666666666673.33333333333334
1112526.8611111111111-1.86111111111111
1123629.8734177215196.12658227848101
1133429.8734177215194.12658227848101
1143333.6666666666667-0.666666666666664
1153229.8734177215192.12658227848101
1164033.66666666666676.33333333333334
1172726.86111111111110.138888888888889
1182429.873417721519-5.87341772151899
1192629.873417721519-3.87341772151899
1201326.8611111111111-13.8611111111111
1212229.873417721519-7.87341772151899
1222929.873417721519-0.873417721518987
1233029.8734177215190.126582278481013
1242435.6666666666667-11.6666666666667
1252629.873417721519-3.87341772151899
1263729.8734177215197.12658227848101
1273629.8734177215196.12658227848101
1283833.66666666666674.33333333333334
1293429.8734177215194.12658227848101
1303529.8734177215195.12658227848101
1313233.6666666666667-1.66666666666666
1324435.66666666666678.33333333333334
1334029.87341772151910.126582278481
1342433.6666666666667-9.66666666666666
1353629.8734177215196.12658227848101
1362026.8611111111111-6.86111111111111
1372829.873417721519-1.87341772151899
1381829.873417721519-11.873417721519
1392329.873417721519-6.87341772151899
1402833.6666666666667-5.66666666666666
1413026.86111111111113.13888888888889
1423033.6666666666667-3.66666666666666
1434333.66666666666679.33333333333334
1442026.8611111111111-6.86111111111111
1453729.8734177215197.12658227848101
1462426.8611111111111-2.86111111111111
1473329.8734177215193.12658227848101
1484329.87341772151913.126582278481
1492733.6666666666667-6.66666666666666
1502229.873417721519-7.87341772151899
1512829.873417721519-1.87341772151899
1521826.8611111111111-8.86111111111111
1533833.66666666666674.33333333333334
1542329.873417721519-6.87341772151899
1553829.8734177215198.12658227848101
1562126.8611111111111-5.86111111111111
1572529.873417721519-4.87341772151899
1583033.6666666666667-3.66666666666666
1592526.8611111111111-1.86111111111111
1601733.6666666666667-16.6666666666667
1612626.8611111111111-0.86111111111111
1623935.66666666666673.33333333333334
1632733.6666666666667-6.66666666666666
1643333.6666666666667-0.666666666666664
1654726.861111111111120.1388888888889
1663735.66666666666671.33333333333334
1673433.66666666666670.333333333333336
1682426.8611111111111-2.86111111111111
1692529.873417721519-4.87341772151899
1702026.8611111111111-6.86111111111111
1713429.8734177215194.12658227848101
1722229.873417721519-7.87341772151899
1733933.66666666666675.33333333333334
1743333.6666666666667-0.666666666666664
1753526.86111111111118.13888888888889
1762633.6666666666667-7.66666666666666
1773233.6666666666667-1.66666666666666
1782233.6666666666667-11.6666666666667
1793929.8734177215199.12658227848101
1803529.8734177215195.12658227848101
1812135.6666666666667-14.6666666666667
1822735.6666666666667-8.66666666666666
1833129.8734177215191.12658227848101
1842029.873417721519-9.87341772151899
1852829.873417721519-1.87341772151899
1862626.8611111111111-0.86111111111111
1873629.8734177215196.12658227848101
1881626.8611111111111-10.8611111111111
1893429.8734177215194.12658227848101
1903029.8734177215190.126582278481013
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/29/t12936447693d0wpa3d6k3toek/2vxbx1293644891.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/29/t12936447693d0wpa3d6k3toek/2vxbx1293644891.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/29/t12936447693d0wpa3d6k3toek/3vxbx1293644891.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/29/t12936447693d0wpa3d6k3toek/3vxbx1293644891.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/29/t12936447693d0wpa3d6k3toek/4o6bh1293644891.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/29/t12936447693d0wpa3d6k3toek/4o6bh1293644891.ps (open in new window)


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





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