Home » date » 2010 » Dec » 10 »

Recursive Participation - werkloosheid en consumentenvertrouwen

*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, 10 Dec 2010 13:40:23 +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/10/t1291988318ilo8t1gvrlrwg5q.htm/, Retrieved Fri, 10 Dec 2010 14:38:38 +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/10/t1291988318ilo8t1gvrlrwg5q.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 «
235.1 1 280.7 1 264.6 2 240.7 0 201.4 1 240.8 0 241.1 -1 223.8 -3 206.1 -3 174.7 -3 203.3 -4 220.5 -8 299.5 -9 347.4 -13 338.3 -18 327.7 -11 351.6 -9 396.6 -10 438.8 -13 395.6 -11 363.5 -5 378.8 -15 357 -6 369 -6 464.8 -3 479.1 -1 431.3 -3 366.5 -4 326.3 -6 355.1 0 331.6 -4 261.3 -2 249 -2 205.5 -6 235.6 -7 240.9 -6 264.9 -6 253.8 -3 232.3 -2 193.8 -5 177 -11 213.2 -11 207.2 -11 180.6 -10 188.6 -14 175.4 -8 199 -9 179.6 -5 225.8 -1 234 -2 200.2 -5 183.6 -4 178.2 -6 203.2 -2 208.5 -2 191.8 -2 172.8 -2 148 2 159.4 1 154.5 -8 213.2 -1 196.4 1 182.8 -1 176.4 2 153.6 2 173.2 1 171 -1 151.2 -2 161.9 -2 157.2 -1 201.7 -8 236.4 -4 356.1 -6 398.3 -3 403.7 -3 384.6 -7 365.8 -9 368.1 -11 367.9 -13 347 -11 343.3 -9 292.9 -17 311.5 -22 300.9 -25 366.9 -20 356.9 -24 329.7 -24 316.2 -22 269 -19 289.3 -18 266.2 -17 253.6 -11 233.8 -11 228.4 -12 253.6 -10 260.1 -15 306.6 -15 309.2 -15 309.5 -13 271 -8 279.9 -13 317.9 -9 298.4 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 time5 seconds
R Server'Sir Ronald Aylmer Fisher' @ 193.190.124.24


Goodness of Fit
Correlation0.3972
R-squared0.1578
RMSE73.3205


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
1235.1218.40967741935516.6903225806452
2280.7218.40967741935562.2903225806452
3264.6218.40967741935546.1903225806452
4240.7218.40967741935522.2903225806452
5201.4218.409677419355-17.0096774193548
6240.8218.40967741935522.3903225806452
7241.1218.40967741935522.6903225806452
8223.8288.169333333333-64.3693333333333
9206.1288.169333333333-82.0693333333333
10174.7288.169333333333-113.469333333333
11203.3288.169333333333-84.8693333333333
12220.5288.169333333333-67.6693333333333
13299.5288.16933333333311.3306666666667
14347.4288.16933333333359.2306666666667
15338.3288.16933333333350.1306666666667
16327.7288.16933333333339.5306666666667
17351.6288.16933333333363.4306666666667
18396.6288.169333333333108.430666666667
19438.8288.169333333333150.630666666667
20395.6288.169333333333107.430666666667
21363.5288.16933333333375.3306666666667
22378.8288.16933333333390.6306666666667
23357288.16933333333368.8306666666667
24369288.16933333333380.8306666666667
25464.8288.169333333333176.630666666667
26479.1218.409677419355260.690322580645
27431.3288.169333333333143.130666666667
28366.5288.16933333333378.3306666666667
29326.3288.16933333333338.1306666666667
30355.1218.409677419355136.690322580645
31331.6288.16933333333343.4306666666667
32261.3218.40967741935542.8903225806452
33249218.40967741935530.5903225806452
34205.5288.169333333333-82.6693333333333
35235.6288.169333333333-52.5693333333333
36240.9288.169333333333-47.2693333333333
37264.9288.169333333333-23.2693333333333
38253.8288.169333333333-34.3693333333333
39232.3218.40967741935513.8903225806452
40193.8288.169333333333-94.3693333333333
41177288.169333333333-111.169333333333
42213.2288.169333333333-74.9693333333333
43207.2288.169333333333-80.9693333333333
44180.6288.169333333333-107.569333333333
45188.6288.169333333333-99.5693333333333
46175.4288.169333333333-112.769333333333
47199288.169333333333-89.1693333333333
48179.6288.169333333333-108.569333333333
49225.8218.4096774193557.39032258064518
50234218.40967741935515.5903225806452
51200.2288.169333333333-87.9693333333333
52183.6288.169333333333-104.569333333333
53178.2288.169333333333-109.969333333333
54203.2218.409677419355-15.2096774193548
55208.5218.409677419355-9.90967741935484
56191.8218.409677419355-26.6096774193548
57172.8218.409677419355-45.6096774193548
58148218.409677419355-70.4096774193548
59159.4218.409677419355-59.0096774193548
60154.5288.169333333333-133.669333333333
61213.2218.409677419355-5.20967741935485
62196.4218.409677419355-22.0096774193548
63182.8218.409677419355-35.6096774193548
64176.4218.409677419355-42.0096774193548
65153.6218.409677419355-64.8096774193548
66173.2218.409677419355-45.2096774193548
67171218.409677419355-47.4096774193548
68151.2218.409677419355-67.2096774193548
69161.9218.409677419355-56.5096774193548
70157.2218.409677419355-61.2096774193548
71201.7288.169333333333-86.4693333333333
72236.4288.169333333333-51.7693333333333
73356.1288.16933333333367.9306666666667
74398.3288.169333333333110.130666666667
75403.7288.169333333333115.530666666667
76384.6288.16933333333396.4306666666667
77365.8288.16933333333377.6306666666667
78368.1288.16933333333379.9306666666667
79367.9288.16933333333379.7306666666667
80347288.16933333333358.8306666666667
81343.3288.16933333333355.1306666666667
82292.9288.1693333333334.73066666666665
83311.5288.16933333333323.3306666666667
84300.9288.16933333333312.7306666666667
85366.9288.16933333333378.7306666666667
86356.9288.16933333333368.7306666666667
87329.7288.16933333333341.5306666666667
88316.2288.16933333333328.0306666666667
89269288.169333333333-19.1693333333333
90289.3288.1693333333331.13066666666668
91266.2288.169333333333-21.9693333333333
92253.6288.169333333333-34.5693333333333
93233.8288.169333333333-54.3693333333333
94228.4288.169333333333-59.7693333333333
95253.6288.169333333333-34.5693333333333
96260.1288.169333333333-28.0693333333333
97306.6288.16933333333318.4306666666667
98309.2288.16933333333321.0306666666667
99309.5288.16933333333321.3306666666667
100271288.169333333333-17.1693333333333
101279.9288.169333333333-8.26933333333335
102317.9288.16933333333329.7306666666667
103298.4288.16933333333310.2306666666667
104246.7288.169333333333-41.4693333333333
105227.3288.169333333333-60.8693333333333
106209.1218.409677419355-9.30967741935484
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/10/t1291988318ilo8t1gvrlrwg5q/2lr0n1291988416.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/10/t1291988318ilo8t1gvrlrwg5q/2lr0n1291988416.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/10/t1291988318ilo8t1gvrlrwg5q/3lr0n1291988416.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/10/t1291988318ilo8t1gvrlrwg5q/3lr0n1291988416.ps (open in new window)


http://www.freestatistics.org/blog/date/2010/Dec/10/t1291988318ilo8t1gvrlrwg5q/4w0z81291988416.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/10/t1291988318ilo8t1gvrlrwg5q/4w0z81291988416.ps (open in new window)


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