Home » date » 2010 » Dec » 11 »

recursive partitioning (NC) gewesten

*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: Sat, 11 Dec 2010 17:29:40 +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/11/t1292088638iwo89qm4iw3gv1o.htm/, Retrieved Sat, 11 Dec 2010 18:30:39 +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/11/t1292088638iwo89qm4iw3gv1o.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 «
33024 31086 19828 18932 32526 30839 19967 18927 31455 30051 19814 19124 31524 29976 20053 19066 31856 30463 20719 19971 32696 31422 21174 20165 32584 31588 20648 19705 33498 31900 20659 19718 34175 32878 20733 19938 34172 33010 21069 20039 34379 32954 20566 19721 34988 33076 20839 19777 36158 35057 21615 20505 37411 35906 22739 21763 38015 36100 23222 22404 37577 35824 23031 22038 36354 34579 23014 22038 36030 34484 22868 21874 35636 33920 22182 21269 35669 34059 22177 21127 34635 33812 21216 20609 35496 34594 21031 20565 36376 36083 20968 19791 37635 36563 21049 20672 38875 37416 21033 20938 38372 37953 21078 20675 38897 37517 20702 19992 38018 37467 20309 19801 37325 36963 20449 20050 36893 36019 20737 20427 36117 35232 20849 20815 37599 36857 21966 21666 39037 37978 23100 22720 40809 40160 23975 23650 42508 42165 24350 24244 44021 43069 24020 23669 44088 43021 24005 23881 44510 43376 23602 23857 45786 43978 24120 23999 47349 45911 24847 24780 48696 47107 25702 25426 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.994
R-squared0.988
RMSE1810.3897


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
13302433156.4285714286-132.428571428572
23252633156.4285714286-630.428571428572
33145533156.4285714286-1701.42857142857
43152433156.4285714286-1632.42857142857
53185633156.4285714286-1300.42857142857
63269633156.4285714286-460.428571428572
73258433156.4285714286-572.428571428572
83349833156.4285714286341.571428571428
93417533156.42857142861018.57142857143
103417233156.42857142861015.57142857143
113437933156.42857142861222.57142857143
123498833156.42857142861831.57142857143
133615836439.2352941177-281.23529411765
143741136439.2352941177971.76470588235
153801536439.23529411771575.76470588235
163757736439.23529411771137.76470588235
173635436439.2352941177-85.2352941176505
183603036439.2352941177-409.23529411765
193563636439.2352941177-803.23529411765
203566936439.2352941177-770.23529411765
213463533156.42857142861478.57142857143
223549636439.2352941177-943.23529411765
233637636439.2352941177-63.2352941176505
243763536439.23529411771195.76470588235
253887540097.625-1222.625
263837240097.625-1725.625
273889740097.625-1200.625
283801840097.625-2079.625
293732536439.2352941177885.76470588235
303689336439.2352941177453.76470588235
313611736439.2352941177-322.23529411765
323759936439.23529411771159.76470588235
333903740097.625-1060.625
344080940097.625711.375
354250840097.6252410.375
364402147061.1875-3040.1875
374408847061.1875-2973.1875
384451047061.1875-2551.1875
394578647061.1875-1275.1875
404734947061.1875287.8125
414869647061.18751634.8125
425059847061.18753536.8125
435006647061.18753004.8125
444936747061.18752305.8125
454878447061.18751722.8125
464784147061.1875779.8125
474830047061.18751238.8125
484751847061.1875456.8125
494650447061.1875-557.1875
504514747061.1875-1914.1875
514440447061.1875-2657.1875
524345540097.6253357.375
534229940097.6252201.375
544210540097.6252007.375
554015240097.62554.375
563951940097.625-578.625
573963340097.625-464.625
583937640097.625-721.625
593885040097.625-1247.625
603965740097.625-440.625
613480436439.2352941177-1635.23529411765
623437236439.2352941177-2067.23529411765
633267833156.4285714286-478.428571428572
642842026704.51715.5
652542026704.5-1284.5
662768326704.5978.5
672990426704.53199.5
683054626704.53841.5
692914226704.52437.5
702772426704.51019.5
712706926704.5364.5
722666526704.5-39.5
732600426704.5-700.5
742576726704.5-937.5
752491526704.5-1789.5
762368926704.5-3015.5
772091526704.5-5789.5
781941413769.66666666675644.33333333333
791782413769.66666666674054.33333333333
801634813769.66666666672578.33333333333
811557113769.66666666671801.33333333333
821392913769.6666666667159.333333333334
831248013769.6666666667-1289.66666666667
841083713769.6666666667-2932.66666666667
85947313769.6666666667-4296.66666666667
86805113769.6666666667-5718.66666666667
87527826512627
8830082651357
8924042651-247
9022982651-353
9122602651-391
9219382651-713
9313712651-1280
941009163.944444444444845.055555555556
95686163.944444444444522.055555555556
96493163.944444444444329.055555555556
97285163.944444444444121.055555555556
98192163.94444444444428.0555555555555
99129163.944444444444-34.9444444444445
10060163.944444444444-103.944444444444
10154163.944444444444-109.944444444444
10226163.944444444444-137.944444444444
10311163.944444444444-152.944444444444
1043163.944444444444-160.944444444444
1050163.944444444444-163.944444444444
1062163.944444444444-161.944444444444
1071163.944444444444-162.944444444444
1080163.944444444444-163.944444444444
1090163.944444444444-163.944444444444
1100163.944444444444-163.944444444444
1110163.944444444444-163.944444444444
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/11/t1292088638iwo89qm4iw3gv1o/2qyzz1292088573.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/11/t1292088638iwo89qm4iw3gv1o/2qyzz1292088573.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/11/t1292088638iwo89qm4iw3gv1o/3qyzz1292088573.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/11/t1292088638iwo89qm4iw3gv1o/3qyzz1292088573.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/11/t1292088638iwo89qm4iw3gv1o/417y21292088573.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/11/t1292088638iwo89qm4iw3gv1o/417y21292088573.ps (open in new window)


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