R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(60,57,56,56,59,57,62,62,59,57,63,61,59,58,58,58,55,55,56,60,56,59,59,63,60,58,57,58,55,57,56,53,61,65,66,65,68,78,79,80,84,84,86,86,81,80,79,76,78,69,70,59,55,47,48,47,45,36,44,33,34) > x <- c(46,50,49,48,50,47,50,49,51,52,48,55,56,43,44,50,49,47,46,50,49,53,54,56,56,58,53,51,52,53,56,54,54,56,59,62,62,73,76,80,77,81,80,80,81,80,77,71,71,64,64,47,41,35,34,33,23,16,16,8,9) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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.5485231 0.5494956 0.5504748 0.5514608 0.5524535 0.5534531 0.5544595 [8] 0.5554727 0.5564929 0.5575200 0.5585541 0.5595952 0.5606433 0.5616984 [15] 0.5627607 0.5638300 0.5649065 0.5659902 0.5670810 0.5681791 0.5692844 [22] 0.5703970 0.5715169 0.5726442 0.5737787 0.5749206 0.5760700 0.5772267 [29] 0.5783908 0.5795624 0.5807415 0.5819281 0.5831222 0.5843238 0.5855329 [36] 0.5867496 0.5879738 0.5892057 0.5904451 0.5916922 0.5929468 0.5942091 [43] 0.5954791 0.5967566 0.5980419 0.5993347 0.6006353 0.6019435 0.6032594 [50] 0.6045830 0.6059142 0.6072531 0.6085997 0.6099539 0.6113158 0.6126853 [57] 0.6140625 0.6154474 0.6168399 0.6182400 0.6196477 0.6210630 0.6224859 [64] 0.6239163 0.6253543 0.6267998 0.6282528 0.6297134 0.6311813 0.6326567 [71] 0.6341396 0.6356297 0.6371273 0.6386322 0.6401443 0.6416637 0.6431903 [78] 0.6447241 0.6462650 0.6478130 0.6493681 0.6509301 0.6524991 0.6540750 [85] 0.6556578 0.6572474 0.6588437 0.6604467 0.6620564 0.6636726 0.6652953 [92] 0.6669245 0.6685600 0.6702019 0.6718500 0.6735043 0.6751647 0.6768311 [99] 0.6785034 0.6801816 0.6818656 0.6835552 0.6852505 0.6869513 0.6886576 [106] 0.6903692 0.6920860 0.6938080 0.6955350 0.6972670 0.6990038 0.7007454 [113] 0.7024916 0.7042424 0.7059975 0.7077570 0.7095207 0.7112885 0.7130602 [120] 0.7148358 0.7166151 0.7183980 0.7201844 0.7219741 0.7237670 0.7255630 [127] 0.7273620 0.7291638 0.7309683 0.7327753 0.7345847 0.7363964 0.7382103 [134] 0.7400260 0.7418437 0.7436630 0.7454838 0.7473061 0.7491295 0.7509541 [141] 0.7527795 0.7546058 0.7564326 0.7582599 0.7600875 0.7619152 0.7637429 [148] 0.7655704 0.7673976 0.7692242 0.7710502 0.7728752 0.7746993 0.7765222 [155] 0.7783437 0.7801637 0.7819820 0.7837984 0.7856128 0.7874249 0.7892347 [162] 0.7910420 0.7928465 0.7946481 0.7964466 0.7982419 0.8000337 0.8018220 [169] 0.8036065 0.8053871 0.8071635 0.8089357 0.8107035 0.8124666 0.8142249 [176] 0.8159782 0.8177264 0.8194694 0.8212068 0.8229386 0.8246646 0.8263847 [183] 0.8280986 0.8298062 0.8315073 0.8332019 0.8348897 0.8365705 0.8382442 [190] 0.8399107 0.8415698 0.8432214 0.8448652 0.8465012 0.8481292 0.8497490 [197] 0.8513605 0.8529637 0.8545582 0.8561440 0.8577210 0.8592891 0.8608480 [204] 0.8623976 0.8639379 0.8654687 0.8669899 0.8685014 0.8700029 0.8714946 [211] 0.8729761 0.8744475 0.8759085 0.8773591 0.8787992 0.8802287 0.8816475 [218] 0.8830555 0.8844526 0.8858387 0.8872137 0.8885775 0.8899301 0.8912714 [225] 0.8926013 0.8939197 0.8952265 0.8965217 0.8978053 0.8990771 0.9003371 [232] 0.9015852 0.9028214 0.9040456 0.9052579 0.9064580 0.9076461 0.9088220 [239] 0.9099857 0.9111372 0.9122764 0.9134034 0.9145180 0.9156203 0.9167103 [246] 0.9177878 0.9188530 0.9199058 0.9209462 0.9219741 0.9229896 0.9239926 [253] 0.9249832 0.9259614 0.9269272 0.9278805 0.9288214 0.9297499 0.9306660 [260] 0.9315697 0.9324611 0.9333401 0.9342068 0.9350612 0.9359034 0.9367333 [267] 0.9375510 0.9383565 0.9391499 0.9399311 0.9407004 0.9414575 0.9422027 [274] 0.9429360 0.9436573 0.9443668 0.9450645 0.9457505 0.9464248 0.9470874 [281] 0.9477384 0.9483779 0.9490059 0.9496225 0.9502278 0.9508217 0.9514044 [288] 0.9519760 0.9525364 0.9530859 0.9536243 0.9541519 0.9546686 0.9551746 [295] 0.9556699 0.9561546 0.9566287 0.9570924 0.9575456 0.9579886 0.9584213 [302] 0.9588439 0.9592564 0.9596589 0.9600514 0.9604342 0.9608071 0.9611704 [309] 0.9615240 0.9618682 0.9622029 0.9625282 0.9628442 0.9631511 0.9634489 [316] 0.9637376 0.9640174 0.9642883 0.9645505 0.9648039 0.9650488 0.9652851 [323] 0.9655130 0.9657325 0.9659437 0.9661468 0.9663418 0.9665287 0.9667077 [330] 0.9668789 0.9670423 0.9671980 0.9673461 0.9674867 0.9676198 0.9677456 [337] 0.9678641 0.9679755 0.9680797 0.9681769 0.9682672 0.9683506 0.9684272 [344] 0.9684971 0.9685604 0.9686172 0.9686675 0.9687114 0.9687490 0.9687804 [351] 0.9688056 0.9688247 0.9688379 0.9688451 0.9688465 0.9688422 0.9688321 [358] 0.9688164 0.9687952 0.9687685 0.9687364 0.9686990 0.9686563 0.9686084 [365] 0.9685554 0.9684974 0.9684344 0.9683665 0.9682937 0.9682162 0.9681340 [372] 0.9680472 0.9679557 0.9678598 0.9677594 0.9676547 0.9675457 0.9674324 [379] 0.9673149 0.9671933 0.9670676 0.9669380 0.9668044 0.9666669 0.9665256 [386] 0.9663805 0.9662317 0.9660793 0.9659233 0.9657638 0.9656008 0.9654343 [393] 0.9652645 0.9650914 0.9649150 0.9647355 0.9645527 0.9643669 0.9641780 [400] 0.9639861 0.9637912 > mx [1] 0.9688465 > mxli [1] 1.54 > 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/1yurh1258051550.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/2o81a1258051550.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/3d1ib1258051550.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 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > 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/428ws1258051550.tab") > > system("convert tmp/1yurh1258051550.ps tmp/1yurh1258051550.png") > system("convert tmp/2o81a1258051550.ps tmp/2o81a1258051550.png") > system("convert tmp/3d1ib1258051550.ps tmp/3d1ib1258051550.png") > > > proc.time() user system elapsed 0.781 0.492 0.901