Home » date » 2010 » Dec » 22 »

BEL20-RP1(no cat)

*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, 22 Dec 2010 17:58:31 +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/22/t12930430811usqngnfibvyhfh.htm/, Retrieved Wed, 22 Dec 2010 19:38:06 +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/22/t12930430811usqngnfibvyhfh.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 «
3.04 493 9 3.030 9.026 25.64 104.8 3.28 481 11 2.803 9.787 27.97 105.2 3.51 462 13 2.768 9.536 27.62 105.6 3.69 457 12 2.883 9.490 23.31 105.8 3.92 442 13 2.863 9.736 29.07 106.1 4.29 439 15 2.897 9.694 29.58 106.5 4.31 488 13 3.013 9.647 28.63 106.71 4.42 521 16 3.143 9.753 29.92 106.68 4.59 501 10 3.033 10.070 32.68 107.41 4.76 485 14 3.046 10.137 31.54 107.15 4.83 464 14 3.111 9.984 32.43 107.5 4.83 460 45 3.013 9.732 26.54 107.22 4.76 467 13 2.987 9.103 25.85 107.11 4.99 460 8 2.996 9.155 27.60 107.57 4.78 448 7 2.833 9.308 25.71 107.81 5.06 443 3 2.849 9.394 25.38 108.75 4.65 436 3 2.795 9.948 28.57 109.43 4.54 431 4 2.845 10.177 27.64 109.62 4.51 484 4 2.915 10.002 25.36 109.54 4.49 510 0 2.893 9.728 25.90 109.53 3.99 513 -4 2.604 10.002 26.29 109.84 3.97 503 -14 2.642 10.063 21.74 109.67 3.51 471 -18 2.660 10.018 19.20 109.79 3.34 471 -8 2.639 9.960 19.32 109.56 3.29 476 -1 2.720 10.236 19.82 110.22 3.28 475 1 2.746 10.893 20.36 110.4 3.26 470 2 2.736 10.756 24.31 110.69 3.32 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 time8 seconds
R Server'George Udny Yule' @ 72.249.76.132


Goodness of Fit
Correlation0.9377
R-squared0.8793
RMSE0.2628


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
13.032.744888888888890.285111111111111
22.8032.744888888888890.0581111111111108
32.7682.744888888888890.0231111111111106
42.8832.94794117647059-0.0649411764705885
52.8632.94794117647059-0.0849411764705885
62.8972.94794117647059-0.0509411764705887
73.0132.947941176470590.0650588235294114
83.1432.947941176470590.195058823529411
93.0332.947941176470590.0850588235294114
103.0462.947941176470590.0980588235294113
113.1112.947941176470590.163058823529412
123.0132.947941176470590.0650588235294114
132.9872.947941176470590.0390588235294116
142.9962.947941176470590.0480588235294115
152.8332.94794117647059-0.114941176470588
162.8492.94794117647059-0.0989411764705883
172.7952.94794117647059-0.152941176470589
182.8452.94794117647059-0.102941176470588
192.9152.94794117647059-0.0329411764705885
202.8932.94794117647059-0.0549411764705887
212.6042.306611111111110.297388888888888
222.6421.9761250.665875
232.661.9761250.683875
242.6392.306611111111110.332388888888888
252.722.306611111111110.413388888888889
262.7462.744888888888890.00111111111111084
272.7362.74488888888889-0.00888888888888895
282.8122.744888888888890.0671111111111107
292.7992.744888888888890.0541111111111108
302.5552.74488888888889-0.189888888888889
312.3052.30661111111111-0.00161111111111145
322.2152.30661111111111-0.0916111111111118
332.0662.30661111111111-0.240611111111112
341.942.30661111111111-0.366611111111112
352.0422.30661111111111-0.264611111111112
361.9952.30661111111111-0.311611111111112
371.9471.976125-0.0291249999999998
381.7661.976125-0.210125
391.6351.976125-0.341125
401.8331.976125-0.143125
411.911.976125-0.066125
421.961.976125-0.0161249999999999
431.971.976125-0.00612499999999994
442.0611.9761250.084875
452.0932.30661111111111-0.213611111111112
462.1211.9761250.144875
472.1752.30661111111111-0.131611111111112
482.1972.30661111111111-0.109611111111112
492.352.306611111111110.0433888888888885
502.442.306611111111110.133388888888888
512.4092.306611111111110.102388888888888
522.4732.306611111111110.166388888888888
532.4082.306611111111110.101388888888888
542.4552.74488888888889-0.289888888888889
552.4482.306611111111110.141388888888888
562.4982.81914285714286-0.321142857142857
572.6462.81914285714286-0.173142857142857
582.7572.81914285714286-0.0621428571428568
592.8492.819142857142860.0298571428571432
602.9212.819142857142860.101857142857143
612.9822.819142857142860.162857142857143
623.0812.819142857142860.261857142857143
633.1062.778666666666670.327333333333333
643.1192.778666666666670.340333333333333
653.0612.93450.1265
663.0972.93450.1625
673.1622.93450.2275
683.2572.93450.3225
693.2772.93450.3425
703.2952.778666666666670.516333333333333
713.3642.93450.4295
723.4943.7693-0.275300000000000
733.6673.7693-0.1023
743.8133.76930.0437000000000003
753.9183.76930.148700000000000
763.8963.76930.1267
773.8013.76930.0317000000000003
783.573.7693-0.1993
793.7023.7693-0.0672999999999999
803.8623.76930.0927000000000002
813.973.76930.200700000000000
824.1394.24521052631579-0.10621052631579
834.24.24521052631579-0.04521052631579
844.2914.245210526315790.0457894736842102
854.4444.245210526315790.198789473684210
864.5034.245210526315790.25778947368421
874.3574.245210526315790.11178947368421
884.5914.245210526315790.34578947368421
894.6974.245210526315790.45178947368421
904.6214.245210526315790.37578947368421
914.5634.245210526315790.317789473684210
924.2034.24521052631579-0.0422105263157899
934.2964.245210526315790.05078947368421
944.4354.245210526315790.189789473684209
954.1054.24521052631579-0.140210526315790
964.1174.24521052631579-0.128210526315790
973.8444.24521052631579-0.401210526315790
983.7214.24521052631579-0.52421052631579
993.6744.24521052631579-0.57121052631579
1003.8584.24521052631579-0.38721052631579
1013.8012.93450.8665
1023.5042.93450.5695
1033.0332.93450.0985
1043.0472.93450.112500000000000
1052.9622.93450.0275000000000003
1062.1982.236375-0.0383749999999998
1072.0142.236375-0.222375
1081.8631.976125-0.113125
1091.9051.976125-0.0711249999999999
1101.8111.976125-0.165125
1111.671.976125-0.306125
1121.8641.976125-0.112125000000000
1132.0522.236375-0.184375000000000
1142.032.236375-0.206375
1152.0712.236375-0.165375000000000
1162.2932.9345-0.6415
1172.4432.9345-0.4915
1182.5132.9345-0.4215
1192.4672.9345-0.4675
1202.5032.2363750.266625000000000
1212.542.2363750.303625
1222.4832.2363750.246625000000000
1232.6262.9345-0.3085
1242.6562.77866666666667-0.122666666666667
1252.4472.9345-0.4875
1262.4672.9345-0.4675
1272.4622.77866666666667-0.316666666666667
1282.5052.77866666666667-0.273666666666667
1292.5792.77866666666667-0.199666666666667
1302.6492.77866666666667-0.129666666666667
1312.6372.77866666666667-0.141666666666667
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/22/t12930430811usqngnfibvyhfh/28f1w1293040702.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/22/t12930430811usqngnfibvyhfh/28f1w1293040702.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/22/t12930430811usqngnfibvyhfh/38f1w1293040702.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/22/t12930430811usqngnfibvyhfh/38f1w1293040702.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/22/t12930430811usqngnfibvyhfh/4joiy1293040702.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/22/t12930430811usqngnfibvyhfh/4joiy1293040702.ps (open in new window)


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