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(6.3,6.2,6.1,6.3,6.5,6.6,6.5,6.2,6.2,5.9,6.1,6.1,6.1,6.1,6.1,6.4,6.7,6.9,7,7,6.8,6.4,5.9,5.5,5.5,5.6,5.8,5.9,6.1,6.1,6,6,5.9,5.5,5.6,5.4,5.2,5.2,5.2,5.5,5.8,5.8,5.5,5.3,5.1,5.2,5.8,5.8,5.5,5,4.9,5.3,6.1,6.5,6.8,6.6,6.4,6.4) > x <- c(8.9,8.2,7.6,7.7,8.1,8.3,8.3,7.9,7.8,8,8.5,8.6,8.5,8,7.8,8,8.2,8.3,8.2,8.1,8,7.8,7.8,7.7,7.6,7.6,7.6,7.8,8,8,7.9,7.7,7.4,6.9,6.7,6.5,6.4,6.7,6.8,6.9,6.9,6.7,6.4,6.2,5.9,6.1,6.7,6.8,6.6,6.4,6.4,6.7,7.1,7.1,6.9,6.4,6,6) > #'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.5718988 0.5719940 0.5720891 0.5721839 0.5722786 0.5723731 0.5724675 [8] 0.5725616 0.5726556 0.5727493 0.5728429 0.5729363 0.5730295 0.5731225 [15] 0.5732154 0.5733080 0.5734005 0.5734928 0.5735849 0.5736768 0.5737685 [22] 0.5738600 0.5739514 0.5740426 0.5741335 0.5742243 0.5743149 0.5744053 [29] 0.5744956 0.5745856 0.5746755 0.5747651 0.5748546 0.5749439 0.5750330 [36] 0.5751219 0.5752106 0.5752991 0.5753875 0.5754756 0.5755636 0.5756514 [43] 0.5757389 0.5758263 0.5759136 0.5760006 0.5760874 0.5761740 0.5762605 [50] 0.5763467 0.5764328 0.5765187 0.5766044 0.5766899 0.5767752 0.5768603 [57] 0.5769452 0.5770299 0.5771145 0.5771988 0.5772830 0.5773669 0.5774507 [64] 0.5775343 0.5776177 0.5777009 0.5777839 0.5778667 0.5779493 0.5780317 [71] 0.5781140 0.5781960 0.5782779 0.5783595 0.5784410 0.5785222 0.5786033 [78] 0.5786842 0.5787649 0.5788454 0.5789257 0.5790058 0.5790857 0.5791654 [85] 0.5792449 0.5793243 0.5794034 0.5794824 0.5795611 0.5796397 0.5797180 [92] 0.5797962 0.5798741 0.5799519 0.5800295 0.5801069 0.5801841 0.5802610 [99] 0.5803378 0.5804144 0.5804908 0.5805670 0.5806430 0.5807189 0.5807945 [106] 0.5808699 0.5809451 0.5810201 0.5810950 0.5811696 0.5812440 0.5813183 [113] 0.5813923 0.5814662 0.5815398 0.5816133 0.5816865 0.5817596 0.5818324 [120] 0.5819051 0.5819776 0.5820498 0.5821219 0.5821937 0.5822654 0.5823369 [127] 0.5824082 0.5824792 0.5825501 0.5826208 0.5826912 0.5827615 0.5828316 [134] 0.5829015 0.5829712 0.5830406 0.5831099 0.5831790 0.5832479 0.5833165 [141] 0.5833850 0.5834533 0.5835214 0.5835893 0.5836569 0.5837244 0.5837917 [148] 0.5838588 0.5839257 0.5839923 0.5840588 0.5841251 0.5841912 0.5842570 [155] 0.5843227 0.5843882 0.5844534 0.5845185 0.5845834 0.5846480 0.5847125 [162] 0.5847768 0.5848408 0.5849047 0.5849683 0.5850318 0.5850950 0.5851581 [169] 0.5852209 0.5852836 0.5853460 0.5854082 0.5854703 0.5855321 0.5855937 [176] 0.5856552 0.5857164 0.5857774 0.5858382 0.5858988 0.5859593 0.5860195 [183] 0.5860795 0.5861393 0.5861989 0.5862582 0.5863174 0.5863764 0.5864352 [190] 0.5864938 0.5865522 0.5866103 0.5866683 0.5867260 0.5867836 0.5868409 [197] 0.5868981 0.5869550 0.5870118 0.5870683 0.5871246 0.5871807 0.5872367 [204] 0.5872924 0.5873479 0.5874032 0.5874583 0.5875132 0.5875678 0.5876223 [211] 0.5876766 0.5877307 0.5877845 0.5878382 0.5878916 0.5879449 0.5879979 [218] 0.5880507 0.5881034 0.5881558 0.5882080 0.5882600 0.5883118 0.5883634 [225] 0.5884148 0.5884660 0.5885169 0.5885677 0.5886183 0.5886686 0.5887188 [232] 0.5887687 0.5888184 0.5888680 0.5889173 0.5889664 0.5890153 0.5890640 [239] 0.5891125 0.5891607 0.5892088 0.5892567 0.5893043 0.5893518 0.5893990 [246] 0.5894461 0.5894929 0.5895395 0.5895859 0.5896321 0.5896781 0.5897239 [253] 0.5897695 0.5898148 0.5898600 0.5899049 0.5899497 0.5899942 0.5900385 [260] 0.5900827 0.5901266 0.5901703 0.5902137 0.5902570 0.5903001 0.5903430 [267] 0.5903856 0.5904281 0.5904703 0.5905123 0.5905541 0.5905957 0.5906371 [274] 0.5906783 0.5907193 0.5907601 0.5908006 0.5908410 0.5908811 0.5909210 [281] 0.5909607 0.5910003 0.5910396 0.5910786 0.5911175 0.5911562 0.5911946 [288] 0.5912329 0.5912709 0.5913088 0.5913464 0.5913838 0.5914210 0.5914580 [295] 0.5914947 0.5915313 0.5915677 0.5916038 0.5916397 0.5916754 0.5917110 [302] 0.5917463 0.5917813 0.5918162 0.5918509 0.5918853 0.5919196 0.5919536 [309] 0.5919874 0.5920211 0.5920545 0.5920876 0.5921206 0.5921534 0.5921859 [316] 0.5922183 0.5922504 0.5922823 0.5923140 0.5923455 0.5923768 0.5924079 [323] 0.5924388 0.5924694 0.5924998 0.5925301 0.5925601 0.5925899 0.5926195 [330] 0.5926488 0.5926780 0.5927070 0.5927357 0.5927642 0.5927926 0.5928207 [337] 0.5928486 0.5928762 0.5929037 0.5929310 0.5929580 0.5929848 0.5930115 [344] 0.5930379 0.5930641 0.5930900 0.5931158 0.5931414 0.5931667 0.5931918 [351] 0.5932167 0.5932415 0.5932659 0.5932902 0.5933143 0.5933381 0.5933618 [358] 0.5933852 0.5934084 0.5934314 0.5934542 0.5934768 0.5934992 0.5935213 [365] 0.5935432 0.5935650 0.5935865 0.5936078 0.5936289 0.5936497 0.5936704 [372] 0.5936908 0.5937111 0.5937311 0.5937509 0.5937705 0.5937899 0.5938090 [379] 0.5938280 0.5938467 0.5938652 0.5938836 0.5939017 0.5939195 0.5939372 [386] 0.5939547 0.5939719 0.5939889 0.5940058 0.5940224 0.5940387 0.5940549 [393] 0.5940709 0.5940866 0.5941022 0.5941175 0.5941326 0.5941475 0.5941622 [400] 0.5941766 0.5941909 > mx [1] 0.5941909 > 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/1id6o1257963102.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/2q6kq1257963102.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/3qo7s1257963102.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/4mc9a1257963102.tab") > > system("convert tmp/1id6o1257963102.ps tmp/1id6o1257963102.png") > system("convert tmp/2q6kq1257963102.ps tmp/2q6kq1257963102.png") > system("convert tmp/3qo7s1257963102.ps tmp/3qo7s1257963102.png") > > > proc.time() user system elapsed 0.795 0.503 0.940