R version 2.10.0 (2009-10-26) 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(15.5,15.1,11.7,16.3,16.7,15,14.9,14.6,15.3,17.9,16.4,15.4,17.9,15.9,13.9,17.8,17.9,17.4,16.7,16,16.6,19.1,17.8,17.2,18.6,16.3,15.1,19.2,17.7,19.1,18,17.5,17.8,21.1,17.2,19.4,19.8,17.6,16.2,19.5,19.9,20,17.3,18.9,18.6,21.4,18.6,19.8,20.8,19.6,17.7,19.8,22.2,20.7,17.9,20.9,21.2,21.4,23,21.3,23.9,22.4,18.3,22.8,22.3,17.8,16.4,16,16.4,17.7,16.6,16.2,18.3) > x <- c(-0.8,-0.2,0.2,1,0,-0.2,1,0.4,1,1.7,3.1,3.3,3.1,3.5,6,5.7,4.7,4.2,3.6,4.4,2.5,-0.6,-1.9,-1.9,0.7,-0.9,-1.7,-3.1,-2.1,0.2,1.2,3.8,4,6.6,5.3,7.6,4.7,6.6,4.4,4.6,6,4.8,4,2.7,3,4.1,4,2.7,2.6,3.1,4.4,3,2,1.3,1.5,1.3,3.2,1.8,3.3,1,2.4,0.4,-0.1,1.3,-1.1,-4.4,-7.5,-12.2,-14.5,-16,-16.7,-16.3,-16.9) > #'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!) > x <- x +100 > 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.1991365 0.1991625 0.1991885 0.1992145 0.1992404 0.1992663 0.1992922 [8] 0.1993180 0.1993438 0.1993696 0.1993954 0.1994211 0.1994468 0.1994725 [15] 0.1994981 0.1995237 0.1995493 0.1995749 0.1996004 0.1996259 0.1996514 [22] 0.1996768 0.1997022 0.1997276 0.1997529 0.1997783 0.1998036 0.1998288 [29] 0.1998540 0.1998793 0.1999044 0.1999296 0.1999547 0.1999798 0.2000048 [36] 0.2000298 0.2000548 0.2000798 0.2001047 0.2001296 0.2001545 0.2001793 [43] 0.2002042 0.2002289 0.2002537 0.2002784 0.2003031 0.2003278 0.2003524 [50] 0.2003770 0.2004016 0.2004261 0.2004506 0.2004751 0.2004995 0.2005239 [57] 0.2005483 0.2005727 0.2005970 0.2006213 0.2006455 0.2006698 0.2006940 [64] 0.2007181 0.2007423 0.2007664 0.2007904 0.2008145 0.2008385 0.2008624 [71] 0.2008864 0.2009103 0.2009342 0.2009580 0.2009819 0.2010056 0.2010294 [78] 0.2010531 0.2010768 0.2011005 0.2011241 0.2011477 0.2011712 0.2011948 [85] 0.2012183 0.2012417 0.2012652 0.2012886 0.2013119 0.2013353 0.2013586 [92] 0.2013818 0.2014051 0.2014283 0.2014515 0.2014746 0.2014977 0.2015208 [99] 0.2015438 0.2015668 0.2015898 0.2016127 0.2016357 0.2016585 0.2016814 [106] 0.2017042 0.2017270 0.2017497 0.2017724 0.2017951 0.2018177 0.2018403 [113] 0.2018629 0.2018855 0.2019080 0.2019304 0.2019529 0.2019753 0.2019977 [120] 0.2020200 0.2020423 0.2020646 0.2020868 0.2021090 0.2021312 0.2021533 [127] 0.2021754 0.2021975 0.2022196 0.2022416 0.2022635 0.2022855 0.2023073 [134] 0.2023292 0.2023510 0.2023728 0.2023946 0.2024163 0.2024380 0.2024597 [141] 0.2024813 0.2025029 0.2025244 0.2025459 0.2025674 0.2025889 0.2026103 [148] 0.2026317 0.2026530 0.2026743 0.2026956 0.2027168 0.2027380 0.2027592 [155] 0.2027803 0.2028014 0.2028225 0.2028435 0.2028645 0.2028855 0.2029064 [162] 0.2029273 0.2029481 0.2029689 0.2029897 0.2030105 0.2030312 0.2030518 [169] 0.2030725 0.2030931 0.2031136 0.2031342 0.2031546 0.2031751 0.2031955 [176] 0.2032159 0.2032362 0.2032566 0.2032768 0.2032971 0.2033173 0.2033374 [183] 0.2033576 0.2033777 0.2033977 0.2034177 0.2034377 0.2034577 0.2034776 [190] 0.2034974 0.2035173 0.2035371 0.2035568 0.2035766 0.2035963 0.2036159 [197] 0.2036355 0.2036551 0.2036747 0.2036942 0.2037136 0.2037331 0.2037525 [204] 0.2037718 0.2037911 0.2038104 0.2038297 0.2038489 0.2038680 0.2038872 [211] 0.2039063 0.2039253 0.2039443 0.2039633 0.2039823 0.2040012 0.2040201 [218] 0.2040389 0.2040577 0.2040764 0.2040952 0.2041138 0.2041325 0.2041511 [225] 0.2041697 0.2041882 0.2042067 0.2042251 0.2042435 0.2042619 0.2042803 [232] 0.2042986 0.2043168 0.2043351 0.2043532 0.2043714 0.2043895 0.2044076 [239] 0.2044256 0.2044436 0.2044616 0.2044795 0.2044974 0.2045152 0.2045330 [246] 0.2045508 0.2045685 0.2045862 0.2046038 0.2046214 0.2046390 0.2046565 [253] 0.2046740 0.2046915 0.2047089 0.2047263 0.2047436 0.2047609 0.2047782 [260] 0.2047954 0.2048126 0.2048297 0.2048468 0.2048639 0.2048809 0.2048979 [267] 0.2049148 0.2049317 0.2049486 0.2049654 0.2049822 0.2049990 0.2050157 [274] 0.2050323 0.2050490 0.2050655 0.2050821 0.2050986 0.2051151 0.2051315 [281] 0.2051479 0.2051642 0.2051806 0.2051968 0.2052131 0.2052293 0.2052454 [288] 0.2052615 0.2052776 0.2052936 0.2053096 0.2053256 0.2053415 0.2053573 [295] 0.2053732 0.2053890 0.2054047 0.2054204 0.2054361 0.2054517 0.2054673 [302] 0.2054829 0.2054984 0.2055138 0.2055293 0.2055446 0.2055600 0.2055753 [309] 0.2055906 0.2056058 0.2056210 0.2056361 0.2056512 0.2056663 0.2056813 [316] 0.2056963 0.2057112 0.2057261 0.2057410 0.2057558 0.2057706 0.2057853 [323] 0.2058000 0.2058146 0.2058293 0.2058438 0.2058583 0.2058728 0.2058873 [330] 0.2059017 0.2059161 0.2059304 0.2059447 0.2059589 0.2059731 0.2059873 [337] 0.2060014 0.2060155 0.2060295 0.2060435 0.2060574 0.2060713 0.2060852 [344] 0.2060990 0.2061128 0.2061266 0.2061403 0.2061539 0.2061675 0.2061811 [351] 0.2061947 0.2062081 0.2062216 0.2062350 0.2062484 0.2062617 0.2062750 [358] 0.2062882 0.2063014 0.2063146 0.2063277 0.2063408 0.2063538 0.2063668 [365] 0.2063798 0.2063927 0.2064055 0.2064183 0.2064311 0.2064439 0.2064566 [372] 0.2064692 0.2064818 0.2064944 0.2065069 0.2065194 0.2065319 0.2065443 [379] 0.2065566 0.2065689 0.2065812 0.2065934 0.2066056 0.2066178 0.2066299 [386] 0.2066419 0.2066539 0.2066659 0.2066779 0.2066897 0.2067016 0.2067134 [393] 0.2067252 0.2067369 0.2067486 0.2067602 0.2067718 0.2067833 0.2067948 [400] 0.2068063 0.2068177 > mx [1] 0.2068177 > 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/11ji41261127704.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/2n2zr1261127704.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/3og481261127704.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/4owhg1261127704.tab") > > try(system("convert tmp/11ji41261127704.ps tmp/11ji41261127704.png",intern=TRUE)) character(0) > try(system("convert tmp/2n2zr1261127704.ps tmp/2n2zr1261127704.png",intern=TRUE)) character(0) > try(system("convert tmp/3og481261127704.ps tmp/3og481261127704.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.100 0.980 1.832