| 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!
Goodness of Fit | Correlation | 0.2955 | R-squared | 0.0873 | RMSE | 26037.693 |
Actuals, Predictions, and Residuals | # | Actuals | Forecasts | Residuals | 1 | 211868 | 199626.275 | 12241.725 | 2 | 229527 | 199626.275 | 29900.725 | 3 | 229139 | 199626.275 | 29512.725 | 4 | 198563 | 199626.275 | -1063.27499999999 | 5 | 195722 | 199626.275 | -3904.27499999999 | 6 | 202196 | 199626.275 | 2569.72500000001 | 7 | 205816 | 199626.275 | 6189.725 | 8 | 212588 | 199626.275 | 12961.725 | 9 | 214320 | 199626.275 | 14693.725 | 10 | 220375 | 199626.275 | 20748.725 | 11 | 204442 | 199626.275 | 4815.72500000001 | 12 | 206903 | 199626.275 | 7276.725 | 13 | 214126 | 199626.275 | 14499.725 | 14 | 226899 | 199626.275 | 27272.725 | 15 | 223532 | 199626.275 | 23905.725 | 16 | 195309 | 199626.275 | -4317.27499999999 | 17 | 186005 | 199626.275 | -13621.275 | 18 | 188906 | 199626.275 | -10720.275 | 19 | 191563 | 199626.275 | -8063.275 | 20 | 189226 | 199626.275 | -10400.275 | 21 | 186413 | 199626.275 | -13213.275 | 22 | 178037 | 199626.275 | -21589.275 | 23 | 166827 | 199626.275 | -32799.275 | 24 | 169362 | 168012.666666667 | 1349.33333333334 | 25 | 174330 | 168012.666666667 | 6317.33333333334 | 26 | 187069 | 168012.666666667 | 19056.3333333333 | 27 | 186530 | 168012.666666667 | 18517.3333333333 | 28 | 158114 | 168012.666666667 | -9898.66666666666 | 29 | 151001 | 168012.666666667 | -17011.6666666667 | 30 | 159612 | 168012.666666667 | -8400.66666666666 | 31 | 161914 | 168012.666666667 | -6098.66666666666 | 32 | 164182 | 168012.666666667 | -3830.66666666666 | 33 | 169701 | 199626.275 | -29925.275 | 34 | 171297 | 199626.275 | -28329.275 | 35 | 166444 | 199626.275 | -33182.275 | 36 | 173476 | 199626.275 | -26150.275 | 37 | 182516 | 199626.275 | -17110.275 | 38 | 202388 | 199626.275 | 2761.72500000001 | 39 | 202300 | 199626.275 | 2673.72500000001 | 40 | 168053 | 199626.275 | -31573.275 | 41 | 167302 | 199626.275 | -32324.275 | 42 | 172608 | 199626.275 | -27018.275 | 43 | 178106 | 199626.275 | -21520.275 | 44 | 185686 | 199626.275 | -13940.275 | 45 | 194581 | 199626.275 | -5045.27499999999 | 46 | 194596 | 199626.275 | -5030.27499999999 | 47 | 197922 | 199626.275 | -1704.27499999999 | 48 | 208795 | 199626.275 | 9168.725 | 49 | 230580 | 199626.275 | 30953.725 | 50 | 240636 | 199626.275 | 41009.725 | 51 | 240048 | 199626.275 | 40421.725 | 52 | 211457 | 199626.275 | 11830.725 | 53 | 211142 | 199626.275 | 11515.725 | 54 | 214771 | 199626.275 | 15144.725 | 55 | 212610 | 199626.275 | 12983.725 | 56 | 219313 | 199626.275 | 19686.725 | 57 | 219277 | 199626.275 | 19650.725 | 58 | 231805 | 199626.275 | 32178.725 | 59 | 229245 | 199626.275 | 29618.725 | 60 | 241114 | 199626.275 | 41487.725 | 61 | 248624 | 199626.275 | 48997.725 | 62 | 265845 | 199626.275 | 66218.725 | 63 | 256446 | 199626.275 | 56819.725 | 64 | 219452 | 199626.275 | 19825.725 | 65 | 217142 | 199626.275 | 17515.725 | 66 | 221678 | 199626.275 | 22051.725 | 67 | 227184 | 199626.275 | 27557.725 | 68 | 230354 | 199626.275 | 30727.725 | 69 | 235243 | 199626.275 | 35616.725 | 70 | 237217 | 199626.275 | 37590.725 | 71 | 233575 | 199626.275 | 33948.725 | 72 | 244460 | 199626.275 | 44833.725 | 73 | 243324 | 199626.275 | 43697.725 | 74 | 260307 | 199626.275 | 60680.725 | 75 | 241476 | 199626.275 | 41849.725 | 76 | 203666 | 199626.275 | 4039.72500000001 | 77 | 200237 | 199626.275 | 610.725000000006 | 78 | 204045 | 199626.275 | 4418.72500000001 | 79 | 209465 | 199626.275 | 9838.725 | 80 | 213586 | 199626.275 | 13959.725 | 81 | 216234 | 199626.275 | 16607.725 | 82 | 213188 | 199626.275 | 13561.725 | 83 | 208679 | 199626.275 | 9052.725 | 84 | 217859 | 199626.275 | 18232.725 | 85 | 227247 | 199626.275 | 27620.725 | 86 | 243477 | 199626.275 | 43850.725 | 87 | 232571 | 199626.275 | 32944.725 | 88 | 191531 | 199626.275 | -8095.275 | 89 | 186029 | 199626.275 | -13597.275 | 90 | 189733 | 199626.275 | -9893.275 | 91 | 190420 | 199626.275 | -9206.275 | 92 | 194163 | 199626.275 | -5463.27499999999 | 93 | 198770 | 199626.275 | -856.274999999994 | 94 | 195198 | 199626.275 | -4428.27499999999 | 95 | 193111 | 199626.275 | -6515.275 | 96 | 195411 | 199626.275 | -4215.27499999999 | 97 | 202108 | 199626.275 | 2481.72500000001 | 98 | 215706 | 199626.275 | 16079.725 | 99 | 206348 | 199626.275 | 6721.725 | 100 | 166972 | 199626.275 | -32654.275 | 101 | 166070 | 199626.275 | -33556.275 | 102 | 169292 | 199626.275 | -30334.275 | 103 | 175041 | 199626.275 | -24585.275 | 104 | 177876 | 199626.275 | -21750.275 | 105 | 181140 | 199626.275 | -18486.275 | 106 | 179566 | 199626.275 | -20060.275 | 107 | 175335 | 199626.275 | -24291.275 | 108 | 184128 | 199626.275 | -15498.275 | 109 | 189917 | 199626.275 | -9709.275 | 110 | 194690 | 199626.275 | -4936.27499999999 | 111 | 179612 | 199626.275 | -20014.275 | 112 | 150605 | 199626.275 | -49021.275 | 113 | 150569 | 199626.275 | -49057.275 | 114 | 153745 | 199626.275 | -45881.275 | 115 | 155511 | 199626.275 | -44115.275 | 116 | 159044 | 199626.275 | -40582.275 | 117 | 163095 | 199626.275 | -36531.275 | 118 | 159585 | 199626.275 | -40041.275 | 119 | 158644 | 199626.275 | -40982.275 | 120 | 166618 | 199626.275 | -33008.275 | 121 | 176512 | 199626.275 | -23114.275 | 122 | 200765 | 199626.275 | 1138.72500000001 | 123 | 182698 | 199626.275 | -16928.275 | 124 | 153730 | 199626.275 | -45896.275 | 125 | 156145 | 199626.275 | -43481.275 | 126 | 161570 | 199626.275 | -38056.275 | 127 | 165688 | 199626.275 | -33938.275 | 128 | 173666 | 199626.275 | -25960.275 | 129 | 180144 | 199626.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
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
|