R version 2.7.2 (2008-08-25) 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(116,111,104,100,93,91,119,139,134,124,113,109,109,106,101,98,93,91,122,139,140,132,117,114,113,110,107,103,98,98,137,148,147,139,130,128,127,123,118,114,108,111,151,159,158,148,138,137,136,133,126,120,114,116,153,162,161,149,139,135,130,127,122,117) > x <- c(493,481,462,457,442,439,488,521,501,485,464,460,467,460,448,443,436,431,484,510,513,503,471,471,476,475,470,461,455,456,517,525,523,519,509,512,519,517,510,509,501,507,569,580,578,565,547,555,562,561,555,544,537,543,594,611,613,611,594,595,591,589,584,573) > #'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.8394940 0.8394588 0.8394235 0.8393880 0.8393523 0.8393165 0.8392805 [8] 0.8392443 0.8392080 0.8391715 0.8391349 0.8390980 0.8390611 0.8390239 [15] 0.8389866 0.8389492 0.8389116 0.8388738 0.8388358 0.8387977 0.8387594 [22] 0.8387210 0.8386824 0.8386436 0.8386047 0.8385656 0.8385264 0.8384870 [29] 0.8384474 0.8384077 0.8383678 0.8383277 0.8382875 0.8382471 0.8382065 [36] 0.8381658 0.8381250 0.8380839 0.8380427 0.8380014 0.8379599 0.8379182 [43] 0.8378764 0.8378344 0.8377922 0.8377499 0.8377074 0.8376647 0.8376219 [50] 0.8375790 0.8375358 0.8374925 0.8374491 0.8374055 0.8373617 0.8373178 [57] 0.8372737 0.8372294 0.8371850 0.8371404 0.8370957 0.8370508 0.8370057 [64] 0.8369605 0.8369151 0.8368696 0.8368239 0.8367780 0.8367320 0.8366858 [71] 0.8366395 0.8365930 0.8365463 0.8364995 0.8364525 0.8364054 0.8363581 [78] 0.8363106 0.8362630 0.8362152 0.8361673 0.8361192 0.8360709 0.8360225 [85] 0.8359739 0.8359252 0.8358763 0.8358272 0.8357780 0.8357286 0.8356791 [92] 0.8356294 0.8355796 0.8355296 0.8354794 0.8354291 0.8353786 0.8353280 [99] 0.8352772 0.8352262 0.8351751 0.8351238 0.8350724 0.8350208 0.8349691 [106] 0.8349172 0.8348651 0.8348129 0.8347605 0.8347080 0.8346553 0.8346025 [113] 0.8345495 0.8344963 0.8344430 0.8343895 0.8343359 0.8342821 0.8342282 [120] 0.8341741 0.8341198 0.8340654 0.8340108 0.8339561 0.8339012 0.8338462 [127] 0.8337910 0.8337357 0.8336802 0.8336245 0.8335687 0.8335127 0.8334566 [134] 0.8334003 0.8333439 0.8332873 0.8332306 0.8331737 0.8331166 0.8330594 [141] 0.8330020 0.8329445 0.8328868 0.8328290 0.8327710 0.8327129 0.8326546 [148] 0.8325962 0.8325376 0.8324788 0.8324199 0.8323609 0.8323017 0.8322423 [155] 0.8321828 0.8321231 0.8320633 0.8320033 0.8319432 0.8318829 0.8318225 [162] 0.8317619 0.8317011 0.8316402 0.8315792 0.8315180 0.8314567 0.8313952 [169] 0.8313335 0.8312717 0.8312098 0.8311477 0.8310854 0.8310230 0.8309604 [176] 0.8308977 0.8308349 0.8307719 0.8307087 0.8306454 0.8305819 0.8305183 [183] 0.8304546 0.8303906 0.8303266 0.8302624 0.8301980 0.8301335 0.8300688 [190] 0.8300040 0.8299391 0.8298740 0.8298087 0.8297433 0.8296777 0.8296120 [197] 0.8295462 0.8294802 0.8294140 0.8293477 0.8292813 0.8292147 0.8291480 [204] 0.8290811 0.8290140 0.8289469 0.8288795 0.8288121 0.8287444 0.8286767 [211] 0.8286087 0.8285407 0.8284725 0.8284041 0.8283356 0.8282670 0.8281982 [218] 0.8281292 0.8280601 0.8279909 0.8279215 0.8278520 0.8277823 0.8277125 [225] 0.8276426 0.8275725 0.8275022 0.8274318 0.8273613 0.8272906 0.8272198 [232] 0.8271488 0.8270777 0.8270064 0.8269350 0.8268635 0.8267918 0.8267200 [239] 0.8266480 0.8265759 0.8265036 0.8264312 0.8263587 0.8262860 0.8262131 [246] 0.8261402 0.8260671 0.8259938 0.8259204 0.8258469 0.8257732 0.8256994 [253] 0.8256254 0.8255513 0.8254771 0.8254027 0.8253282 0.8252535 0.8251787 [260] 0.8251037 0.8250287 0.8249534 0.8248781 0.8248026 0.8247269 0.8246511 [267] 0.8245752 0.8244991 0.8244229 0.8243466 0.8242701 0.8241935 0.8241168 [274] 0.8240399 0.8239628 0.8238857 0.8238084 0.8237309 0.8236534 0.8235756 [281] 0.8234978 0.8234198 0.8233417 0.8232634 0.8231850 0.8231065 0.8230278 [288] 0.8229490 0.8228701 0.8227910 0.8227118 0.8226324 0.8225529 0.8224733 [295] 0.8223936 0.8223137 0.8222337 0.8221535 0.8220732 0.8219928 0.8219122 [302] 0.8218316 0.8217507 0.8216698 0.8215887 0.8215075 0.8214261 0.8213446 [309] 0.8212630 0.8211812 0.8210994 0.8210173 0.8209352 0.8208529 0.8207705 [316] 0.8206880 0.8206053 0.8205225 0.8204395 0.8203565 0.8202733 0.8201900 [323] 0.8201065 0.8200229 0.8199392 0.8198554 0.8197714 0.8196873 0.8196030 [330] 0.8195187 0.8194342 0.8193496 0.8192648 0.8191799 0.8190949 0.8190098 [337] 0.8189245 0.8188392 0.8187536 0.8186680 0.8185822 0.8184963 0.8184103 [344] 0.8183242 0.8182379 0.8181515 0.8180650 0.8179783 0.8178915 0.8178046 [351] 0.8177176 0.8176304 0.8175432 0.8174558 0.8173682 0.8172806 0.8171928 [358] 0.8171049 0.8170169 0.8169287 0.8168405 0.8167521 0.8166635 0.8165749 [365] 0.8164861 0.8163973 0.8163083 0.8162191 0.8161299 0.8160405 0.8159510 [372] 0.8158614 0.8157716 0.8156818 0.8155918 0.8155017 0.8154115 0.8153211 [379] 0.8152307 0.8151401 0.8150494 0.8149586 0.8148676 0.8147766 0.8146854 [386] 0.8145941 0.8145027 0.8144112 0.8143195 0.8142277 0.8141359 0.8140438 [393] 0.8139517 0.8138595 0.8137671 0.8136747 0.8135821 0.8134894 0.8133965 [400] 0.8133036 0.8132105 > mx [1] 0.839494 > 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/html/rcomp/tmp/1jvtl1226606942.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/22fgc1226606942.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/3bc411226606942.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/4hoz21226606942.tab") > > system("convert tmp/1jvtl1226606942.ps tmp/1jvtl1226606942.png") > system("convert tmp/22fgc1226606942.ps tmp/22fgc1226606942.png") > system("convert tmp/3bc411226606942.ps tmp/3bc411226606942.png") > > > proc.time() user system elapsed 1.013 0.535 1.550