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(79,106,101,104,97,93,99,116,104,99,109,93,91,111,105,114,103,105,106,125,103,114,123,102,101,121,120,119,102,118,114,130,113,119,129,116,110,124,133,129,105,127,127,128,133,122,141,127,110,136,132,110,97,96,98,106,98,94,107,98) > x <- c(82,106,97,102,102,91,101,117,102,101,109,89,95,114,103,120,116,109,111,132,106,115,119,104,107,123,120,124,106,116,115,133,112,118,126,116,112,124,136,134,118,128,130,133,137,122,145,128,115,136,134,117,102,95,98,109,99,94,109,98) > #'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.9401735 0.9403531 0.9405321 0.9407105 0.9408884 0.9410657 0.9412424 [8] 0.9414186 0.9415941 0.9417692 0.9419436 0.9421175 0.9422908 0.9424635 [15] 0.9426357 0.9428073 0.9429783 0.9431487 0.9433186 0.9434879 0.9436567 [22] 0.9438248 0.9439924 0.9441594 0.9443259 0.9444917 0.9446570 0.9448218 [29] 0.9449859 0.9451495 0.9453125 0.9454750 0.9456368 0.9457981 0.9459589 [36] 0.9461190 0.9462786 0.9464376 0.9465960 0.9467539 0.9469112 0.9470679 [43] 0.9472241 0.9473796 0.9475346 0.9476891 0.9478429 0.9479962 0.9481489 [50] 0.9483011 0.9484526 0.9486036 0.9487540 0.9489039 0.9490532 0.9492019 [57] 0.9493500 0.9494976 0.9496446 0.9497910 0.9499368 0.9500821 0.9502268 [64] 0.9503710 0.9505145 0.9506575 0.9507999 0.9509418 0.9510830 0.9512237 [71] 0.9513639 0.9515034 0.9516424 0.9517808 0.9519187 0.9520560 0.9521927 [78] 0.9523288 0.9524644 0.9525994 0.9527338 0.9528676 0.9530009 0.9531336 [85] 0.9532658 0.9533974 0.9535284 0.9536588 0.9537887 0.9539180 0.9540467 [92] 0.9541748 0.9543024 0.9544294 0.9545559 0.9546818 0.9548071 0.9549318 [99] 0.9550560 0.9551796 0.9553027 0.9554251 0.9555470 0.9556684 0.9557891 [106] 0.9559093 0.9560290 0.9561481 0.9562666 0.9563845 0.9565019 0.9566187 [113] 0.9567349 0.9568506 0.9569657 0.9570802 0.9571942 0.9573076 0.9574205 [120] 0.9575328 0.9576445 0.9577556 0.9578662 0.9579762 0.9580857 0.9581946 [127] 0.9583029 0.9584107 0.9585179 0.9586246 0.9587307 0.9588362 0.9589411 [134] 0.9590455 0.9591494 0.9592527 0.9593554 0.9594575 0.9595591 0.9596602 [141] 0.9597606 0.9598606 0.9599599 0.9600587 0.9601570 0.9602546 0.9603518 [148] 0.9604483 0.9605443 0.9606398 0.9607347 0.9608290 0.9609228 0.9610160 [155] 0.9611086 0.9612008 0.9612923 0.9613833 0.9614737 0.9615636 0.9616530 [162] 0.9617417 0.9618300 0.9619176 0.9620047 0.9620913 0.9621773 0.9622628 [169] 0.9623477 0.9624320 0.9625158 0.9625991 0.9626818 0.9627639 0.9628455 [176] 0.9629265 0.9630070 0.9630870 0.9631664 0.9632452 0.9633235 0.9634013 [183] 0.9634785 0.9635551 0.9636312 0.9637068 0.9637818 0.9638563 0.9639302 [190] 0.9640036 0.9640764 0.9641487 0.9642204 0.9642916 0.9643623 0.9644324 [197] 0.9645019 0.9645709 0.9646394 0.9647074 0.9647748 0.9648416 0.9649079 [204] 0.9649737 0.9650389 0.9651036 0.9651678 0.9652314 0.9652944 0.9653570 [211] 0.9654190 0.9654804 0.9655413 0.9656017 0.9656616 0.9657209 0.9657797 [218] 0.9658379 0.9658956 0.9659528 0.9660094 0.9660655 0.9661211 0.9661761 [225] 0.9662306 0.9662846 0.9663380 0.9663909 0.9664433 0.9664951 0.9665464 [232] 0.9665972 0.9666474 0.9666972 0.9667464 0.9667950 0.9668432 0.9668908 [239] 0.9669378 0.9669844 0.9670304 0.9670759 0.9671209 0.9671653 0.9672093 [246] 0.9672527 0.9672956 0.9673379 0.9673797 0.9674210 0.9674618 0.9675021 [253] 0.9675418 0.9675811 0.9676198 0.9676579 0.9676956 0.9677328 0.9677694 [260] 0.9678055 0.9678411 0.9678761 0.9679107 0.9679447 0.9679783 0.9680113 [267] 0.9680438 0.9680757 0.9681072 0.9681382 0.9681686 0.9681985 0.9682279 [274] 0.9682568 0.9682852 0.9683131 0.9683405 0.9683673 0.9683937 0.9684195 [281] 0.9684448 0.9684696 0.9684940 0.9685178 0.9685411 0.9685639 0.9685861 [288] 0.9686079 0.9686292 0.9686500 0.9686702 0.9686900 0.9687093 0.9687280 [295] 0.9687463 0.9687641 0.9687813 0.9687981 0.9688143 0.9688301 0.9688453 [302] 0.9688601 0.9688744 0.9688881 0.9689014 0.9689142 0.9689264 0.9689382 [309] 0.9689495 0.9689603 0.9689706 0.9689804 0.9689897 0.9689985 0.9690068 [316] 0.9690147 0.9690220 0.9690288 0.9690352 0.9690411 0.9690465 0.9690514 [323] 0.9690558 0.9690597 0.9690631 0.9690661 0.9690685 0.9690705 0.9690720 [330] 0.9690730 0.9690735 0.9690735 0.9690731 0.9690722 0.9690707 0.9690689 [337] 0.9690665 0.9690636 0.9690603 0.9690565 0.9690522 0.9690474 0.9690422 [344] 0.9690365 0.9690303 0.9690236 0.9690164 0.9690088 0.9690007 0.9689922 [351] 0.9689831 0.9689736 0.9689636 0.9689531 0.9689422 0.9689308 0.9689189 [358] 0.9689066 0.9688938 0.9688805 0.9688667 0.9688525 0.9688378 0.9688227 [365] 0.9688071 0.9687910 0.9687744 0.9687574 0.9687400 0.9687220 0.9687036 [372] 0.9686848 0.9686654 0.9686457 0.9686254 0.9686047 0.9685836 0.9685619 [379] 0.9685399 0.9685173 0.9684943 0.9684709 0.9684470 0.9684226 0.9683978 [386] 0.9683725 0.9683468 0.9683206 0.9682940 0.9682669 0.9682394 0.9682114 [393] 0.9681830 0.9681541 0.9681248 0.9680950 0.9680648 0.9680341 0.9680030 [400] 0.9679714 0.9679394 > mx [1] 0.9690735 > mxli [1] 1.31 > 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/1fsdj1260299425.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/2jm3q1260299425.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/3n1iy1260299425.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/49y2l1260299425.tab") > > system("convert tmp/1fsdj1260299425.ps tmp/1fsdj1260299425.png") > system("convert tmp/2jm3q1260299425.ps tmp/2jm3q1260299425.png") > system("convert tmp/3n1iy1260299425.ps tmp/3n1iy1260299425.png") > > > proc.time() user system elapsed 0.782 0.514 1.663