Home » date » 2010 » Dec » 20 »

Recursieve Partitioning: arbeidshandicap

*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: Mon, 20 Dec 2010 14:38:00 +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/20/t1292855799v00axwvc3mue6z0.htm/, Retrieved Mon, 20 Dec 2010 15:36:43 +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/20/t1292855799v00axwvc3mue6z0.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 «
22.037 17.759 14.116 104.708 158.620 21.732 17.530 13.504 101.817 154.583 21.172 17.139 13.168 97.898 149.377 21.388 16.916 13.064 95.559 146.927 22.053 16.543 12.828 92.822 144.246 22.687 16.317 12.541 90.848 142.393 24.793 18.161 13.547 101.141 157.642 26.113 19.144 13.710 105.841 164.808 23.708 16.947 12.535 93.647 146.837 23.554 16.491 12.386 90.923 143.354 23.222 16.428 12.253 89.130 141.033 23.363 16.639 12.484 90.212 142.698 24.023 16.821 12.966 93.196 147.006 23.355 16.765 12.770 91.861 144.751 23.276 16.533 12.660 90.593 143.062 23.085 16.554 12.514 89.895 142.048 23.173 16.494 12.430 88.819 140.916 23.487 16.612 12.372 87.924 140.395 25.576 17.933 13.085 96.906 153.500 26.311 19.070 13.454 101.217 160.052 27.109 18.179 13.361 98.709 157.358 27.060 17.830 13.713 98.139 156.742 26.490 17.349 13.601 95.529 152.969 27.157 17.919 14.090 98.577 157.743 26.973 18.269 14.452 100.772 160.466 27.589 18.385 14.108 100.180 160.262 27.246 18.260 14.036 99.200 158.742 26.845 17.905 13.3 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.9923
R-squared0.9847
RMSE0.6235


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
117.75917.8651666666667-0.106166666666667
217.5317.8651666666667-0.335166666666666
317.13916.65707142857140.481928571428572
416.91616.65707142857140.258928571428573
516.54316.6570714285714-0.114071428571428
616.31716.6570714285714-0.340071428571427
718.16117.86516666666670.295833333333334
819.14418.86950.2745
916.94716.65707142857140.289928571428572
1016.49116.6570714285714-0.166071428571428
1116.42816.6570714285714-0.229071428571427
1216.63916.6570714285714-0.0180714285714281
1316.82116.65707142857140.163928571428574
1416.76516.65707142857140.107928571428573
1516.53316.6570714285714-0.124071428571426
1616.55416.6570714285714-0.103071428571429
1716.49416.6570714285714-0.163071428571428
1816.61216.6570714285714-0.0450714285714291
1917.93317.86516666666670.0678333333333327
2019.0718.86950.200500000000002
2118.17917.86516666666670.313833333333331
2217.8317.8651666666667-0.0351666666666688
2317.34917.8651666666667-0.516166666666667
2417.91917.86516666666670.0538333333333334
2518.26918.8695-0.6005
2618.38518.8695-0.484499999999997
2718.2617.86516666666670.394833333333334
2817.90517.86516666666670.0398333333333341
2917.7317.8651666666667-0.135166666666667
3017.82717.8651666666667-0.0381666666666653
3119.97820.1624444444444-0.184444444444445
3220.31520.16244444444440.152555555555555
3318.93118.86950.0615000000000023
3418.73218.8695-0.137499999999999
3519.15518.86950.285500000000003
3619.2718.86950.400500000000001
3719.75420.1624444444444-0.408444444444445
3819.84520.1624444444444-0.317444444444448
3919.93720.1624444444444-0.225444444444445
4020.09720.1624444444444-0.0654444444444451
4119.98120.1624444444444-0.181444444444445
4220.50220.16244444444440.339555555555553
4322.71222.1230.589000000000002
4423.10122.1230.978000000000002
4521.38122.123-0.741999999999997
4621.25522.123-0.867999999999999
4721.05320.16244444444440.890555555555554
4821.56122.123-0.561999999999998
4921.92322.123-0.199999999999999
5022.00122.123-0.121999999999996
5122.36922.1230.246000000000002
5222.3222.1230.197000000000003
5322.14922.1230.0260000000000034
5422.58122.1230.458000000000002
5524.89626.6273333333333-1.73133333333334
5626.6126.6273333333333-0.0173333333333368
5725.41726.6273333333333-1.21033333333333
5826.48426.6273333333333-0.143333333333334
5926.32926.6273333333333-0.298333333333336
6026.98926.62733333333330.361666666666665
6127.1826.62733333333330.552666666666664
6227.28426.62733333333330.656666666666663
6327.43626.62733333333330.808666666666664
6427.08226.62733333333330.454666666666665
6526.81826.62733333333330.190666666666665
6627.00326.62733333333330.375666666666664
6729.34428.49492592592590.849074074074078
6829.77728.49492592592591.28207407407408
6928.0728.4949259259259-0.424925925925923
7027.99328.4949259259259-0.501925925925924
7127.67228.4949259259259-0.822925925925922
7227.80228.4949259259259-0.692925925925923
7327.32828.4949259259259-1.16692592592592
7427.66628.4949259259259-0.828925925925923
7527.45628.4949259259259-1.03892592592592
7627.79628.4949259259259-0.698925925925924
7727.64228.4949259259259-0.852925925925923
7827.65128.4949259259259-0.843925925925923
7929.60428.49492592592591.10907407407408
8029.19628.49492592592590.701074074074079
8128.32828.4949259259259-0.166925925925923
8227.98627.4543750.531625000000002
8327.73827.4543750.283625000000001
8427.86727.4543750.412625000000002
8527.5828.4949259259259-0.914925925925925
8627.38128.4949259259259-1.11392592592592
8727.29227.454375-0.162374999999997
8826.94427.454375-0.510375
8926.32927.454375-1.12537500000000
9029.02328.49492592592590.528074074074077
9128.70528.49492592592590.210074074074075
9227.21327.454375-0.241374999999998
9327.06327.454375-0.391375
9427.0127.454375-0.444374999999997
9527.70927.4543750.254625000000001
9627.80227.4543750.347625000000001
9727.68727.4543750.232625000000002
9827.71927.4543750.264625000000002
9927.96127.4543750.506625
10027.20327.454375-0.251374999999999
10127.74727.4543750.292625000000001
10230.71328.49492592592592.21807407407408
10330.39528.49492592592591.90007407407408
10428.89528.49492592592590.400074074074077
10528.4628.4949259259259-0.034925925925922
10628.28628.4949259259259-0.208925925925922
10728.98428.49492592592590.489074074074079
10829.62428.49492592592591.12907407407408
10929.73429.9608-0.226800000000001
11030.60329.96080.642199999999999
11130.42729.96080.466199999999997
11230.26929.96080.308199999999996
11330.79829.96080.837199999999996
11432.67631.37357142857141.30242857142857
11532.6831.37357142857141.30642857142857
11630.73729.96080.776199999999996
11730.329.96080.339199999999998
11830.32129.96080.360199999999999
11931.28231.3735714285714-0.0915714285714309
12030.86831.3735714285714-0.505571428571432
12130.74931.3735714285714-0.624571428571432
12230.23629.96080.275199999999998
12329.9929.96080.0291999999999959
12429.42729.9608-0.533800000000003
12529.37629.9608-0.584800000000001
12630.82831.3735714285714-0.545571428571431
12730.53231.3735714285714-0.84157142857143
12829.16629.9608-0.794800000000002
12929.12429.9608-0.836800000000004
13028.90429.9608-1.05680000000000
13127.99228.4949259259259-0.502925925925922
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/20/t1292855799v00axwvc3mue6z0/2ude91292855864.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/20/t1292855799v00axwvc3mue6z0/2ude91292855864.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/20/t1292855799v00axwvc3mue6z0/3ude91292855864.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/20/t1292855799v00axwvc3mue6z0/3ude91292855864.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/20/t1292855799v00axwvc3mue6z0/4nmvu1292855864.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/20/t1292855799v00axwvc3mue6z0/4nmvu1292855864.ps (open in new window)


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