Home » date » 2010 » Dec » 21 »

*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: Tue, 21 Dec 2010 12:56:27 +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/21/t129293609950oiry7uzggwbbu.htm/, Retrieved Tue, 21 Dec 2010 13:54:59 +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/21/t129293609950oiry7uzggwbbu.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 «
14 11 23 8 1 6 7 22 24 4 2 5 22 23 24 7 2 20 12 21 21 4 2 12 15 19 21 4 2 11 9 12 19 5 2 12 20 24 12 15 1 11 10 21 21 5 1 9 12 21 25 7 2 13 23 26 27 4 2 9 10 18 21 4 1 14 11 21 27 7 1 12 20 22 20 8 1 18 11 26 16 4 2 9 22 20 26 8 1 15 19 20 24 4 2 12 20 26 25 5 2 12 16 27 25 16 1 12 12 27 27 7 1 15 14 16 23 4 2 11 14 26 22 6 1 13 9 20 10 4 1 10 19 25 25 5 2 17 17 16 18 4 1 13 14 20 21 4 1 17 19 20 20 6 1 15 20 24 18 4 1 13 20 24 25 4 1 17 9 22 28 4 1 21 10 18 27 8 1 12 6 21 20 5 2 12 15 17 20 4 1 15 9 15 20 10 2 8 24 28 27 4 2 15 11 23 23 4 1 16 4 19 23 4 2 9 12 15 22 5 2 13 22 26 26 5 1 11 16 20 21 4 1 9 14 11 17 6 1 15 13 17 27 4 2 9 13 16 16 4 2 15 10 21 26 4 1 14 12 18 17 4 1 8 13 17 24 4 2 11 16 21 23 4 2 14 18 18 20 6 1 14 10 16 10 4 1 12 12 13 21 5 1 15 9 28 25 4 1 11 7 25 28 4 1 11 16 24 25 5 2 9 12 15 20 10 2 8 15 21 20 10 1 13 15 11 27 4 1 12 8 27 26 4 1 24 14 23 19 4 2 11 13 21 26 8 1 11 18 16 20 4 2 16 11 20 22 14 1 12 12 21 19 4 2 18 12 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 time23 seconds
R Server'Sir Ronald Aylmer Fisher' @ 193.190.124.24


Goodness of Fit
Correlation0.2927
R-squared0.0857
RMSE4.1015


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
11119.8934426229508-8.89344262295082
22219.89344262295082.10655737704918
32323.1923076923077-0.192307692307693
42119.89344262295081.10655737704918
51919.8934426229508-0.893442622950818
61219.8934426229508-7.89344262295082
72423.19230769230770.807692307692307
82119.89344262295081.10655737704918
92119.89344262295081.10655737704918
102623.19230769230772.80769230769231
111819.8934426229508-1.89344262295082
122119.89344262295081.10655737704918
132223.1923076923077-1.19230769230769
142619.89344262295086.10655737704918
152023.1923076923077-3.19230769230769
162023.1923076923077-3.19230769230769
172623.19230769230772.80769230769231
182719.89344262295087.10655737704918
192719.89344262295087.10655737704918
201619.8934426229508-3.89344262295082
212619.89344262295086.10655737704918
222019.89344262295080.106557377049182
232523.19230769230771.80769230769231
241619.8934426229508-3.89344262295082
252019.89344262295080.106557377049182
262023.1923076923077-3.19230769230769
272423.19230769230770.807692307692307
282423.19230769230770.807692307692307
292219.89344262295082.10655737704918
301819.8934426229508-1.89344262295082
312119.89344262295081.10655737704918
321719.8934426229508-2.89344262295082
331519.8934426229508-4.89344262295082
342823.19230769230774.80769230769231
352319.89344262295083.10655737704918
361919.8934426229508-0.893442622950818
371519.8934426229508-4.89344262295082
382623.19230769230772.80769230769231
392019.89344262295080.106557377049182
401119.8934426229508-8.89344262295082
411719.8934426229508-2.89344262295082
421619.8934426229508-3.89344262295082
432119.89344262295081.10655737704918
441819.8934426229508-1.89344262295082
451719.8934426229508-2.89344262295082
462119.89344262295081.10655737704918
471819.8934426229508-1.89344262295082
481619.8934426229508-3.89344262295082
491319.8934426229508-6.89344262295082
502819.89344262295088.10655737704918
512519.89344262295085.10655737704918
522419.89344262295084.10655737704918
531519.8934426229508-4.89344262295082
542119.89344262295081.10655737704918
551119.8934426229508-8.89344262295082
562719.89344262295087.10655737704918
572319.89344262295083.10655737704918
582119.89344262295081.10655737704918
591619.8934426229508-3.89344262295082
602019.89344262295080.106557377049182
612119.89344262295081.10655737704918
621019.8934426229508-9.89344262295082
631823.1923076923077-5.19230769230769
642019.89344262295080.106557377049182
652119.89344262295081.10655737704918
662419.89344262295084.10655737704918
672619.89344262295086.10655737704918
682323.1923076923077-0.192307692307693
692219.89344262295082.10655737704918
701319.8934426229508-6.89344262295082
712723.19230769230773.80769230769231
722419.89344262295084.10655737704918
731923.1923076923077-4.19230769230769
741719.8934426229508-2.89344262295082
751619.8934426229508-3.89344262295082
762023.1923076923077-3.19230769230769
77819.8934426229508-11.8934426229508
781619.8934426229508-3.89344262295082
791719.8934426229508-2.89344262295082
802323.1923076923077-0.192307692307693
811819.8934426229508-1.89344262295082
822423.19230769230770.807692307692307
831719.8934426229508-2.89344262295082
842019.89344262295080.106557377049182
852219.89344262295082.10655737704918
862219.89344262295082.10655737704918
872019.89344262295080.106557377049182
881819.8934426229508-1.89344262295082
892119.89344262295081.10655737704918
902319.89344262295083.10655737704918
912823.19230769230774.80769230769231
921919.8934426229508-0.893442622950818
932219.89344262295082.10655737704918
941719.8934426229508-2.89344262295082
952519.89344262295085.10655737704918
962219.89344262295082.10655737704918
972119.89344262295081.10655737704918
981519.8934426229508-4.89344262295082
992019.89344262295080.106557377049182
1002519.89344262295085.10655737704918
1012119.89344262295081.10655737704918
1022419.89344262295084.10655737704918
1032319.89344262295083.10655737704918
1042219.89344262295082.10655737704918
1051419.8934426229508-5.89344262295082
1061119.8934426229508-8.89344262295082
1072219.89344262295082.10655737704918
1082219.89344262295082.10655737704918
109619.8934426229508-13.8934426229508
1101519.8934426229508-4.89344262295082
1112619.89344262295086.10655737704918
1122623.19230769230772.80769230769231
1132019.89344262295080.106557377049182
1142619.89344262295086.10655737704918
1151519.8934426229508-4.89344262295082
1162519.89344262295085.10655737704918
1172219.89344262295082.10655737704918
1182019.89344262295080.106557377049182
1191819.8934426229508-1.89344262295082
1202319.89344262295083.10655737704918
1212219.89344262295082.10655737704918
1222319.89344262295083.10655737704918
1231723.1923076923077-6.19230769230769
1242019.89344262295080.106557377049182
1252119.89344262295081.10655737704918
1262319.89344262295083.10655737704918
1272519.89344262295085.10655737704918
1282519.89344262295085.10655737704918
1292119.89344262295081.10655737704918
1302219.89344262295082.10655737704918
1311819.8934426229508-1.89344262295082
1321819.8934426229508-1.89344262295082
1331823.1923076923077-5.19230769230769
1342119.89344262295081.10655737704918
1352119.89344262295081.10655737704918
1362519.89344262295085.10655737704918
1372419.89344262295084.10655737704918
1382419.89344262295084.10655737704918
1392823.19230769230774.80769230769231
1402423.19230769230770.807692307692307
1412219.89344262295082.10655737704918
1422219.89344262295082.10655737704918
1432019.89344262295080.106557377049182
1442519.89344262295085.10655737704918
1451319.8934426229508-6.89344262295082
1462119.89344262295081.10655737704918
1472319.89344262295083.10655737704918
1481819.8934426229508-1.89344262295082
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/21/t129293609950oiry7uzggwbbu/2evgg1292936162.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/21/t129293609950oiry7uzggwbbu/2evgg1292936162.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/21/t129293609950oiry7uzggwbbu/3evgg1292936162.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/21/t129293609950oiry7uzggwbbu/3evgg1292936162.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/21/t129293609950oiry7uzggwbbu/4zwx41292936162.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/21/t129293609950oiry7uzggwbbu/4zwx41292936162.ps (open in new window)


 
Parameters (Session):
par1 = 2 ; par2 = none ; par4 = no ;
 
Parameters (R input):
par1 = 2 ; par2 = none ; 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