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(103.1,100.6,103.1,95.5,90.5,90.9,88.8,90.7,94.3,104.6,111.1,110.8,107.2,99,99,91,96.2,96.9,96.2,100.1,99,115.4,106.9,107.1,99.3,99.2,108.3,105.6,99.5,107.4,93.1,88.1,110.7,113.1,99.6,93.6,98.6,99.6,114.3,107.8,101.2,112.5,100.5,93.9,116.2,112,106.4,95.7,96,95.8,103,102.2,98.4,111.4,86.6,91.3,107.9,101.8,104.4,93.4,100.1,98.5,112.9,101.4,107.1,110.8,90.3,95.5,111.4,113,107.5,95.9,106.3,105.2,117.2,106.9,108.2,110,96.1,100.6) > x <- c(98.6,98,106.8,96.6,100.1,107.7,91.5,97.8,107.4,117.5,105.6,97.4,99.5,98,104.3,100.6,101.1,103.9,96.9,95.5,108.4,117,103.8,100.8,110.6,104,112.6,107.3,98.9,109.8,104.9,102.2,123.9,124.9,112.7,121.9,100.6,104.3,120.4,107.5,102.9,125.6,107.5,108.8,128.4,121.1,119.5,128.7,108.7,105.5,119.8,111.3,110.6,120.1,97.5,107.7,127.3,117.2,119.8,116.2,111,112.4,130.6,109.1,118.8,123.9,101.6,112.8,128,129.6,125.8,119.5,115.7,113.6,129.7,112,116.8,126.3,112.9,115.9) > #'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.5855302 0.5856098 0.5856893 0.5857687 0.5858480 0.5859272 0.5860062 [8] 0.5860852 0.5861641 0.5862429 0.5863216 0.5864002 0.5864788 0.5865572 [15] 0.5866355 0.5867137 0.5867918 0.5868698 0.5869477 0.5870255 0.5871032 [22] 0.5871808 0.5872583 0.5873358 0.5874131 0.5874903 0.5875674 0.5876444 [29] 0.5877213 0.5877981 0.5878748 0.5879515 0.5880280 0.5881044 0.5881807 [36] 0.5882569 0.5883330 0.5884090 0.5884849 0.5885607 0.5886364 0.5887120 [43] 0.5887875 0.5888629 0.5889382 0.5890134 0.5890885 0.5891635 0.5892384 [50] 0.5893132 0.5893879 0.5894625 0.5895369 0.5896113 0.5896856 0.5897598 [57] 0.5898338 0.5899078 0.5899817 0.5900554 0.5901291 0.5902026 0.5902761 [64] 0.5903495 0.5904227 0.5904958 0.5905689 0.5906418 0.5907147 0.5907874 [71] 0.5908600 0.5909325 0.5910049 0.5910773 0.5911495 0.5912216 0.5912936 [78] 0.5913655 0.5914373 0.5915090 0.5915805 0.5916520 0.5917234 0.5917947 [85] 0.5918658 0.5919369 0.5920078 0.5920787 0.5921494 0.5922201 0.5922906 [92] 0.5923610 0.5924313 0.5925016 0.5925717 0.5926417 0.5927116 0.5927814 [99] 0.5928510 0.5929206 0.5929901 0.5930595 0.5931287 0.5931979 0.5932669 [106] 0.5933359 0.5934047 0.5934734 0.5935420 0.5936106 0.5936790 0.5937473 [113] 0.5938155 0.5938835 0.5939515 0.5940194 0.5940872 0.5941548 0.5942224 [120] 0.5942898 0.5943571 0.5944244 0.5944915 0.5945585 0.5946254 0.5946922 [127] 0.5947589 0.5948255 0.5948919 0.5949583 0.5950245 0.5950907 0.5951567 [134] 0.5952227 0.5952885 0.5953542 0.5954198 0.5954853 0.5955507 0.5956159 [141] 0.5956811 0.5957462 0.5958111 0.5958759 0.5959407 0.5960053 0.5960698 [148] 0.5961342 0.5961985 0.5962627 0.5963267 0.5963907 0.5964546 0.5965183 [155] 0.5965819 0.5966455 0.5967089 0.5967722 0.5968354 0.5968984 0.5969614 [162] 0.5970243 0.5970870 0.5971497 0.5972122 0.5972746 0.5973369 0.5973991 [169] 0.5974612 0.5975232 0.5975850 0.5976468 0.5977084 0.5977700 0.5978314 [176] 0.5978927 0.5979539 0.5980150 0.5980760 0.5981368 0.5981976 0.5982582 [183] 0.5983187 0.5983792 0.5984395 0.5984997 0.5985597 0.5986197 0.5986796 [190] 0.5987393 0.5987990 0.5988585 0.5989179 0.5989772 0.5990364 0.5990954 [197] 0.5991544 0.5992133 0.5992720 0.5993306 0.5993891 0.5994475 0.5995058 [204] 0.5995640 0.5996220 0.5996800 0.5997378 0.5997955 0.5998532 0.5999107 [211] 0.5999680 0.6000253 0.6000825 0.6001395 0.6001964 0.6002533 0.6003100 [218] 0.6003665 0.6004230 0.6004794 0.6005356 0.6005918 0.6006478 0.6007037 [225] 0.6007595 0.6008152 0.6008707 0.6009262 0.6009815 0.6010368 0.6010919 [232] 0.6011469 0.6012018 0.6012565 0.6013112 0.6013657 0.6014202 0.6014745 [239] 0.6015287 0.6015828 0.6016367 0.6016906 0.6017443 0.6017980 0.6018515 [246] 0.6019049 0.6019581 0.6020113 0.6020644 0.6021173 0.6021701 0.6022228 [253] 0.6022754 0.6023279 0.6023803 0.6024325 0.6024847 0.6025367 0.6025886 [260] 0.6026404 0.6026921 0.6027436 0.6027951 0.6028464 0.6028976 0.6029487 [267] 0.6029997 0.6030506 0.6031013 0.6031520 0.6032025 0.6032529 0.6033032 [274] 0.6033534 0.6034034 0.6034534 0.6035032 0.6035529 0.6036025 0.6036520 [281] 0.6037013 0.6037506 0.6037997 0.6038488 0.6038977 0.6039464 0.6039951 [288] 0.6040437 0.6040921 0.6041404 0.6041886 0.6042367 0.6042847 0.6043326 [295] 0.6043803 0.6044279 0.6044754 0.6045228 0.6045701 0.6046173 0.6046643 [302] 0.6047113 0.6047581 0.6048048 0.6048513 0.6048978 0.6049442 0.6049904 [309] 0.6050365 0.6050825 0.6051284 0.6051742 0.6052198 0.6052653 0.6053108 [316] 0.6053561 0.6054012 0.6054463 0.6054913 0.6055361 0.6055808 0.6056254 [323] 0.6056699 0.6057143 0.6057585 0.6058026 0.6058467 0.6058906 0.6059343 [330] 0.6059780 0.6060215 0.6060650 0.6061083 0.6061515 0.6061946 0.6062375 [337] 0.6062804 0.6063231 0.6063657 0.6064082 0.6064506 0.6064929 0.6065350 [344] 0.6065770 0.6066190 0.6066608 0.6067024 0.6067440 0.6067854 0.6068268 [351] 0.6068680 0.6069091 0.6069500 0.6069909 0.6070316 0.6070723 0.6071128 [358] 0.6071532 0.6071934 0.6072336 0.6072736 0.6073136 0.6073534 0.6073930 [365] 0.6074326 0.6074721 0.6075114 0.6075506 0.6075897 0.6076287 0.6076676 [372] 0.6077063 0.6077450 0.6077835 0.6078219 0.6078602 0.6078983 0.6079364 [379] 0.6079743 0.6080121 0.6080498 0.6080874 0.6081248 0.6081622 0.6081994 [386] 0.6082365 0.6082735 0.6083104 0.6083471 0.6083838 0.6084203 0.6084567 [393] 0.6084930 0.6085292 0.6085652 0.6086012 0.6086370 0.6086727 0.6087083 [400] 0.6087437 0.6087791 > mx [1] 0.6087791 > 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/1fmiu1194695183.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/2qo3y1194695183.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/3yyus1194695183.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/46j1t1194695183.tab") > > system("convert tmp/1fmiu1194695183.ps tmp/1fmiu1194695183.png") > system("convert tmp/2qo3y1194695183.ps tmp/2qo3y1194695183.png") > system("convert tmp/3yyus1194695183.ps tmp/3yyus1194695183.png") > > > proc.time() user system elapsed 1.054 0.546 1.306