Home » date » 2010 » Dec » 24 »

*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: Fri, 24 Dec 2010 17:31:53 +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/24/t12932118446ikbdf5ahjklw4h.htm/, Retrieved Fri, 24 Dec 2010 18:30:48 +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/24/t12932118446ikbdf5ahjklw4h.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 «
9506 1775 8704 2197 10079 2920 8993 4240 9957 5415 10240 6136 10098 6719 10090 6234 9867 7152 9736 3646 9040 2165 9232 2803 9520 1615 9217 2350 9868 3350 9455 3536 9984 5834 9556 6767 10190 5993 9906 7276 9824 5641 9972 3477 9185 2247 9765 2466 9838 1567 9084 2237 9643 2598 10051 3729 9987 5715 9827 5776 10491 5852 9722 6878 9472 5488 9728 3583 8510 2054 9511 2282 9492 1552 8638 2261 9792 2446 9605 3519 9237 5161 9533 5085 10293 5711 9938 6057 9984 5224 9563 3363 8871 1899 9301 2115 9215 1491 8834 2061 9998 2419 9604 3430 9507 4778 9718 4862 10095 6176 9583 5664 9883 5529 9365 3418 8919 1941 9449 2402 9769 1579 9321 2146 9939 2462 9336 3695 10195 4831 9464 5134 10010 6250 10213 5760 9563 6249 9890 2917 9305 1741 9391 2359 9743 1511 8587 2059 9731 2635 9563 2867 9998 4403 9437 5720 10038 4502 9918 5749 9252 5627 9737 2846 9035 1762 9133 2429 9487 1169 8700 2154 9627 2249 8947 2687 9283 4359 8829 5382 9947 4459 9628 6398 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 time15 seconds
R Server'George Udny Yule' @ 72.249.76.132


Goodness of Fit
Correlation0.6167
R-squared0.3803
RMSE346.546


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
195069128.4074074074377.592592592593
287049128.4074074074-424.407407407407
3100799654.71428571429424.285714285714
489939654.71428571429-661.714285714286
599579932.7524.25
6102409932.75307.25
7100989932.75165.25
8100909932.75157.25
998679932.75-65.75
1097369654.7142857142981.2857142857138
1190409128.4074074074-88.407407407407
1292329654.71428571429-422.714285714286
1395209641.8-121.799999999999
1492179654.71428571429-437.714285714286
1598689654.71428571429213.285714285714
1694559654.71428571429-199.714285714286
1799849932.7551.25
1895569932.75-376.75
19101909932.75257.25
2099069932.75-26.75
2198249932.75-108.75
2299729654.71428571429317.285714285714
2391859128.407407407456.5925925925931
2497659654.71428571429110.285714285714
2598389641.8196.200000000001
2690849128.4074074074-44.4074074074069
2796439654.71428571429-11.7142857142862
28100519654.71428571429396.285714285714
2999879932.7554.25
3098279932.75-105.75
31104919932.75558.25
3297229932.75-210.75
3394729932.75-460.75
3497289654.7142857142973.2857142857138
3585109128.4074074074-618.407407407407
3695119654.71428571429-143.714285714286
3794929641.8-149.799999999999
3886389128.4074074074-490.407407407407
3997929654.71428571429137.285714285714
4096059654.71428571429-49.7142857142862
4192379654.71428571429-417.714285714286
4295339654.71428571429-121.714285714286
43102939932.75360.25
4499389932.755.25
4599849654.71428571429329.285714285714
4695639654.71428571429-91.7142857142862
4788719128.4074074074-257.407407407407
4893019128.4074074074172.592592592593
4992159641.8-426.799999999999
5088349128.4074074074-294.407407407407
5199989654.71428571429343.285714285714
5296049654.71428571429-50.7142857142862
5395079654.71428571429-147.714285714286
5497189654.7142857142963.2857142857138
55100959932.75162.25
5695839932.75-349.75
5798839932.75-49.75
5893659654.71428571429-289.714285714286
5989199128.4074074074-209.407407407407
6094499654.71428571429-205.714285714286
6197699641.8127.200000000001
6293219128.4074074074192.592592592593
6399399654.71428571429284.285714285714
6493369654.71428571429-318.714285714286
65101959654.71428571429540.285714285714
6694649654.71428571429-190.714285714286
67100109932.7577.25
68102139932.75280.25
6995639932.75-369.75
7098909654.71428571429235.285714285714
7193059128.4074074074176.592592592593
7293919654.71428571429-263.714285714286
7397439641.8101.200000000001
7485879128.4074074074-541.407407407407
7597319654.7142857142976.2857142857138
7695639654.71428571429-91.7142857142862
7799989654.71428571429343.285714285714
7894379932.75-495.75
79100389654.71428571429383.285714285714
8099189932.75-14.75
8192529932.75-680.75
8297379654.7142857142982.2857142857138
8390359128.4074074074-93.407407407407
8491339654.71428571429-521.714285714286
8594879641.8-154.799999999999
8687009128.4074074074-428.407407407407
8796279128.4074074074498.592592592593
8889479654.71428571429-707.714285714286
8992839654.71428571429-371.714285714286
9088299654.71428571429-825.714285714286
9199479654.71428571429292.285714285714
9296289932.75-304.75
9393189654.71428571429-336.714285714286
9496059654.71428571429-49.7142857142862
9586409128.4074074074-488.407407407407
9692149128.407407407485.592592592593
9796769641.834.2000000000007
9886429128.4074074074-486.407407407407
9994029654.71428571429-252.714285714286
10096109654.71428571429-44.7142857142862
10192949654.71428571429-360.714285714286
10294489654.71428571429-206.714285714286
103103199654.71428571429664.285714285714
10495489932.75-384.75
10598019654.71428571429146.285714285714
10695969654.71428571429-58.7142857142862
10789239128.4074074074-205.407407407407
10897469128.4074074074617.592592592593
10998299641.8187.200000000001
11091259654.71428571429-529.714285714286
11197829128.4074074074653.592592592593
11294419654.71428571429-213.714285714286
11391629654.71428571429-492.714285714286
11499159654.71428571429260.285714285714
115104449932.75511.25
116102099932.75276.25
11799859654.71428571429330.285714285714
11898429654.71428571429187.285714285714
11994299128.4074074074300.592592592593
120101329654.71428571429477.285714285714
12198499641.8207.200000000001
12291729128.407407407443.5925925925931
123103139128.40740740741184.59259259259
12498199654.71428571429164.285714285714
12599559654.71428571429300.285714285714
126100489654.71428571429393.285714285714
127100829932.75149.25
128105419932.75608.25
129102089654.71428571429553.285714285714
130102339654.71428571429578.285714285714
13194399128.4074074074310.592592592593
13299639654.71428571429308.285714285714
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/24/t12932118446ikbdf5ahjklw4h/2orl11293211897.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/24/t12932118446ikbdf5ahjklw4h/2orl11293211897.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/24/t12932118446ikbdf5ahjklw4h/3orl11293211897.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/24/t12932118446ikbdf5ahjklw4h/3orl11293211897.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/24/t12932118446ikbdf5ahjklw4h/4yilm1293211897.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/24/t12932118446ikbdf5ahjklw4h/4yilm1293211897.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