Home » date » 2010 » Dec » 24 »

Apple Inc - Recursive Partitioning Trend

*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 13:24:35 +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/t1293197592548ust8s96hr0vp.htm/, Retrieved Fri, 24 Dec 2010 14:33:18 +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/t1293197592548ust8s96hr0vp.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 «
10.81 -0,2643 0 0 24563400 24.45 2772.73 0,0373 115.7 1 9.12 -0,2643 0 0 14163200 23.62 2151.83 0,0353 109.2 2 11.03 -0,2643 0 0 18184800 21.90 1840.26 0,0292 116.9 3 12.74 -0,1918 0 0 20810300 27.12 2116.24 0,0327 109.9 4 9.98 -0,1918 0 0 12843000 27.70 2110.49 0,0362 116.1 5 11.62 -0,1918 0 0 13866700 29.23 2160.54 0,0325 118.9 6 9.40 -0,2246 0 0 15119200 26.50 2027.13 0,0272 116.3 7 9.27 -0,2246 0 0 8301600 22.84 1805.43 0,0272 114.0 8 7.76 -0,2246 0 0 14039600 20.49 1498.80 0,0265 97.0 9 8.78 0,3654 0 0 12139700 23.28 1690.20 0,0213 85.3 10 10.65 0,3654 0 0 9649000 25.71 1930.58 0,019 84.9 11 10.95 0,3654 0 0 8513600 26.52 1950.40 0,0155 94.6 12 12.36 0,0447 0 0 15278600 25.51 1934.03 0,0114 97.8 13 10.85 0,0447 0 0 15590900 23.36 1731.49 0,0114 95.0 14 11.84 0,0447 0 0 9691100 24.15 1845.35 0,0148 110.7 15 12.14 -0,0312 0 0 10882700 20.92 1688.23 0,0164 108.5 16 11.65 -0,0312 0 0 10294800 20.38 1615.73 0,0118 110.3 17 8.86 -0,0312 0 0 16031900 21.90 1463.21 0,0107 106.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 time13 seconds
R Server'George Udny Yule' @ 72.249.76.132


Goodness of Fit
Correlation0.9756
R-squared0.9518
RMSE16.6129


Actuals, Predictions, and Residuals
#ActualsForecastsResiduals
110.8110.83-0.0199999999999978
29.1210.83-1.71
311.0310.830.200000000000001
412.7410.831.91000000000000
59.9810.83-0.849999999999998
611.6210.830.790000000000001
79.410.83-1.43000000000000
89.2710.83-1.56
97.767.666923076923080.0930769230769215
108.7810.83-2.05
1110.6510.83-0.179999999999998
1210.9510.830.120000000000001
1312.3610.831.53
1410.8510.830.0200000000000014
1511.8410.831.01000000000000
1612.1410.831.31000000000000
1711.6510.830.820000000000002
188.867.666923076923081.19307692307692
197.637.66692307692308-0.0369230769230784
207.387.66692307692308-0.286923076923078
217.257.66692307692308-0.416923076923078
228.037.666923076923080.363076923076921
237.757.666923076923080.0830769230769217
247.167.66692307692308-0.506923076923078
257.187.66692307692308-0.486923076923079
267.517.66692307692308-0.156923076923078
277.077.66692307692308-0.596923076923078
287.117.66692307692308-0.556923076923078
298.987.666923076923081.31307692307692
309.5310.83-1.3
3110.5410.83-0.289999999999999
3211.3110.830.480000000000002
3310.3610.83-0.469999999999999
3411.4410.830.610000000000001
3510.4510.83-0.379999999999999
3610.6910.83-0.139999999999999
3711.2810.830.450000000000001
3811.9610.831.13000000000000
3913.5215.6442857142857-2.12428571428571
4012.8915.6442857142857-2.75428571428571
4114.0315.6442857142857-1.61428571428571
4216.2715.64428571428570.625714285714286
4316.1715.64428571428570.525714285714288
4417.2515.64428571428571.60571428571429
4519.3815.64428571428573.73571428571429
4626.237.219-11.019
4733.5337.219-3.689
4832.237.219-5.019
4938.4537.2191.23100000000000
5044.8637.2197.641
5141.6737.2194.451
5236.0637.219-1.159
5339.7637.2192.54100000000000
5436.8137.219-0.408999999999999
5542.6537.2195.431
5646.8958.7057142857143-11.8157142857143
5753.6158.7057142857143-5.09571428571428
5857.5958.7057142857143-1.11571428571428
5967.8278.0484615384615-10.2284615384615
6071.8978.0484615384615-6.15846153846154
6175.5178.0484615384615-2.53846153846153
6268.4978.0484615384615-9.55846153846154
6362.7278.0484615384615-15.3284615384615
6470.3978.0484615384615-7.65846153846154
6559.7758.70571428571431.06428571428572
6657.2758.7057142857143-1.43571428571428
6767.9658.70571428571439.25428571428571
6867.8558.70571428571439.14428571428572
6976.9878.0484615384615-1.06846153846153
7081.0878.04846153846153.03153846153846
7191.6678.048461538461513.6115384615385
7284.8478.04846153846156.79153846153847
7385.7378.04846153846157.68153846153847
7484.6178.04846153846156.56153846153846
7592.9178.048461538461514.8615384615385
7699.8151.770476190476-51.9704761904762
77121.19151.770476190476-30.5804761904762
78122.04151.770476190476-29.7304761904762
79131.76151.770476190476-20.0104761904762
80138.48151.770476190476-13.2904761904762
81153.47151.7704761904761.69952380952384
82189.95151.77047619047638.1795238095238
83182.22151.77047619047630.4495238095238
84198.08151.77047619047646.3095238095239
85135.36151.770476190476-16.4104761904761
86125.02151.770476190476-26.7504761904762
87143.5151.770476190476-8.27047619047616
88173.95151.77047619047622.1795238095238
89188.75151.77047619047636.9795238095238
90167.44151.77047619047615.6695238095238
91158.95151.7704761904767.17952380952383
92169.53151.77047619047617.7595238095238
93113.66151.770476190476-38.1104761904762
94107.59103.976253.61374999999998
9592.67103.97625-11.3062500000000
9685.35103.97625-18.6262500000000
9790.13103.97625-13.8462500000000
9889.31103.97625-14.6662500000000
99105.12103.976251.14374999999998
100125.83103.9762521.8537500000000
101135.81103.9762531.83375
102142.43151.770476190476-9.34047619047615
103163.39151.77047619047611.6195238095238
104168.21151.77047619047616.4395238095238
105185.35228.443846153846-43.0938461538462
106188.5228.443846153846-39.9438461538462
107199.91228.443846153846-28.5338461538462
108210.73228.443846153846-17.7138461538462
109192.06228.443846153846-36.3838461538462
110204.62228.443846153846-23.8238461538461
111235228.4438461538466.55615384615385
112261.09228.44384615384632.6461538461538
113256.88228.44384615384628.4361538461538
114251.53228.44384615384623.0861538461538
115257.25228.44384615384628.8061538461538
116243.1228.44384615384614.6561538461538
117283.75228.44384615384655.3061538461538
 
Charts produced by software:
http://www.freestatistics.org/blog/date/2010/Dec/24/t1293197592548ust8s96hr0vp/2wupo1293197061.png (open in new window)
http://www.freestatistics.org/blog/date/2010/Dec/24/t1293197592548ust8s96hr0vp/2wupo1293197061.ps (open in new window)


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


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