Home » date » 2010 » Dec » 14 »

*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, 14 Dec 2010 00:35:45 +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/14/t1292286936xq98p5kz7ft1h9l.htm/, Retrieved Tue, 14 Dec 2010 01:35:37 +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/14/t1292286936xq98p5kz7ft1h9l.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 «
1579 0 4,0 45,7 2146 0 5,9 81,9 2462 0 7,1 56,8 3695 0 10,5 65,1 4831 0 15,1 86,2 5134 0 16,8 35,1 6250 0 15,3 133,8 5760 0 18,4 34,5 6249 0 16,1 69,9 2917 0 11,3 98,3 1741 0 7,9 86,7 2359 0 5,6 58,2 1511 1 3,4 83,6 2059 0 4,8 83,5 2635 0 6,5 112,3 2867 0 8,5 134,3 4403 0 15,1 30,0 5720 0 15,7 44,5 4502 0 18,7 120,1 5749 0 19,2 43,4 5627 0 12,9 199,4 2846 0 14,4 68,1 1762 0 6,2 99,8 2429 0 3,3 69,5 1169 0 4,6 71,3 2154 1 7,2 167,8 2249 0 7,8 66,3 2687 0 9,9 41,9 4359 0 13,6 57,2 5382 0 17,1 72,3 4459 0 17,8 96,5 6398 0 18,6 172,1 4596 0 14,7 25,8 3024 0 10,5 105,1 1887 0 8,6 92,2 2070 0 4,4 109,3 1351 0 2,3 101,7 2218 0 2,8 29,1 2461 1 8,8 34,6 3028 0 10,7 46,7 4784 0 13,9 82,0 4975 0 19,3 34,4 4607 0 19,5 72,7 6249 0 20,4 44,4 4809 0 15,3 31,0 3157 0 7,9 64,0 1910 0 8,3 65,4 2228 0 4,5 64,5 1594 0 3,2 153,8 2467 0 5,0 48,8 2222 0 6,6 25,0 3607 1 11,1 37,2 4685 0 12,8 40,8 4962 0 16,3 78,4 5770 0 17,4 112,4 5480 0 18,9 122,7 5000 0 15,8 82,9 3228 0 11,7 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
R Framework
error message
The field 'Names of X columns' contains a hard return which cannot be interpreted.
Please, resubmit your request without hard returns in the 'Names of X columns'.


Goodness of Fit
Correlation0.9294
R-squared0.8638
RMSE596.4812


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
115792093.64705882353-514.647058823529
221462093.6470588235352.3529411764707
324622093.64705882353368.352941176471
436953188.86666666667506.133333333333
548314414.70588235294416.294117647059
651345554.37837837838-420.378378378378
762505554.37837837838695.621621621622
857605554.37837837838205.621621621622
962495554.37837837838694.621621621622
1029173188.86666666667-271.866666666667
1117412093.64705882353-352.647058823529
1223592093.64705882353265.352941176471
1315112093.64705882353-582.647058823529
1420592093.64705882353-34.6470588235293
1526352093.64705882353541.352941176471
1628672093.64705882353773.352941176471
1744034414.70588235294-11.7058823529414
1857205554.37837837838165.621621621622
1945025554.37837837838-1052.37837837838
2057495554.37837837838194.621621621622
2156274414.705882352941212.29411764706
2228464414.70588235294-1568.70588235294
2317622093.64705882353-331.647058823529
2424292093.64705882353335.352941176471
2511692093.64705882353-924.647058823529
2621542093.6470588235360.3529411764707
2722492093.64705882353155.352941176471
2826873188.86666666667-501.866666666667
2943594414.70588235294-55.7058823529414
3053825554.37837837838-172.378378378378
3144595554.37837837838-1095.37837837838
3263985554.37837837838843.621621621622
3345964414.70588235294181.294117647059
3430243188.86666666667-164.866666666667
3518872093.64705882353-206.647058823529
3620702093.64705882353-23.6470588235293
3713512093.64705882353-742.647058823529
3822182093.64705882353124.352941176471
3924612093.64705882353367.352941176471
4030283188.86666666667-160.866666666667
4147844414.70588235294369.294117647059
4249755554.37837837838-579.378378378378
4346075554.37837837838-947.378378378378
4462495554.37837837838694.621621621622
4548095554.37837837838-745.378378378378
4631572093.647058823531063.35294117647
4719102093.64705882353-183.647058823529
4822282093.64705882353134.352941176471
4915942093.64705882353-499.647058823529
5024672093.64705882353373.352941176471
5122222093.64705882353128.352941176471
5236073188.86666666667418.133333333333
5346854414.70588235294270.294117647059
5449625554.37837837838-592.378378378378
5557705554.37837837838215.621621621622
5654805554.37837837838-74.3783783783783
5750005554.37837837838-554.378378378378
5832283188.8666666666739.1333333333332
5919932093.64705882353-100.647058823529
6022882093.64705882353194.352941176471
6115802093.64705882353-513.647058823529
6221112093.6470588235317.3529411764707
6321922093.6470588235398.3529411764707
6436013188.86666666667412.133333333333
6546654414.70588235294250.294117647059
6648765554.37837837838-678.378378378378
6758135554.37837837838258.621621621622
6855895554.3783783783834.6216216216217
6953315554.37837837838-223.378378378378
7030754414.70588235294-1339.70588235294
7120022093.64705882353-91.6470588235293
7223062093.64705882353212.352941176471
7315072093.64705882353-586.647058823529
7419922093.64705882353-101.647058823529
7524872093.64705882353393.352941176471
7634903188.86666666667301.133333333333
7746474414.70588235294232.294117647059
7855945554.3783783783839.6216216216217
7956115554.3783783783856.6216216216217
8057885554.37837837838233.621621621622
8162045554.37837837838649.621621621622
8230134414.70588235294-1401.70588235294
8319312093.64705882353-162.647058823529
8425492093.64705882353455.352941176471
8515042093.64705882353-589.647058823529
8620902093.64705882353-3.64705882352928
8727022093.64705882353608.352941176471
8829394414.70588235294-1475.70588235294
8945004414.7058823529485.2941176470586
9062085554.37837837838653.621621621622
9164155554.37837837838860.621621621622
9256575554.37837837838102.621621621622
9359644414.705882352941549.29411764706
9431633188.86666666667-25.8666666666668
9519972093.64705882353-96.6470588235293
9624222093.64705882353328.352941176471
9713762093.64705882353-717.647058823529
9822022093.64705882353108.352941176471
9926832093.64705882353589.352941176471
10033033188.86666666667114.133333333333
10152025554.37837837838-352.378378378378
10252315554.37837837838-323.378378378378
10348805554.37837837838-674.378378378378
10479985554.378378378382443.62162162162
10549774414.70588235294562.294117647059
10635313188.86666666667342.133333333333
10720252093.64705882353-68.6470588235293
10822052093.64705882353111.352941176471
10914422093.64705882353-651.647058823529
11022382093.64705882353144.352941176471
11121792093.6470588235385.3529411764707
11232183188.8666666666729.1333333333332
11351394414.70588235294724.294117647059
11449905554.37837837838-564.378378378378
11549145554.37837837838-640.378378378378
11660845554.37837837838529.621621621622
11756725554.37837837838117.621621621622
11835483188.86666666667359.133333333333
11917933188.86666666667-1395.86666666667
12020862093.64705882353-7.64705882352928
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/14/t1292286936xq98p5kz7ft1h9l/2c56z1292286939.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/14/t1292286936xq98p5kz7ft1h9l/2c56z1292286939.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/14/t1292286936xq98p5kz7ft1h9l/3c56z1292286939.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/14/t1292286936xq98p5kz7ft1h9l/3c56z1292286939.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/14/t1292286936xq98p5kz7ft1h9l/44wn21292286939.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/14/t1292286936xq98p5kz7ft1h9l/44wn21292286939.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