R version 2.8.1 (2008-12-22) 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(100.64,100.63,100.43,100.8,101.33,101.88,101.85,102.04,102.22,102.63,102.65,102.54,102.37,102.68,102.76,102.82,103.31,103.23,103.6,103.95,103.93,104.25,104.38,104.36,104.32,104.58,104.68,104.92,105.46,105.23,105.58,105.34,105.28,105.7,105.67,105.71,106.19,106.93,107.44,107.85,108.71,109.32,109.49,110.2,110.62,111.22,110.88,111.15,111.29,111.09,111.24,111.45,111.75,111.07,111.17,110.96,110.5,110.48,110.66,110.46) > x <- c(101,100.88,100.55,100.83,101.51,102.16,102.39,102.54,102.85,103.47,103.57,103.69,103.5,103.47,103.45,103.48,103.93,103.89,104.4,104.79,104.77,105.13,105.26,104.96,104.75,105.01,105.15,105.2,105.77,105.78,106.26,106.13,106.12,106.57,106.44,106.54,107.1,108.1,108.4,108.84,109.62,110.42,110.67,111.66,112.28,112.87,112.18,112.36,112.16,111.49,111.25,111.36,111.74,111.1,111.33,111.25,111.04,110.97,111.31,111.02) > #'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.9925004 0.9925100 0.9925195 0.9925291 0.9925386 0.9925481 0.9925575 [8] 0.9925670 0.9925764 0.9925858 0.9925952 0.9926046 0.9926139 0.9926232 [15] 0.9926325 0.9926418 0.9926510 0.9926602 0.9926694 0.9926786 0.9926877 [22] 0.9926969 0.9927060 0.9927150 0.9927241 0.9927331 0.9927421 0.9927511 [29] 0.9927601 0.9927690 0.9927780 0.9927869 0.9927957 0.9928046 0.9928134 [36] 0.9928222 0.9928310 0.9928398 0.9928485 0.9928572 0.9928659 0.9928746 [43] 0.9928832 0.9928918 0.9929004 0.9929090 0.9929176 0.9929261 0.9929346 [50] 0.9929431 0.9929516 0.9929600 0.9929684 0.9929768 0.9929852 0.9929935 [57] 0.9930019 0.9930102 0.9930184 0.9930267 0.9930349 0.9930431 0.9930513 [64] 0.9930595 0.9930676 0.9930758 0.9930839 0.9930919 0.9931000 0.9931080 [71] 0.9931160 0.9931240 0.9931320 0.9931399 0.9931478 0.9931557 0.9931636 [78] 0.9931715 0.9931793 0.9931871 0.9931949 0.9932026 0.9932104 0.9932181 [85] 0.9932258 0.9932334 0.9932411 0.9932487 0.9932563 0.9932639 0.9932714 [92] 0.9932790 0.9932865 0.9932940 0.9933014 0.9933089 0.9933163 0.9933237 [99] 0.9933311 0.9933384 0.9933458 0.9933531 0.9933604 0.9933676 0.9933749 [106] 0.9933821 0.9933893 0.9933965 0.9934036 0.9934107 0.9934178 0.9934249 [113] 0.9934320 0.9934390 0.9934460 0.9934530 0.9934600 0.9934670 0.9934739 [120] 0.9934808 0.9934877 0.9934945 0.9935014 0.9935082 0.9935150 0.9935218 [127] 0.9935285 0.9935352 0.9935419 0.9935486 0.9935553 0.9935619 0.9935685 [134] 0.9935751 0.9935817 0.9935882 0.9935948 0.9936013 0.9936077 0.9936142 [141] 0.9936206 0.9936270 0.9936334 0.9936398 0.9936462 0.9936525 0.9936588 [148] 0.9936651 0.9936713 0.9936776 0.9936838 0.9936900 0.9936961 0.9937023 [155] 0.9937084 0.9937145 0.9937206 0.9937267 0.9937327 0.9937387 0.9937447 [162] 0.9937507 0.9937566 0.9937626 0.9937685 0.9937743 0.9937802 0.9937860 [169] 0.9937919 0.9937977 0.9938034 0.9938092 0.9938149 0.9938206 0.9938263 [176] 0.9938320 0.9938376 0.9938432 0.9938488 0.9938544 0.9938599 0.9938655 [183] 0.9938710 0.9938765 0.9938819 0.9938874 0.9938928 0.9938982 0.9939036 [190] 0.9939089 0.9939143 0.9939196 0.9939249 0.9939301 0.9939354 0.9939406 [197] 0.9939458 0.9939510 0.9939561 0.9939613 0.9939664 0.9939715 0.9939766 [204] 0.9939816 0.9939866 0.9939916 0.9939966 0.9940016 0.9940065 0.9940114 [211] 0.9940163 0.9940212 0.9940261 0.9940309 0.9940357 0.9940405 0.9940453 [218] 0.9940500 0.9940547 0.9940594 0.9940641 0.9940688 0.9940734 0.9940780 [225] 0.9940826 0.9940872 0.9940917 0.9940963 0.9941008 0.9941053 0.9941097 [232] 0.9941142 0.9941186 0.9941230 0.9941274 0.9941317 0.9941361 0.9941404 [239] 0.9941447 0.9941489 0.9941532 0.9941574 0.9941616 0.9941658 0.9941699 [246] 0.9941741 0.9941782 0.9941823 0.9941864 0.9941904 0.9941945 0.9941985 [253] 0.9942025 0.9942064 0.9942104 0.9942143 0.9942182 0.9942221 0.9942259 [260] 0.9942298 0.9942336 0.9942374 0.9942412 0.9942449 0.9942487 0.9942524 [267] 0.9942561 0.9942597 0.9942634 0.9942670 0.9942706 0.9942742 0.9942778 [274] 0.9942813 0.9942848 0.9942883 0.9942918 0.9942952 0.9942987 0.9943021 [281] 0.9943055 0.9943089 0.9943122 0.9943155 0.9943188 0.9943221 0.9943254 [288] 0.9943286 0.9943318 0.9943350 0.9943382 0.9943414 0.9943445 0.9943476 [295] 0.9943507 0.9943538 0.9943569 0.9943599 0.9943629 0.9943659 0.9943689 [302] 0.9943718 0.9943747 0.9943776 0.9943805 0.9943834 0.9943862 0.9943890 [309] 0.9943918 0.9943946 0.9943974 0.9944001 0.9944028 0.9944055 0.9944082 [316] 0.9944108 0.9944135 0.9944161 0.9944187 0.9944212 0.9944238 0.9944263 [323] 0.9944288 0.9944313 0.9944338 0.9944362 0.9944386 0.9944410 0.9944434 [330] 0.9944458 0.9944481 0.9944504 0.9944527 0.9944550 0.9944572 0.9944595 [337] 0.9944617 0.9944639 0.9944660 0.9944682 0.9944703 0.9944724 0.9944745 [344] 0.9944766 0.9944786 0.9944807 0.9944827 0.9944846 0.9944866 0.9944886 [351] 0.9944905 0.9944924 0.9944943 0.9944961 0.9944980 0.9944998 0.9945016 [358] 0.9945033 0.9945051 0.9945068 0.9945085 0.9945102 0.9945119 0.9945136 [365] 0.9945152 0.9945168 0.9945184 0.9945200 0.9945215 0.9945230 0.9945246 [372] 0.9945260 0.9945275 0.9945290 0.9945304 0.9945318 0.9945332 0.9945345 [379] 0.9945359 0.9945372 0.9945385 0.9945398 0.9945410 0.9945423 0.9945435 [386] 0.9945447 0.9945459 0.9945470 0.9945482 0.9945493 0.9945504 0.9945515 [393] 0.9945525 0.9945536 0.9945546 0.9945556 0.9945566 0.9945575 0.9945584 [400] 0.9945594 0.9945602 > mx [1] 0.9945602 > 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/rcomp/tmp/1ksec1257954684.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/rcomp/tmp/25tcp1257954684.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/rcomp/tmp/3aa8w1257954684.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/4vwag1257954684.tab") > > system("convert tmp/1ksec1257954684.ps tmp/1ksec1257954684.png") > system("convert tmp/25tcp1257954684.ps tmp/25tcp1257954684.png") > system("convert tmp/3aa8w1257954684.ps tmp/3aa8w1257954684.png") > > > proc.time() user system elapsed 0.970 0.880 1.566