Home » date » 2010 » Dec » 22 »

WS10 Feedback Recursive Partitioning

*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 16:40:24 +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/t1293035980ak1xqkyvvpo0phz.htm/, Retrieved Wed, 22 Dec 2010 17:39:41 +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/t1293035980ak1xqkyvvpo0phz.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 «
211868 43880 229527 43110 229139 44496 198563 44164 195722 40399 202196 36763 205816 37903 212588 35532 214320 35533 220375 32110 204442 33374 206903 35462 214126 33508 226899 36080 223532 34560 195309 38737 186005 38144 188906 37594 191563 36424 189226 36843 186413 37246 178037 38661 166827 40454 169362 44928 174330 48441 187069 48140 186530 45998 158114 47369 151001 49554 159612 47510 161914 44873 164182 45344 169701 42413 171297 36912 166444 43452 173476 42142 182516 44382 202388 43636 202300 44167 168053 44423 167302 42868 172608 43908 178106 42013 185686 38846 194581 35087 194596 33026 197922 34646 208795 37135 230580 37985 240636 43121 240048 43722 211457 43630 211142 42234 214771 39351 212610 39327 219313 35704 219277 30466 231805 28155 229245 29257 241114 29998 248624 32529 265845 34787 256446 33855 219452 34556 217142 31348 221678 30805 227184 28353 230354 24514 235243 21106 237217 21346 233575 23335 244460 24379 243324 26290 26 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


Goodness of Fit
Correlation0.2955
R-squared0.0873
RMSE26037.693


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
1211868199626.27512241.725
2229527199626.27529900.725
3229139199626.27529512.725
4198563199626.275-1063.27499999999
5195722199626.275-3904.27499999999
6202196199626.2752569.72500000001
7205816199626.2756189.725
8212588199626.27512961.725
9214320199626.27514693.725
10220375199626.27520748.725
11204442199626.2754815.72500000001
12206903199626.2757276.725
13214126199626.27514499.725
14226899199626.27527272.725
15223532199626.27523905.725
16195309199626.275-4317.27499999999
17186005199626.275-13621.275
18188906199626.275-10720.275
19191563199626.275-8063.275
20189226199626.275-10400.275
21186413199626.275-13213.275
22178037199626.275-21589.275
23166827199626.275-32799.275
24169362168012.6666666671349.33333333334
25174330168012.6666666676317.33333333334
26187069168012.66666666719056.3333333333
27186530168012.66666666718517.3333333333
28158114168012.666666667-9898.66666666666
29151001168012.666666667-17011.6666666667
30159612168012.666666667-8400.66666666666
31161914168012.666666667-6098.66666666666
32164182168012.666666667-3830.66666666666
33169701199626.275-29925.275
34171297199626.275-28329.275
35166444199626.275-33182.275
36173476199626.275-26150.275
37182516199626.275-17110.275
38202388199626.2752761.72500000001
39202300199626.2752673.72500000001
40168053199626.275-31573.275
41167302199626.275-32324.275
42172608199626.275-27018.275
43178106199626.275-21520.275
44185686199626.275-13940.275
45194581199626.275-5045.27499999999
46194596199626.275-5030.27499999999
47197922199626.275-1704.27499999999
48208795199626.2759168.725
49230580199626.27530953.725
50240636199626.27541009.725
51240048199626.27540421.725
52211457199626.27511830.725
53211142199626.27511515.725
54214771199626.27515144.725
55212610199626.27512983.725
56219313199626.27519686.725
57219277199626.27519650.725
58231805199626.27532178.725
59229245199626.27529618.725
60241114199626.27541487.725
61248624199626.27548997.725
62265845199626.27566218.725
63256446199626.27556819.725
64219452199626.27519825.725
65217142199626.27517515.725
66221678199626.27522051.725
67227184199626.27527557.725
68230354199626.27530727.725
69235243199626.27535616.725
70237217199626.27537590.725
71233575199626.27533948.725
72244460199626.27544833.725
73243324199626.27543697.725
74260307199626.27560680.725
75241476199626.27541849.725
76203666199626.2754039.72500000001
77200237199626.275610.725000000006
78204045199626.2754418.72500000001
79209465199626.2759838.725
80213586199626.27513959.725
81216234199626.27516607.725
82213188199626.27513561.725
83208679199626.2759052.725
84217859199626.27518232.725
85227247199626.27527620.725
86243477199626.27543850.725
87232571199626.27532944.725
88191531199626.275-8095.275
89186029199626.275-13597.275
90189733199626.275-9893.275
91190420199626.275-9206.275
92194163199626.275-5463.27499999999
93198770199626.275-856.274999999994
94195198199626.275-4428.27499999999
95193111199626.275-6515.275
96195411199626.275-4215.27499999999
97202108199626.2752481.72500000001
98215706199626.27516079.725
99206348199626.2756721.725
100166972199626.275-32654.275
101166070199626.275-33556.275
102169292199626.275-30334.275
103175041199626.275-24585.275
104177876199626.275-21750.275
105181140199626.275-18486.275
106179566199626.275-20060.275
107175335199626.275-24291.275
108184128199626.275-15498.275
109189917199626.275-9709.275
110194690199626.275-4936.27499999999
111179612199626.275-20014.275
112150605199626.275-49021.275
113150569199626.275-49057.275
114153745199626.275-45881.275
115155511199626.275-44115.275
116159044199626.275-40582.275
117163095199626.275-36531.275
118159585199626.275-40041.275
119158644199626.275-40982.275
120166618199626.275-33008.275
121176512199626.275-23114.275
122200765199626.2751138.72500000001
123182698199626.275-16928.275
124153730199626.275-45896.275
125156145199626.275-43481.275
126161570199626.275-38056.275
127165688199626.275-33938.275
128173666199626.275-25960.275
129180144199626.275-19482.275
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/22/t1293035980ak1xqkyvvpo0phz/2zhgy1293036018.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/22/t1293035980ak1xqkyvvpo0phz/2zhgy1293036018.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/22/t1293035980ak1xqkyvvpo0phz/3zhgy1293036018.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/22/t1293035980ak1xqkyvvpo0phz/3zhgy1293036018.ps (open in new window)


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


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