R version 2.6.0 (2007-10-03) Copyright (C) 2007 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > y <- c(6.5,6.4,6.2,6.2,6.3,7.5,7.4,7.4,7.4,7.4,7.4,7.2,7.2,7.2,7.5,7.4,7.4,8,8.1,8.1,8.1,8.1,8.1,7.9,7.9,8,8.1,8.1,8.1,8.5,8.5,8.6,8.4,8.4,8.4,7.7,7.8,7.9,8.7,8.8,8.8,8.5,8.5,8.5,8.4,8.5,8.5,8.3,8.4,8.4,8.4,8.4,8.4,8.5,8.5,8.5,8.5,8.5,8.5,8.3,8.3,8.4,8.2,8.2,8.1,8.1,8,7.8,7.9,7.8,7.7,7.9,7.8) > x <- c(7.8,7.8,7.8,7.8,7.8,7.9,7.9,7.9,8,8,8,8.1,8.1,8.2,8.3,8.3,8.4,8.4,8.5,8.5,8.6,8.7,8.7,8.7,8.7,8.8,8.7,8.7,8.8,8.8,8.8,8.8,8.8,8.8,8.8,8.9,8.9,8.9,8.9,8.9,8.9,8.9,8.9,9,9,9,9.1,9,9,9,8.9,8.9,8.9,8.8,8.8,8.7,8.7,8.7,8.6,8.5,8.4,8.3,8.2,8.2,8.1,8,8,7.9,7.7,7.7,7.6,7.5,7.5) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2007), Box-Cox Linearity Plot (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxlin.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description > n <- length(x) > c <- array(NA,dim=c(401)) > l <- array(NA,dim=c(401)) > mx <- 0 > mxli <- -999 > for (i in 1:401) + { + l[i] <- (i-201)/100 + if (l[i] != 0) + { + x1 <- (x^l[i] - 1) / l[i] + } else { + x1 <- log(x) + } + c[i] <- cor(x1,y) + if (mx < abs(c[i])) + { + mx <- abs(c[i]) + mxli <- l[i] + } + } > c [1] 0.7004797 0.7005116 0.7005433 0.7005751 0.7006067 0.7006383 0.7006699 [8] 0.7007013 0.7007328 0.7007641 0.7007954 0.7008267 0.7008578 0.7008890 [15] 0.7009200 0.7009510 0.7009820 0.7010129 0.7010437 0.7010744 0.7011051 [22] 0.7011358 0.7011664 0.7011969 0.7012274 0.7012578 0.7012881 0.7013184 [29] 0.7013486 0.7013788 0.7014089 0.7014390 0.7014690 0.7014989 0.7015288 [36] 0.7015586 0.7015883 0.7016180 0.7016476 0.7016772 0.7017067 0.7017362 [43] 0.7017656 0.7017949 0.7018242 0.7018534 0.7018826 0.7019117 0.7019407 [50] 0.7019697 0.7019986 0.7020275 0.7020563 0.7020850 0.7021137 0.7021423 [57] 0.7021709 0.7021994 0.7022278 0.7022562 0.7022846 0.7023128 0.7023410 [64] 0.7023692 0.7023973 0.7024253 0.7024533 0.7024812 0.7025091 0.7025369 [71] 0.7025646 0.7025923 0.7026199 0.7026475 0.7026750 0.7027024 0.7027298 [78] 0.7027571 0.7027844 0.7028116 0.7028387 0.7028658 0.7028929 0.7029198 [85] 0.7029467 0.7029736 0.7030004 0.7030271 0.7030538 0.7030804 0.7031070 [92] 0.7031335 0.7031599 0.7031863 0.7032127 0.7032389 0.7032651 0.7032913 [99] 0.7033174 0.7033434 0.7033694 0.7033953 0.7034212 0.7034470 0.7034727 [106] 0.7034984 0.7035240 0.7035496 0.7035751 0.7036005 0.7036259 0.7036512 [113] 0.7036765 0.7037017 0.7037269 0.7037520 0.7037770 0.7038020 0.7038269 [120] 0.7038518 0.7038766 0.7039014 0.7039260 0.7039507 0.7039753 0.7039998 [127] 0.7040242 0.7040486 0.7040730 0.7040973 0.7041215 0.7041456 0.7041698 [134] 0.7041938 0.7042178 0.7042417 0.7042656 0.7042894 0.7043132 0.7043369 [141] 0.7043605 0.7043841 0.7044077 0.7044311 0.7044545 0.7044779 0.7045012 [148] 0.7045244 0.7045476 0.7045707 0.7045938 0.7046168 0.7046398 0.7046627 [155] 0.7046855 0.7047083 0.7047310 0.7047537 0.7047763 0.7047988 0.7048213 [162] 0.7048437 0.7048661 0.7048884 0.7049107 0.7049329 0.7049550 0.7049771 [169] 0.7049991 0.7050211 0.7050430 0.7050649 0.7050867 0.7051084 0.7051301 [176] 0.7051517 0.7051733 0.7051948 0.7052163 0.7052377 0.7052590 0.7052803 [183] 0.7053015 0.7053227 0.7053438 0.7053649 0.7053859 0.7054068 0.7054277 [190] 0.7054485 0.7054693 0.7054900 0.7055106 0.7055312 0.7055518 0.7055723 [197] 0.7055927 0.7056131 0.7056334 0.7056536 0.7056738 0.7056940 0.7057141 [204] 0.7057341 0.7057541 0.7057740 0.7057938 0.7058136 0.7058334 0.7058531 [211] 0.7058727 0.7058923 0.7059118 0.7059312 0.7059506 0.7059700 0.7059893 [218] 0.7060085 0.7060277 0.7060468 0.7060659 0.7060849 0.7061038 0.7061227 [225] 0.7061416 0.7061603 0.7061791 0.7061977 0.7062163 0.7062349 0.7062534 [232] 0.7062718 0.7062902 0.7063086 0.7063268 0.7063450 0.7063632 0.7063813 [239] 0.7063994 0.7064173 0.7064353 0.7064532 0.7064710 0.7064887 0.7065065 [246] 0.7065241 0.7065417 0.7065593 0.7065767 0.7065942 0.7066115 0.7066289 [253] 0.7066461 0.7066633 0.7066805 0.7066976 0.7067146 0.7067316 0.7067485 [260] 0.7067654 0.7067822 0.7067990 0.7068157 0.7068323 0.7068489 0.7068654 [267] 0.7068819 0.7068983 0.7069147 0.7069310 0.7069473 0.7069635 0.7069796 [274] 0.7069957 0.7070118 0.7070277 0.7070437 0.7070595 0.7070753 0.7070911 [281] 0.7071068 0.7071224 0.7071380 0.7071536 0.7071691 0.7071845 0.7071998 [288] 0.7072152 0.7072304 0.7072456 0.7072608 0.7072759 0.7072909 0.7073059 [295] 0.7073208 0.7073357 0.7073505 0.7073653 0.7073800 0.7073946 0.7074092 [302] 0.7074238 0.7074382 0.7074527 0.7074671 0.7074814 0.7074956 0.7075099 [309] 0.7075240 0.7075381 0.7075522 0.7075661 0.7075801 0.7075940 0.7076078 [316] 0.7076216 0.7076353 0.7076490 0.7076626 0.7076761 0.7076896 0.7077031 [323] 0.7077164 0.7077298 0.7077431 0.7077563 0.7077695 0.7077826 0.7077956 [330] 0.7078086 0.7078216 0.7078345 0.7078473 0.7078601 0.7078729 0.7078856 [337] 0.7078982 0.7079108 0.7079233 0.7079357 0.7079481 0.7079605 0.7079728 [344] 0.7079850 0.7079972 0.7080094 0.7080215 0.7080335 0.7080455 0.7080574 [351] 0.7080693 0.7080811 0.7080928 0.7081045 0.7081162 0.7081278 0.7081393 [358] 0.7081508 0.7081623 0.7081736 0.7081850 0.7081963 0.7082075 0.7082186 [365] 0.7082298 0.7082408 0.7082518 0.7082628 0.7082737 0.7082845 0.7082953 [372] 0.7083060 0.7083167 0.7083274 0.7083379 0.7083485 0.7083589 0.7083694 [379] 0.7083797 0.7083900 0.7084003 0.7084105 0.7084206 0.7084307 0.7084408 [386] 0.7084508 0.7084607 0.7084706 0.7084804 0.7084902 0.7084999 0.7085096 [393] 0.7085192 0.7085288 0.7085383 0.7085477 0.7085571 0.7085665 0.7085758 [400] 0.7085850 0.7085942 > mx [1] 0.7085942 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > r<-lm(y~x) > se <- sqrt(var(r$residuals)) > r1 <- lm(y~x1) > se1 <- sqrt(var(r1$residuals)) > postscript(file="/var/www/html/rcomp/tmp/1r6rc1194287144.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(l,c,main='Box-Cox Linearity Plot',xlab='Lambda',ylab='correlation') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/27be61194287144.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x,y,main='Linear Fit of Original Data',xlab='x',ylab='y') > abline(r) > grid() > mtext(paste('Residual Standard Deviation = ',se)) > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/39lha1194287145.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x1,y,main='Linear Fit of Transformed Data',xlab='x',ylab='y') > abline(r1) > grid() > mtext(paste('Residual Standard Deviation = ',se1)) > dev.off() null device 1 > load(file='/var/www/html/rcomp/createtable') > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Box-Cox Linearity Plot',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'# observations x',header=TRUE) > a<-table.element(a,n) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'maximum correlation',header=TRUE) > a<-table.element(a,mx) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'optimal lambda(x)',header=TRUE) > a<-table.element(a,mxli) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Residual SD (orginial)',header=TRUE) > a<-table.element(a,se) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Residual SD (transformed)',header=TRUE) > a<-table.element(a,se1) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/4kegi1194287145.tab") > > system("convert tmp/1r6rc1194287144.ps tmp/1r6rc1194287144.png") > system("convert tmp/27be61194287144.ps tmp/27be61194287144.png") > system("convert tmp/39lha1194287145.ps tmp/39lha1194287145.png") > > > proc.time() user system elapsed 1.094 0.527 1.208