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(8,8.1,7.7,7.5,7.6,7.8,7.8,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.2,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,7.9,7.7,7.4,7.5,8,8.1) > x <- c(9.3,9.3,8.7,8.2,8.3,8.5,8.6,8.5,8.2,8.1,7.9,8.6,8.7,8.7,8.5,8.4,8.5,8.7,8.7,8.6,8.5,8.3,8,8.2,8.1,8.1,8,7.9,7.9,8,8,7.9,8,7.7,7.2,7.5,7.3,7,7,7,7.2,7.3,7.1,6.8,6.4,6.1,6.5,7.7,7.9,7.5,6.9,6.6,6.9,7.7,8,8,7.7,7.3,7.4,8.1,8.3) > #'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.8650024 0.8650655 0.8651282 0.8651906 0.8652528 0.8653146 0.8653761 [8] 0.8654373 0.8654982 0.8655588 0.8656191 0.8656790 0.8657387 0.8657980 [15] 0.8658571 0.8659158 0.8659742 0.8660324 0.8660902 0.8661477 0.8662049 [22] 0.8662617 0.8663183 0.8663746 0.8664305 0.8664862 0.8665415 0.8665965 [29] 0.8666512 0.8667056 0.8667597 0.8668135 0.8668670 0.8669202 0.8669730 [36] 0.8670256 0.8670778 0.8671297 0.8671813 0.8672326 0.8672836 0.8673343 [43] 0.8673847 0.8674348 0.8674845 0.8675340 0.8675831 0.8676319 0.8676804 [50] 0.8677286 0.8677765 0.8678241 0.8678714 0.8679183 0.8679650 0.8680113 [57] 0.8680573 0.8681030 0.8681484 0.8681935 0.8682383 0.8682827 0.8683269 [64] 0.8683707 0.8684143 0.8684575 0.8685004 0.8685430 0.8685853 0.8686273 [71] 0.8686689 0.8687103 0.8687513 0.8687920 0.8688324 0.8688725 0.8689123 [78] 0.8689518 0.8689910 0.8690298 0.8690684 0.8691066 0.8691445 0.8691821 [85] 0.8692194 0.8692564 0.8692930 0.8693294 0.8693654 0.8694012 0.8694366 [92] 0.8694717 0.8695065 0.8695410 0.8695751 0.8696090 0.8696425 0.8696758 [99] 0.8697087 0.8697413 0.8697736 0.8698056 0.8698372 0.8698686 0.8698996 [106] 0.8699303 0.8699608 0.8699909 0.8700207 0.8700501 0.8700793 0.8701081 [113] 0.8701367 0.8701649 0.8701928 0.8702204 0.8702477 0.8702747 0.8703013 [120] 0.8703277 0.8703537 0.8703795 0.8704049 0.8704300 0.8704547 0.8704792 [127] 0.8705034 0.8705272 0.8705507 0.8705740 0.8705969 0.8706195 0.8706417 [134] 0.8706637 0.8706854 0.8707067 0.8707277 0.8707484 0.8707688 0.8707889 [141] 0.8708087 0.8708282 0.8708473 0.8708662 0.8708847 0.8709029 0.8709208 [148] 0.8709384 0.8709556 0.8709726 0.8709893 0.8710056 0.8710216 0.8710373 [155] 0.8710527 0.8710678 0.8710826 0.8710970 0.8711112 0.8711250 0.8711385 [162] 0.8711517 0.8711646 0.8711772 0.8711895 0.8712014 0.8712131 0.8712244 [169] 0.8712354 0.8712461 0.8712565 0.8712666 0.8712763 0.8712858 0.8712949 [176] 0.8713038 0.8713123 0.8713205 0.8713284 0.8713360 0.8713432 0.8713502 [183] 0.8713568 0.8713631 0.8713692 0.8713749 0.8713803 0.8713853 0.8713901 [190] 0.8713946 0.8713987 0.8714026 0.8714061 0.8714093 0.8714122 0.8714148 [197] 0.8714170 0.8714190 0.8714207 0.8714220 0.8714230 0.8714237 0.8714241 [204] 0.8714242 0.8714240 0.8714235 0.8714226 0.8714215 0.8714200 0.8714182 [211] 0.8714162 0.8714138 0.8714110 0.8714080 0.8714047 0.8714010 0.8713971 [218] 0.8713928 0.8713883 0.8713834 0.8713782 0.8713727 0.8713668 0.8713607 [225] 0.8713543 0.8713475 0.8713405 0.8713331 0.8713254 0.8713174 0.8713091 [232] 0.8713005 0.8712916 0.8712823 0.8712728 0.8712629 0.8712528 0.8712423 [239] 0.8712315 0.8712204 0.8712090 0.8711973 0.8711853 0.8711730 0.8711603 [246] 0.8711474 0.8711341 0.8711206 0.8711067 0.8710925 0.8710780 0.8710632 [253] 0.8710481 0.8710327 0.8710169 0.8710009 0.8709845 0.8709679 0.8709509 [260] 0.8709336 0.8709161 0.8708982 0.8708800 0.8708615 0.8708426 0.8708235 [267] 0.8708041 0.8707844 0.8707643 0.8707439 0.8707233 0.8707023 0.8706810 [274] 0.8706595 0.8706376 0.8706154 0.8705929 0.8705700 0.8705469 0.8705235 [281] 0.8704998 0.8704757 0.8704514 0.8704267 0.8704018 0.8703765 0.8703509 [288] 0.8703250 0.8702989 0.8702724 0.8702456 0.8702185 0.8701911 0.8701633 [295] 0.8701353 0.8701070 0.8700784 0.8700494 0.8700202 0.8699906 0.8699608 [302] 0.8699306 0.8699002 0.8698694 0.8698383 0.8698069 0.8697753 0.8697433 [309] 0.8697110 0.8696784 0.8696455 0.8696123 0.8695788 0.8695450 0.8695109 [316] 0.8694764 0.8694417 0.8694067 0.8693714 0.8693357 0.8692998 0.8692636 [323] 0.8692270 0.8691902 0.8691530 0.8691156 0.8690778 0.8690398 0.8690014 [330] 0.8689627 0.8689238 0.8688845 0.8688450 0.8688051 0.8687649 0.8687244 [337] 0.8686837 0.8686426 0.8686012 0.8685595 0.8685176 0.8684753 0.8684327 [344] 0.8683898 0.8683467 0.8683032 0.8682594 0.8682153 0.8681709 0.8681262 [351] 0.8680813 0.8680360 0.8679904 0.8679445 0.8678983 0.8678519 0.8678051 [358] 0.8677580 0.8677106 0.8676630 0.8676150 0.8675667 0.8675181 0.8674693 [365] 0.8674201 0.8673706 0.8673209 0.8672708 0.8672204 0.8671698 0.8671188 [372] 0.8670676 0.8670160 0.8669642 0.8669120 0.8668596 0.8668069 0.8667538 [379] 0.8667005 0.8666469 0.8665929 0.8665387 0.8664842 0.8664294 0.8663743 [386] 0.8663189 0.8662632 0.8662072 0.8661509 0.8660943 0.8660374 0.8659803 [393] 0.8659228 0.8658650 0.8658070 0.8657486 0.8656900 0.8656310 0.8655718 [400] 0.8655123 0.8654525 > mx [1] 0.8714242 > mxli [1] 0.03 > 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/184ea1257794793.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/2d7h51257794793.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/3aaxs1257794793.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/4p5jz1257794793.tab") > > system("convert tmp/184ea1257794793.ps tmp/184ea1257794793.png") > system("convert tmp/2d7h51257794793.ps tmp/2d7h51257794793.png") > system("convert tmp/3aaxs1257794793.ps tmp/3aaxs1257794793.png") > > > proc.time() user system elapsed 0.90 0.76 1.53