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(93,87,89,91,108,124,104,107,116,70,126,119,102,88,71,76,84,125,122,93,117,71,118,115,101,106,79,77,85,124,115,115,114,75,114,121,113,104,84,113,120,127,92,113,112,75,120,122,116,88,87,107,112,92,112,87,112,75,100,118) > x <- c(108,90,76,81,108,124,114,107,109,74,119,115,99,90,79,86,73,126,123,105,119,81,124,117,101,91,84,79,86,131,127,110,112,77,113,126,99,104,84,95,109,123,109,102,110,71,117,109,109,90,77,113,113,91,109,105,108,82,107,104) > #'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.8679590 0.8680837 0.8682079 0.8683316 0.8684548 0.8685776 0.8686999 [8] 0.8688217 0.8689431 0.8690640 0.8691844 0.8693043 0.8694238 0.8695427 [15] 0.8696612 0.8697793 0.8698968 0.8700138 0.8701304 0.8702465 0.8703621 [22] 0.8704772 0.8705919 0.8707060 0.8708197 0.8709328 0.8710455 0.8711577 [29] 0.8712694 0.8713807 0.8714914 0.8716016 0.8717114 0.8718206 0.8719294 [36] 0.8720377 0.8721454 0.8722527 0.8723595 0.8724658 0.8725716 0.8726769 [43] 0.8727816 0.8728859 0.8729897 0.8730930 0.8731958 0.8732981 0.8733999 [50] 0.8735011 0.8736019 0.8737022 0.8738019 0.8739012 0.8740000 0.8740982 [57] 0.8741959 0.8742932 0.8743899 0.8744861 0.8745818 0.8746770 0.8747716 [64] 0.8748658 0.8749594 0.8750526 0.8751452 0.8752373 0.8753289 0.8754199 [71] 0.8755105 0.8756005 0.8756900 0.8757790 0.8758675 0.8759555 0.8760429 [78] 0.8761298 0.8762162 0.8763021 0.8763874 0.8764722 0.8765565 0.8766403 [85] 0.8767236 0.8768063 0.8768885 0.8769701 0.8770513 0.8771319 0.8772120 [92] 0.8772915 0.8773705 0.8774490 0.8775270 0.8776044 0.8776813 0.8777576 [99] 0.8778335 0.8779088 0.8779835 0.8780577 0.8781314 0.8782046 0.8782772 [106] 0.8783492 0.8784208 0.8784918 0.8785622 0.8786321 0.8787015 0.8787704 [113] 0.8788386 0.8789064 0.8789736 0.8790403 0.8791064 0.8791720 0.8792370 [120] 0.8793015 0.8793654 0.8794288 0.8794917 0.8795540 0.8796157 0.8796769 [127] 0.8797376 0.8797977 0.8798573 0.8799163 0.8799747 0.8800326 0.8800900 [134] 0.8801468 0.8802030 0.8802587 0.8803139 0.8803685 0.8804225 0.8804760 [141] 0.8805289 0.8805813 0.8806331 0.8806843 0.8807351 0.8807852 0.8808348 [148] 0.8808838 0.8809323 0.8809802 0.8810275 0.8810743 0.8811206 0.8811662 [155] 0.8812113 0.8812559 0.8812999 0.8813433 0.8813861 0.8814284 0.8814702 [162] 0.8815113 0.8815519 0.8815920 0.8816314 0.8816703 0.8817087 0.8817465 [169] 0.8817837 0.8818203 0.8818564 0.8818919 0.8819268 0.8819612 0.8819950 [176] 0.8820282 0.8820609 0.8820930 0.8821245 0.8821554 0.8821858 0.8822156 [183] 0.8822449 0.8822735 0.8823016 0.8823291 0.8823561 0.8823825 0.8824083 [190] 0.8824335 0.8824581 0.8824822 0.8825057 0.8825287 0.8825510 0.8825728 [197] 0.8825940 0.8826146 0.8826347 0.8826541 0.8826730 0.8826914 0.8827091 [204] 0.8827263 0.8827428 0.8827589 0.8827743 0.8827891 0.8828034 0.8828171 [211] 0.8828302 0.8828428 0.8828547 0.8828661 0.8828769 0.8828871 0.8828967 [218] 0.8829058 0.8829142 0.8829221 0.8829294 0.8829362 0.8829423 0.8829479 [225] 0.8829529 0.8829573 0.8829611 0.8829643 0.8829670 0.8829690 0.8829705 [232] 0.8829714 0.8829717 0.8829715 0.8829706 0.8829692 0.8829672 0.8829646 [239] 0.8829614 0.8829576 0.8829533 0.8829483 0.8829428 0.8829367 0.8829300 [246] 0.8829227 0.8829148 0.8829064 0.8828973 0.8828877 0.8828775 0.8828667 [253] 0.8828553 0.8828434 0.8828308 0.8828177 0.8828040 0.8827897 0.8827748 [260] 0.8827593 0.8827432 0.8827265 0.8827093 0.8826915 0.8826731 0.8826541 [267] 0.8826345 0.8826143 0.8825935 0.8825722 0.8825503 0.8825277 0.8825046 [274] 0.8824809 0.8824567 0.8824318 0.8824063 0.8823803 0.8823537 0.8823264 [281] 0.8822986 0.8822703 0.8822413 0.8822117 0.8821816 0.8821508 0.8821195 [288] 0.8820876 0.8820551 0.8820220 0.8819884 0.8819541 0.8819193 0.8818839 [295] 0.8818479 0.8818113 0.8817741 0.8817363 0.8816980 0.8816590 0.8816195 [302] 0.8815794 0.8815387 0.8814974 0.8814556 0.8814131 0.8813701 0.8813265 [309] 0.8812823 0.8812375 0.8811921 0.8811462 0.8810996 0.8810525 0.8810048 [316] 0.8809565 0.8809077 0.8808582 0.8808082 0.8807576 0.8807064 0.8806546 [323] 0.8806022 0.8805493 0.8804957 0.8804416 0.8803869 0.8803317 0.8802758 [330] 0.8802194 0.8801624 0.8801048 0.8800466 0.8799878 0.8799285 0.8798686 [337] 0.8798081 0.8797470 0.8796854 0.8796232 0.8795604 0.8794970 0.8794330 [344] 0.8793685 0.8793034 0.8792377 0.8791714 0.8791046 0.8790371 0.8789691 [351] 0.8789006 0.8788314 0.8787617 0.8786914 0.8786205 0.8785491 0.8784771 [358] 0.8784045 0.8783313 0.8782576 0.8781833 0.8781084 0.8780330 0.8779570 [365] 0.8778804 0.8778032 0.8777255 0.8776472 0.8775683 0.8774889 0.8774089 [372] 0.8773283 0.8772471 0.8771654 0.8770831 0.8770003 0.8769169 0.8768329 [379] 0.8767484 0.8766633 0.8765776 0.8764914 0.8764046 0.8763172 0.8762293 [386] 0.8761408 0.8760517 0.8759621 0.8758720 0.8757812 0.8756899 0.8755981 [393] 0.8755057 0.8754127 0.8753192 0.8752251 0.8751304 0.8750352 0.8749395 [400] 0.8748431 0.8747463 > mx [1] 0.8829717 > mxli [1] 0.32 > 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/1s9xt1226613042.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/2t0sx1226613042.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/3dlvw1226613042.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/4n4cc1226613042.tab") > > system("convert tmp/1s9xt1226613042.ps tmp/1s9xt1226613042.png") > system("convert tmp/2t0sx1226613042.ps tmp/2t0sx1226613042.png") > system("convert tmp/3dlvw1226613042.ps tmp/3dlvw1226613042.png") > > > proc.time() user system elapsed 1.110 0.559 5.141