R version 2.7.2 (2008-08-25) Copyright (C) 2008 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(10165,269,708,1362,2271,3516,4775,6334,6150,7794,8851,9721,9676,402,1046,1743,2711,3817,4128,5505,4921,6091,7263,8035,7828,296,500,1134,2061,2737,2959,4113,3494,4518,5470,5664,4717,606,615,1062,983,340,467,1580,804,1709,2335,2832,2582) > x <- c(10165,269,708,1362,2271,3516,4775,6334,6150,7794,8851,9721,9676,402,1046,1743,2711,3817,4128,5505,4921,6091,7263,8035,7828,296,500,1134,2061,2737,2959,4113,3494,4518,5470,5664,4717,606,615,1062,983,340,467,1580,804,1709,2335,2832,2582) > #'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.4952795 0.4965698 0.4978687 0.4991761 0.5004922 0.5018170 0.5031506 [8] 0.5044930 0.5058443 0.5072045 0.5085737 0.5099520 0.5113394 0.5127360 [15] 0.5141417 0.5155568 0.5169812 0.5184150 0.5198582 0.5213109 0.5227732 [22] 0.5242451 0.5257267 0.5272179 0.5287190 0.5302298 0.5317505 0.5332812 [29] 0.5348218 0.5363725 0.5379332 0.5395041 0.5410851 0.5426763 0.5442778 [36] 0.5458896 0.5475118 0.5491443 0.5507873 0.5524408 0.5541048 0.5557793 [43] 0.5574644 0.5591602 0.5608667 0.5625838 0.5643117 0.5660504 0.5677999 [50] 0.5695602 0.5713314 0.5731134 0.5749064 0.5767103 0.5785251 0.5803509 [57] 0.5821877 0.5840355 0.5858943 0.5877642 0.5896451 0.5915370 0.5934400 [64] 0.5953541 0.5972792 0.5992154 0.6011626 0.6031208 0.6050901 0.6070704 [71] 0.6090618 0.6110641 0.6130774 0.6151016 0.6171368 0.6191828 0.6212397 [78] 0.6233075 0.6253860 0.6274753 0.6295753 0.6316860 0.6338073 0.6359391 [85] 0.6380814 0.6402341 0.6423973 0.6445707 0.6467543 0.6489481 0.6511520 [92] 0.6533658 0.6555895 0.6578231 0.6600663 0.6623192 0.6645815 0.6668533 [99] 0.6691343 0.6714245 0.6737237 0.6760318 0.6783487 0.6806743 0.6830083 [106] 0.6853507 0.6877013 0.6900600 0.6924265 0.6948008 0.6971827 0.6995719 [113] 0.7019683 0.7043718 0.7067821 0.7091991 0.7116225 0.7140522 0.7164879 [120] 0.7189294 0.7213765 0.7238291 0.7262868 0.7287494 0.7312168 0.7336886 [127] 0.7361647 0.7386447 0.7411284 0.7436156 0.7461060 0.7485993 0.7510953 [134] 0.7535937 0.7560942 0.7585965 0.7611004 0.7636055 0.7661116 0.7686183 [141] 0.7711254 0.7736326 0.7761394 0.7786458 0.7811512 0.7836555 0.7861582 [148] 0.7886591 0.7911578 0.7936540 0.7961475 0.7986377 0.8011245 0.8036074 [155] 0.8060862 0.8085604 0.8110298 0.8134941 0.8159528 0.8184056 0.8208522 [162] 0.8232922 0.8257254 0.8281512 0.8305695 0.8329799 0.8353819 0.8377753 [169] 0.8401598 0.8425349 0.8449004 0.8472559 0.8496010 0.8519355 0.8542590 [176] 0.8565711 0.8588716 0.8611601 0.8634363 0.8656999 0.8679505 0.8701878 [183] 0.8724116 0.8746215 0.8768172 0.8789984 0.8811648 0.8833162 0.8854522 [190] 0.8875726 0.8896770 0.8917653 0.8938371 0.8958922 0.8979304 0.8999513 [197] 0.9019548 0.9039406 0.9059084 0.9078581 0.9097894 0.9117021 0.9135960 [204] 0.9154709 0.9173265 0.9191629 0.9209796 0.9227766 0.9245536 0.9263106 [211] 0.9280474 0.9297638 0.9314596 0.9331348 0.9347892 0.9364228 0.9380352 [218] 0.9396266 0.9411968 0.9427456 0.9442730 0.9457789 0.9472633 0.9487261 [225] 0.9501672 0.9515865 0.9529841 0.9543599 0.9557138 0.9570458 0.9583560 [232] 0.9596443 0.9609106 0.9621550 0.9633776 0.9645782 0.9657570 0.9669140 [239] 0.9680491 0.9691624 0.9702540 0.9713239 0.9723722 0.9733989 0.9744041 [246] 0.9753878 0.9763501 0.9772912 0.9782110 0.9791097 0.9799874 0.9808441 [253] 0.9816800 0.9824951 0.9832896 0.9840636 0.9848172 0.9855505 0.9862637 [260] 0.9869568 0.9876300 0.9882834 0.9889172 0.9895315 0.9901265 0.9907022 [267] 0.9912589 0.9917966 0.9923156 0.9928160 0.9932979 0.9937615 0.9942070 [274] 0.9946345 0.9950442 0.9954362 0.9958108 0.9961680 0.9965080 0.9968311 [281] 0.9971374 0.9974271 0.9977002 0.9979571 0.9981978 0.9984227 0.9986317 [288] 0.9988251 0.9990031 0.9991659 0.9993135 0.9994463 0.9995644 0.9996679 [295] 0.9997571 0.9998320 0.9998930 0.9999401 0.9999735 0.9999934 1.0000000 [302] 0.9999935 0.9999739 0.9999416 0.9998966 0.9998392 0.9997695 0.9996877 [309] 0.9995939 0.9994883 0.9993711 0.9992424 0.9991024 0.9989514 0.9987893 [316] 0.9986164 0.9984329 0.9982389 0.9980346 0.9978201 0.9975956 0.9973612 [323] 0.9971171 0.9968634 0.9966003 0.9963280 0.9960466 0.9957561 0.9954569 [330] 0.9951490 0.9948325 0.9945077 0.9941746 0.9938333 0.9934841 0.9931271 [337] 0.9927623 0.9923899 0.9920101 0.9916230 0.9912287 0.9908273 0.9904189 [344] 0.9900038 0.9895819 0.9891535 0.9887186 0.9882774 0.9878300 0.9873765 [351] 0.9869169 0.9864515 0.9859804 0.9855035 0.9850212 0.9845334 0.9840402 [358] 0.9835418 0.9830383 0.9825298 0.9820163 0.9814980 0.9809750 0.9804474 [365] 0.9799152 0.9793786 0.9788376 0.9782923 0.9777429 0.9771894 0.9766320 [372] 0.9760706 0.9755054 0.9749364 0.9743638 0.9737876 0.9732080 0.9726249 [379] 0.9720385 0.9714488 0.9708560 0.9702600 0.9696610 0.9690591 0.9684543 [386] 0.9678466 0.9672362 0.9666231 0.9660074 0.9653892 0.9647685 0.9641454 [393] 0.9635199 0.9628921 0.9622621 0.9616299 0.9609957 0.9603594 0.9597210 [400] 0.9590808 0.9584387 > mx [1] 1 > mxli [1] 1 > 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/1trmd1226616071.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/2qqwj1226616071.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/3ioek1226616071.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/4zuzz1226616071.tab") > > system("convert tmp/1trmd1226616071.ps tmp/1trmd1226616071.png") > system("convert tmp/2qqwj1226616071.ps tmp/2qqwj1226616071.png") > system("convert tmp/3ioek1226616071.ps tmp/3ioek1226616071.png") > > > proc.time() user system elapsed 1.185 0.572 3.049