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 21:47:07 +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/t12932271258kxide3olwww2at.htm/, Retrieved Fri, 24 Dec 2010 22:45:28 +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/t12932271258kxide3olwww2at.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 «
1221.53 2617.2 10168.52 6957.61 23448.78 1180.55 2506.13 9937.04 6688.49 23007.99 1183.26 2679.07 9202.45 6601.37 23096.32 1141.2 2589.73 9369.35 6229.02 22358.17 1049.33 2457.46 8824.06 5925.22 20536.49 1101.6 2517.3 9537.3 6147.97 21029.81 1030.71 2386.53 9382.64 5965.52 20128.99 1089.41 2453.37 9768.7 5964.33 19765.19 1186.69 2529.66 11057.4 6135.7 21108.59 1169.43 2475.14 11089.94 6153.55 21239.35 1104.49 2525.93 10126.03 5598.46 20608.7 1073.87 2480.93 10198.04 5608.79 20121.99 1115.1 2229.85 10546.44 5957.43 21872.5 1095.63 2169.14 9345.55 5625.95 21821.5 1036.19 2030.98 10034.74 5414.96 21752.87 1057.08 2071.37 10133.23 5675.16 20955.25 1020.62 1953.35 10492.53 5458.04 19724.19 987.48 1748.74 10356.83 5332.14 20573.33 919.32 1696.58 9958.44 4808.64 18378.73 919.14 1900.09 9522.5 4940.82 18171 872.81 1908.64 8828.26 4769.45 15520.99 797.87 1881.46 8109.53 4084.76 13576.02 735.09 2100.18 7568.42 3843.74 12811.57 825.88 2672.2 7994.05 4338.35 13278.21 903.25 3136 8859.56 4810.2 143 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 time12 seconds
R Server'George Udny Yule' @ 72.249.76.132
R Framework
error message
Warning: there are blank lines in the 'Data X' field.
Please, use NA for missing data - blank lines are simply
 deleted and are NOT treated as missing values.


Goodness of Fit
CorrelationNA
R-squaredNA
RMSE1926.8208


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
11221.531577.76777777778-356.237777777777
21180.551577.76777777778-397.217777777777
31183.261577.76777777778-394.507777777777
41141.21577.76777777778-436.567777777777
51049.331577.76777777778-528.437777777777
61101.61577.76777777778-476.167777777777
71030.711577.76777777778-547.057777777777
81089.411577.76777777778-488.357777777777
91186.691577.76777777778-391.077777777777
101169.431577.76777777778-408.337777777777
111104.491577.76777777778-473.277777777777
121073.871577.76777777778-503.897777777777
131115.11577.76777777778-462.667777777777
141095.631577.76777777778-482.137777777777
151036.191577.76777777778-541.577777777777
161057.081577.76777777778-520.687777777777
171020.621577.76777777778-557.147777777777
18987.481577.76777777778-590.287777777777
19919.321577.76777777778-658.447777777777
20919.141577.76777777778-658.627777777777
21872.811577.76777777778-704.957777777777
22797.871577.76777777778-779.897777777777
23735.091577.76777777778-842.677777777777
24825.881577.76777777778-751.887777777777
25903.251577.76777777778-674.517777777777
26896.241577.76777777778-681.527777777777
27968.751577.76777777778-609.017777777777
281166.361577.76777777778-411.407777777777
291282.831577.76777777778-294.937777777777
301267.381577.76777777778-310.387777777777
3112801577.76777777778-297.767777777777
321400.381577.76777777778-177.387777777777
331385.591577.76777777778-192.177777777777
341322.71577.76777777778-255.067777777777
351330.631577.76777777778-247.137777777777
361378.551577.76777777778-199.217777777777
371468.361577.76777777778-109.407777777777
381481.141577.76777777778-96.6277777777773
391549.381577.76777777778-28.3877777777773
401526.751577.76777777778-51.0177777777774
411473.991577.76777777778-103.777777777777
421455.271577.76777777778-122.497777777777
431503.351577.76777777778-74.4177777777775
441530.621577.76777777778-47.1477777777775
451482.371577.76777777778-95.3977777777775
461420.861577.76777777778-156.907777777777
471406.821577.76777777778-170.947777777777
481438.241577.76777777778-139.527777777777
491418.31577.76777777778-159.467777777777
501400.631577.76777777778-177.137777777777
511377.941577.76777777778-199.827777777777
521335.851577.76777777778-241.917777777777
531303.821577.76777777778-273.947777777777
541276.661577.76777777778-301.107777777777
551270.21577.76777777778-307.567777777777
561270.091577.76777777778-307.677777777777
571310.611577.76777777778-267.157777777777
581294.871577.76777777778-282.897777777777
591280.661577.76777777778-297.107777777777
601280.081577.76777777778-297.687777777777
611248.291577.76777777778-329.477777777777
621249.481577.76777777778-328.287777777777
631207.011577.76777777778-370.757777777777
641228.811577.76777777778-348.957777777777
651220.331577.76777777778-357.437777777777
661234.181577.76777777778-343.587777777777
671191.331577.76777777778-386.437777777777
681191.51577.76777777778-386.267777777777
6911008.91577.767777777789431.13222222222
704348.771577.767777777782771.00222222222
7114195.351577.7677777777812617.5822222222
721221.531577.76777777778-356.237777777777
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/24/t12932271258kxide3olwww2at/2u2t51293227214.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/24/t12932271258kxide3olwww2at/2u2t51293227214.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/24/t12932271258kxide3olwww2at/3u2t51293227214.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/24/t12932271258kxide3olwww2at/3u2t51293227214.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/24/t12932271258kxide3olwww2at/44tsq1293227214.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/24/t12932271258kxide3olwww2at/44tsq1293227214.ps (open in new window)


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