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(101.26,101.08,100.00,98.02,96.76,97.84,107.03,110.09,110.45,110.09,107.03,107.21,106.49,106.13,105.23,103.24,102.16,102.52,111.89,113.33,113.15,110.27,107.21,107.57,106.85,106.31,104.50,103.42,103.24,103.24,111.71,112.79,111.71,105.95,101.98,100.36,101.08,98.92,95.86,94.77,92.07,89.91,100.00,101.80,97.66,94.95,91.89,92.61,93.15,91.53,88.83,88.29,84.50,86.13,95.14,96.22,93.33,91.17,90.45,92.97) > x <- c(91.70,74.44,100.00,74.99,76.27,105.90,74.70,71.60,78.82,88.27,76.11,82.06,78.91,84.36,99.41,93.89,109.62,106.51,79.30,94.51,99.20,90.57,85.54,109.18,109.16,96.00,116.23,93.41,102.27,106.25,87.98,90.11,95.45,100.93,78.97,88.10,90.21,80.36,97.45,80.10,78.50,97.20,81.90,87.20,72.55,105.26,80.90,72.95,83.70,91.92,83.98,87.03,78.21,91.31,74.55,72.25,83.90,76.61,78.10,91.20) > #'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.2147554 0.2147880 0.2148205 0.2148528 0.2148851 0.2149173 0.2149493 [8] 0.2149812 0.2150131 0.2150448 0.2150764 0.2151078 0.2151392 0.2151705 [15] 0.2152016 0.2152326 0.2152635 0.2152943 0.2153250 0.2153556 0.2153861 [22] 0.2154164 0.2154466 0.2154767 0.2155067 0.2155366 0.2155664 0.2155960 [29] 0.2156256 0.2156550 0.2156843 0.2157135 0.2157426 0.2157715 0.2158004 [36] 0.2158291 0.2158577 0.2158862 0.2159146 0.2159429 0.2159710 0.2159991 [43] 0.2160270 0.2160548 0.2160825 0.2161101 0.2161375 0.2161648 0.2161921 [50] 0.2162192 0.2162461 0.2162730 0.2162997 0.2163264 0.2163529 0.2163793 [57] 0.2164056 0.2164317 0.2164578 0.2164837 0.2165095 0.2165352 0.2165607 [64] 0.2165862 0.2166115 0.2166367 0.2166618 0.2166868 0.2167116 0.2167364 [71] 0.2167610 0.2167855 0.2168099 0.2168341 0.2168583 0.2168823 0.2169062 [78] 0.2169300 0.2169536 0.2169772 0.2170006 0.2170239 0.2170471 0.2170701 [85] 0.2170931 0.2171159 0.2171386 0.2171612 0.2171836 0.2172059 0.2172282 [92] 0.2172502 0.2172722 0.2172941 0.2173158 0.2173374 0.2173589 0.2173803 [99] 0.2174015 0.2174226 0.2174436 0.2174645 0.2174853 0.2175059 0.2175264 [106] 0.2175468 0.2175671 0.2175872 0.2176072 0.2176271 0.2176469 0.2176666 [113] 0.2176861 0.2177055 0.2177248 0.2177440 0.2177630 0.2177819 0.2178007 [120] 0.2178194 0.2178380 0.2178564 0.2178747 0.2178929 0.2179109 0.2179289 [127] 0.2179467 0.2179644 0.2179819 0.2179994 0.2180167 0.2180339 0.2180509 [134] 0.2180679 0.2180847 0.2181014 0.2181180 0.2181344 0.2181507 0.2181669 [141] 0.2181830 0.2181990 0.2182148 0.2182305 0.2182461 0.2182615 0.2182768 [148] 0.2182921 0.2183071 0.2183221 0.2183369 0.2183516 0.2183662 0.2183806 [155] 0.2183950 0.2184092 0.2184233 0.2184372 0.2184510 0.2184647 0.2184783 [162] 0.2184918 0.2185051 0.2185183 0.2185314 0.2185443 0.2185571 0.2185698 [169] 0.2185824 0.2185948 0.2186072 0.2186194 0.2186314 0.2186434 0.2186552 [176] 0.2186669 0.2186784 0.2186899 0.2187012 0.2187124 0.2187234 0.2187344 [183] 0.2187452 0.2187558 0.2187664 0.2187768 0.2187871 0.2187973 0.2188074 [190] 0.2188173 0.2188271 0.2188367 0.2188463 0.2188557 0.2188650 0.2188742 [197] 0.2188832 0.2188921 0.2189009 0.2189095 0.2189181 0.2189265 0.2189347 [204] 0.2189429 0.2189509 0.2189588 0.2189666 0.2189742 0.2189817 0.2189891 [211] 0.2189964 0.2190035 0.2190105 0.2190174 0.2190241 0.2190308 0.2190373 [218] 0.2190436 0.2190499 0.2190560 0.2190620 0.2190679 0.2190736 0.2190792 [225] 0.2190847 0.2190900 0.2190953 0.2191004 0.2191053 0.2191102 0.2191149 [232] 0.2191195 0.2191239 0.2191283 0.2191325 0.2191366 0.2191405 0.2191444 [239] 0.2191481 0.2191516 0.2191551 0.2191584 0.2191616 0.2191646 0.2191676 [246] 0.2191704 0.2191731 0.2191756 0.2191780 0.2191803 0.2191825 0.2191846 [253] 0.2191865 0.2191883 0.2191899 0.2191915 0.2191929 0.2191942 0.2191953 [260] 0.2191964 0.2191973 0.2191980 0.2191987 0.2191992 0.2191996 0.2191999 [267] 0.2192000 0.2192000 0.2191999 0.2191996 0.2191993 0.2191988 0.2191982 [274] 0.2191974 0.2191965 0.2191955 0.2191944 0.2191931 0.2191918 0.2191902 [281] 0.2191886 0.2191868 0.2191850 0.2191829 0.2191808 0.2191785 0.2191761 [288] 0.2191736 0.2191709 0.2191682 0.2191653 0.2191622 0.2191591 0.2191558 [295] 0.2191524 0.2191488 0.2191452 0.2191414 0.2191375 0.2191334 0.2191293 [302] 0.2191250 0.2191206 0.2191160 0.2191113 0.2191065 0.2191016 0.2190966 [309] 0.2190914 0.2190861 0.2190807 0.2190751 0.2190694 0.2190636 0.2190577 [316] 0.2190516 0.2190455 0.2190392 0.2190327 0.2190262 0.2190195 0.2190127 [323] 0.2190057 0.2189987 0.2189915 0.2189842 0.2189768 0.2189692 0.2189615 [330] 0.2189537 0.2189458 0.2189377 0.2189295 0.2189212 0.2189128 0.2189042 [337] 0.2188956 0.2188868 0.2188778 0.2188688 0.2188596 0.2188503 0.2188409 [344] 0.2188313 0.2188216 0.2188118 0.2188019 0.2187919 0.2187817 0.2187714 [351] 0.2187610 0.2187505 0.2187398 0.2187290 0.2187181 0.2187071 0.2186959 [358] 0.2186846 0.2186732 0.2186617 0.2186500 0.2186383 0.2186264 0.2186143 [365] 0.2186022 0.2185899 0.2185776 0.2185650 0.2185524 0.2185397 0.2185268 [372] 0.2185138 0.2185007 0.2184874 0.2184741 0.2184606 0.2184470 0.2184332 [379] 0.2184194 0.2184054 0.2183913 0.2183771 0.2183628 0.2183483 0.2183337 [386] 0.2183190 0.2183042 0.2182893 0.2182742 0.2182590 0.2182437 0.2182283 [393] 0.2182128 0.2181971 0.2181813 0.2181654 0.2181494 0.2181332 0.2181170 [400] 0.2181006 0.2180841 > mx [1] 0.2192 > mxli [1] 0.67 > 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/1od4u1258230295.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/2ykb31258230295.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/3u3hk1258230295.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/42hms1258230296.tab") > > system("convert tmp/1od4u1258230295.ps tmp/1od4u1258230295.png") > system("convert tmp/2ykb31258230295.ps tmp/2ykb31258230295.png") > system("convert tmp/3u3hk1258230295.ps tmp/3u3hk1258230295.png") > > > proc.time() user system elapsed 0.785 0.502 0.935