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(100,102.03,103.45,103.33,103.42,104.40,105.89,107.19,108.95,110.95) > x <- c(100,100.13,100.42,100.88,101.34,101.79,102.44,103.38,104.42,105.29) > #'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.9778594 0.9778605 0.9778615 0.9778626 0.9778636 0.9778647 0.9778657 [8] 0.9778667 0.9778678 0.9778688 0.9778698 0.9778708 0.9778718 0.9778728 [15] 0.9778738 0.9778748 0.9778758 0.9778768 0.9778778 0.9778787 0.9778797 [22] 0.9778807 0.9778816 0.9778826 0.9778835 0.9778845 0.9778854 0.9778864 [29] 0.9778873 0.9778882 0.9778892 0.9778901 0.9778910 0.9778919 0.9778928 [36] 0.9778937 0.9778946 0.9778955 0.9778964 0.9778973 0.9778982 0.9778991 [43] 0.9778999 0.9779008 0.9779017 0.9779025 0.9779034 0.9779042 0.9779051 [50] 0.9779059 0.9779068 0.9779076 0.9779084 0.9779093 0.9779101 0.9779109 [57] 0.9779117 0.9779125 0.9779133 0.9779141 0.9779149 0.9779157 0.9779165 [64] 0.9779173 0.9779180 0.9779188 0.9779196 0.9779204 0.9779211 0.9779219 [71] 0.9779226 0.9779234 0.9779241 0.9779248 0.9779256 0.9779263 0.9779270 [78] 0.9779277 0.9779285 0.9779292 0.9779299 0.9779306 0.9779313 0.9779320 [85] 0.9779326 0.9779333 0.9779340 0.9779347 0.9779354 0.9779360 0.9779367 [92] 0.9779373 0.9779380 0.9779386 0.9779393 0.9779399 0.9779406 0.9779412 [99] 0.9779418 0.9779424 0.9779431 0.9779437 0.9779443 0.9779449 0.9779455 [106] 0.9779461 0.9779467 0.9779472 0.9779478 0.9779484 0.9779490 0.9779495 [113] 0.9779501 0.9779507 0.9779512 0.9779518 0.9779523 0.9779529 0.9779534 [120] 0.9779539 0.9779545 0.9779550 0.9779555 0.9779560 0.9779565 0.9779570 [127] 0.9779575 0.9779580 0.9779585 0.9779590 0.9779595 0.9779600 0.9779605 [134] 0.9779609 0.9779614 0.9779619 0.9779623 0.9779628 0.9779632 0.9779637 [141] 0.9779641 0.9779645 0.9779650 0.9779654 0.9779658 0.9779662 0.9779666 [148] 0.9779671 0.9779675 0.9779679 0.9779683 0.9779686 0.9779690 0.9779694 [155] 0.9779698 0.9779702 0.9779705 0.9779709 0.9779713 0.9779716 0.9779720 [162] 0.9779723 0.9779726 0.9779730 0.9779733 0.9779736 0.9779740 0.9779743 [169] 0.9779746 0.9779749 0.9779752 0.9779755 0.9779758 0.9779761 0.9779764 [176] 0.9779767 0.9779770 0.9779772 0.9779775 0.9779778 0.9779780 0.9779783 [183] 0.9779786 0.9779788 0.9779790 0.9779793 0.9779795 0.9779798 0.9779800 [190] 0.9779802 0.9779804 0.9779806 0.9779808 0.9779810 0.9779812 0.9779814 [197] 0.9779816 0.9779818 0.9779820 0.9779822 0.9779824 0.9779825 0.9779827 [204] 0.9779828 0.9779830 0.9779832 0.9779833 0.9779834 0.9779836 0.9779837 [211] 0.9779838 0.9779840 0.9779841 0.9779842 0.9779843 0.9779844 0.9779845 [218] 0.9779846 0.9779847 0.9779848 0.9779849 0.9779850 0.9779850 0.9779851 [225] 0.9779852 0.9779852 0.9779853 0.9779853 0.9779854 0.9779854 0.9779855 [232] 0.9779855 0.9779855 0.9779856 0.9779856 0.9779856 0.9779856 0.9779856 [239] 0.9779856 0.9779856 0.9779856 0.9779856 0.9779856 0.9779856 0.9779856 [246] 0.9779855 0.9779855 0.9779855 0.9779854 0.9779854 0.9779853 0.9779853 [253] 0.9779852 0.9779852 0.9779851 0.9779850 0.9779849 0.9779849 0.9779848 [260] 0.9779847 0.9779846 0.9779845 0.9779844 0.9779843 0.9779842 0.9779841 [267] 0.9779839 0.9779838 0.9779837 0.9779836 0.9779834 0.9779833 0.9779831 [274] 0.9779830 0.9779828 0.9779827 0.9779825 0.9779823 0.9779821 0.9779820 [281] 0.9779818 0.9779816 0.9779814 0.9779812 0.9779810 0.9779808 0.9779806 [288] 0.9779804 0.9779802 0.9779799 0.9779797 0.9779795 0.9779792 0.9779790 [295] 0.9779788 0.9779785 0.9779783 0.9779780 0.9779777 0.9779775 0.9779772 [302] 0.9779769 0.9779766 0.9779764 0.9779761 0.9779758 0.9779755 0.9779752 [309] 0.9779749 0.9779745 0.9779742 0.9779739 0.9779736 0.9779733 0.9779729 [316] 0.9779726 0.9779722 0.9779719 0.9779715 0.9779712 0.9779708 0.9779705 [323] 0.9779701 0.9779697 0.9779693 0.9779689 0.9779686 0.9779682 0.9779678 [330] 0.9779674 0.9779670 0.9779666 0.9779661 0.9779657 0.9779653 0.9779649 [337] 0.9779644 0.9779640 0.9779636 0.9779631 0.9779627 0.9779622 0.9779617 [344] 0.9779613 0.9779608 0.9779603 0.9779599 0.9779594 0.9779589 0.9779584 [351] 0.9779579 0.9779574 0.9779569 0.9779564 0.9779559 0.9779554 0.9779549 [358] 0.9779543 0.9779538 0.9779533 0.9779527 0.9779522 0.9779516 0.9779511 [365] 0.9779505 0.9779500 0.9779494 0.9779488 0.9779482 0.9779477 0.9779471 [372] 0.9779465 0.9779459 0.9779453 0.9779447 0.9779441 0.9779435 0.9779429 [379] 0.9779422 0.9779416 0.9779410 0.9779404 0.9779397 0.9779391 0.9779384 [386] 0.9779378 0.9779371 0.9779365 0.9779358 0.9779351 0.9779345 0.9779338 [393] 0.9779331 0.9779324 0.9779317 0.9779310 0.9779303 0.9779296 0.9779289 [400] 0.9779282 0.9779275 > mx [1] 0.9779856 > mxli [1] 0.38 > 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/1i6xe1258097113.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/27rqo1258097113.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/3vkx71258097113.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/4wny71258097113.tab") > > system("convert tmp/1i6xe1258097113.ps tmp/1i6xe1258097113.png") > system("convert tmp/27rqo1258097113.ps tmp/27rqo1258097113.png") > system("convert tmp/3vkx71258097113.ps tmp/3vkx71258097113.png") > > > proc.time() user system elapsed 0.778 0.501 1.527