Home » date » 2010 » Dec » 11 »

p_Stress_RP1

*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 13:00: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/t12920748315macddk4ldwivjn.htm/, Retrieved Sat, 11 Dec 2010 14:40:34 +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/t12920748315macddk4ldwivjn.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 «
23 10 53 7 12 2 4 0 0 21 6 86 4 11 4 3 0 0 21 13 66 6 14 7 5 0 0 21 12 67 5 12 3 3 0 1 24 8 76 4 21 7 6 0 0 22 6 78 3 12 2 5 0 0 21 10 53 5 22 7 6 0 0 22 10 80 6 11 2 6 0 0 21 9 74 5 10 1 5 0 0 20 9 76 6 13 2 5 0 0 22 7 79 7 10 6 3 0 1 21 5 54 6 8 1 5 0 0 21 14 67 7 15 1 7 0 1 23 6 87 6 10 1 5 0 0 22 10 58 4 14 2 5 0 1 23 10 75 6 14 2 3 0 1 22 7 88 4 11 2 5 0 0 24 10 64 5 10 1 6 0 1 23 8 57 3 13 7 5 0 0 21 6 66 3 7 1 2 0 1 23 10 54 4 12 2 5 0 0 23 12 56 5 14 4 4 0 0 21 7 86 3 11 2 6 0 1 20 15 80 7 9 1 3 0 0 32 8 76 7 11 1 5 0 1 22 10 69 4 15 5 4 0 0 21 13 67 4 13 2 5 0 1 21 8 80 5 9 1 2 0 0 21 11 54 6 15 3 2 0 1 22 7 71 5 10 1 5 0 0 21 9 84 4 11 2 2 0 0 21 10 74 6 13 5 2 0 1 21 8 71 5 8 2 2 0 1 22 15 63 5 20 6 5 0 1 21 9 71 6 12 4 5 0 1 21 7 76 2 10 1 1 0 0 21 11 69 6 10 3 5 0 1 21 9 74 7 9 6 2 0 1 23 8 75 5 14 7 6 0 0 21 8 54 5 8 4 1 0 1 23 12 69 5 11 5 3 0 0 23 13 68 6 13 3 2 0 0 21 9 75 4 11 2 5 0 0 21 11 75 6 11 2 3 0 1 20 8 72 5 10 2 4 0 0 21 10 67 5 14 2 3 0 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 time6 seconds
R Server'Gwilym Jenkins' @ 72.249.127.135


Goodness of Fit
Correlation0.5063
R-squared0.2563
RMSE2.0507


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
1109.279279279279280.72072072072072
269.27927927927928-3.27927927927928
3139.279279279279283.72072072072072
4129.279279279279282.72072072072072
5812.1935483870968-4.19354838709677
669.27927927927928-3.27927927927928
71012.1935483870968-2.19354838709677
8109.279279279279280.72072072072072
999.27927927927928-0.279279279279280
1099.27927927927928-0.279279279279280
1179.27927927927928-2.27927927927928
1259.27927927927928-4.27927927927928
131412.19354838709681.80645161290323
1469.27927927927928-3.27927927927928
15109.279279279279280.72072072072072
16109.279279279279280.72072072072072
1779.27927927927928-2.27927927927928
18109.279279279279280.72072072072072
1989.27927927927928-1.27927927927928
2069.27927927927928-3.27927927927928
21109.279279279279280.72072072072072
22129.279279279279282.72072072072072
2379.27927927927928-2.27927927927928
24159.279279279279285.72072072072072
2589.27927927927928-1.27927927927928
261012.1935483870968-2.19354838709677
27139.279279279279283.72072072072072
2889.27927927927928-1.27927927927928
291112.1935483870968-1.19354838709677
3079.27927927927928-2.27927927927928
3199.27927927927928-0.279279279279280
32109.279279279279280.72072072072072
3389.27927927927928-1.27927927927928
341512.19354838709682.80645161290323
3599.27927927927928-0.279279279279280
3679.27927927927928-2.27927927927928
37119.279279279279281.72072072072072
3899.27927927927928-0.279279279279280
3989.27927927927928-1.27927927927928
4089.27927927927928-1.27927927927928
41129.279279279279282.72072072072072
42139.279279279279283.72072072072072
4399.27927927927928-0.279279279279280
44119.279279279279281.72072072072072
4589.27927927927928-1.27927927927928
46109.279279279279280.72072072072072
471312.19354838709680.806451612903226
48129.279279279279282.72072072072072
49129.279279279279282.72072072072072
5099.27927927927928-0.279279279279280
5189.27927927927928-1.27927927927928
5299.27927927927928-0.279279279279280
53129.279279279279282.72072072072072
541212.1935483870968-0.193548387096774
551612.19354838709683.80645161290323
56119.279279279279281.72072072072072
57139.279279279279283.72072072072072
58109.279279279279280.72072072072072
5999.27927927927928-0.279279279279280
60149.279279279279284.72072072072072
611312.19354838709680.806451612903226
62129.279279279279282.72072072072072
6399.27927927927928-0.279279279279280
6499.27927927927928-0.279279279279280
65109.279279279279280.72072072072072
66812.1935483870968-4.19354838709677
6799.27927927927928-0.279279279279280
6899.27927927927928-0.279279279279280
69119.279279279279281.72072072072072
7079.27927927927928-2.27927927927928
711112.1935483870968-1.19354838709677
7299.27927927927928-0.279279279279280
73119.279279279279281.72072072072072
7499.27927927927928-0.279279279279280
7589.27927927927928-1.27927927927928
7699.27927927927928-0.279279279279280
7789.27927927927928-1.27927927927928
7899.27927927927928-0.279279279279280
79109.279279279279280.72072072072072
8099.27927927927928-0.279279279279280
811712.19354838709684.80645161290323
8279.27927927927928-2.27927927927928
831112.1935483870968-1.19354838709677
8499.27927927927928-0.279279279279280
851012.1935483870968-2.19354838709677
86119.279279279279281.72072072072072
8789.27927927927928-1.27927927927928
881212.1935483870968-0.193548387096774
89109.279279279279280.72072072072072
9079.27927927927928-2.27927927927928
9199.27927927927928-0.279279279279280
9279.27927927927928-2.27927927927928
931212.1935483870968-0.193548387096774
9489.27927927927928-1.27927927927928
95139.279279279279283.72072072072072
96912.1935483870968-3.19354838709677
971512.19354838709682.80645161290323
9889.27927927927928-1.27927927927928
991412.19354838709681.80645161290323
1001412.19354838709681.80645161290323
10199.27927927927928-0.279279279279280
1021312.19354838709680.806451612903226
103119.279279279279281.72072072072072
1041012.1935483870968-2.19354838709677
10569.27927927927928-3.27927927927928
10689.27927927927928-1.27927927927928
107109.279279279279280.72072072072072
108109.279279279279280.72072072072072
1091012.1935483870968-2.19354838709677
1101212.1935483870968-0.193548387096774
111109.279279279279280.72072072072072
11299.27927927927928-0.279279279279280
11399.27927927927928-0.279279279279280
114119.279279279279281.72072072072072
11579.27927927927928-2.27927927927928
11679.27927927927928-2.27927927927928
11759.27927927927928-4.27927927927928
11899.27927927927928-0.279279279279280
119119.279279279279281.72072072072072
1201512.19354838709682.80645161290323
12199.27927927927928-0.279279279279280
12299.27927927927928-0.279279279279280
12389.27927927927928-1.27927927927928
1241312.19354838709680.806451612903226
125109.279279279279280.72072072072072
1261312.19354838709680.806451612903226
12799.27927927927928-0.279279279279280
128119.279279279279281.72072072072072
12989.27927927927928-1.27927927927928
130109.279279279279280.72072072072072
13199.27927927927928-0.279279279279280
13289.27927927927928-1.27927927927928
13389.27927927927928-1.27927927927928
134139.279279279279283.72072072072072
1351112.1935483870968-1.19354838709677
13689.27927927927928-1.27927927927928
137129.279279279279282.72072072072072
1381512.19354838709682.80645161290323
1391112.1935483870968-1.19354838709677
140109.279279279279280.72072072072072
14159.27927927927928-4.27927927927928
142119.279279279279281.72072072072072
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/11/t12920748315macddk4ldwivjn/2jabi1292072433.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/11/t12920748315macddk4ldwivjn/2jabi1292072433.ps (open in new window)


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


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