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(23,19,18,19,19,22,23,20,14,14,14,15,11,17,16,20,24,23,20,21,19,23,23,23,23,27,26,17,24,26,24,27,27,26,24,23,23,24,17,21,19,22,22,18,16,14,12,14,16,8,3,0,5,1,1,3,6,7,8,14) > x <- c(25.7,24.7,24.2,23.6,24.4,22.5,19.4,18.1,18.1,20.7,19.1,18.3,16.9,17.9,20.2,21.2,23.8,24,26.6,25.3,27.6,24.7,26.6,24.4,24.6,26,24.8,24,22.7,23,24.1,24,22.7,22.6,23.1,24.4,23,22,21.3,21.5,21.3,23.2,21.8,23.3,21,22.4,20.4,19.9,21.3,18.9,15.6,12.5,7.8,5.5,4,3.3,3.7,3.1,5,6.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.5975239 0.5982476 0.5989732 0.5997005 0.6004296 0.6011605 0.6018932 [8] 0.6026276 0.6033637 0.6041017 0.6048414 0.6055828 0.6063260 0.6070709 [15] 0.6078175 0.6085659 0.6093160 0.6100679 0.6108214 0.6115766 0.6123336 [22] 0.6130922 0.6138526 0.6146146 0.6153783 0.6161437 0.6169107 0.6176794 [29] 0.6184498 0.6192217 0.6199954 0.6207706 0.6215475 0.6223260 0.6231060 [36] 0.6238877 0.6246710 0.6254558 0.6262422 0.6270301 0.6278196 0.6286107 [43] 0.6294032 0.6301973 0.6309929 0.6317899 0.6325885 0.6333885 0.6341900 [50] 0.6349929 0.6357972 0.6366030 0.6374102 0.6382188 0.6390288 0.6398401 [57] 0.6406528 0.6414668 0.6422822 0.6430989 0.6439169 0.6447361 0.6455567 [64] 0.6463784 0.6472015 0.6480257 0.6488512 0.6496778 0.6505057 0.6513346 [71] 0.6521648 0.6529960 0.6538284 0.6546618 0.6554963 0.6563319 0.6571685 [78] 0.6580061 0.6588447 0.6596842 0.6605248 0.6613662 0.6622086 0.6630519 [85] 0.6638960 0.6647410 0.6655869 0.6664335 0.6672810 0.6681292 0.6689781 [92] 0.6698278 0.6706782 0.6715292 0.6723809 0.6732332 0.6740862 0.6749397 [99] 0.6757938 0.6766484 0.6775035 0.6783591 0.6792151 0.6800716 0.6809285 [106] 0.6817858 0.6826434 0.6835014 0.6843597 0.6852182 0.6860770 0.6869360 [113] 0.6877952 0.6886545 0.6895140 0.6903736 0.6912333 0.6920930 0.6929527 [120] 0.6938125 0.6946722 0.6955318 0.6963913 0.6972507 0.6981100 0.6989690 [127] 0.6998278 0.7006864 0.7015447 0.7024027 0.7032603 0.7041176 0.7049744 [134] 0.7058308 0.7066868 0.7075422 0.7083971 0.7092514 0.7101051 0.7109581 [141] 0.7118105 0.7126622 0.7135132 0.7143633 0.7152127 0.7160612 0.7169089 [148] 0.7177556 0.7186014 0.7194462 0.7202900 0.7211327 0.7219744 0.7228149 [155] 0.7236543 0.7244925 0.7253295 0.7261652 0.7269996 0.7278327 0.7286644 [162] 0.7294947 0.7303236 0.7311509 0.7319768 0.7328011 0.7336239 0.7344450 [169] 0.7352645 0.7360822 0.7368983 0.7377126 0.7385250 0.7393357 0.7401444 [176] 0.7409513 0.7417562 0.7425591 0.7433600 0.7441588 0.7449556 0.7457502 [183] 0.7465427 0.7473329 0.7481209 0.7489067 0.7496901 0.7504712 0.7512499 [190] 0.7520262 0.7528001 0.7535714 0.7543403 0.7551065 0.7558702 0.7566313 [197] 0.7573897 0.7581454 0.7588983 0.7596485 0.7603959 0.7611405 0.7618822 [204] 0.7626209 0.7633568 0.7640897 0.7648195 0.7655464 0.7662701 0.7669908 [211] 0.7677083 0.7684227 0.7691338 0.7698417 0.7705464 0.7712477 0.7719457 [218] 0.7726404 0.7733317 0.7740196 0.7747040 0.7753849 0.7760623 0.7767362 [225] 0.7774065 0.7780732 0.7787363 0.7793957 0.7800514 0.7807035 0.7813517 [232] 0.7819963 0.7826370 0.7832739 0.7839070 0.7845361 0.7851614 0.7857828 [239] 0.7864002 0.7870137 0.7876231 0.7882285 0.7888299 0.7894272 0.7900205 [246] 0.7906096 0.7911945 0.7917754 0.7923520 0.7929244 0.7934927 0.7940566 [253] 0.7946163 0.7951718 0.7957229 0.7962697 0.7968122 0.7973503 0.7978841 [260] 0.7984134 0.7989384 0.7994589 0.7999750 0.8004866 0.8009937 0.8014964 [267] 0.8019946 0.8024882 0.8029774 0.8034620 0.8039420 0.8044174 0.8048883 [274] 0.8053546 0.8058163 0.8062734 0.8067259 0.8071737 0.8076169 0.8080554 [281] 0.8084892 0.8089184 0.8093430 0.8097628 0.8101779 0.8105884 0.8109941 [288] 0.8113951 0.8117914 0.8121830 0.8125699 0.8129520 0.8133294 0.8137020 [295] 0.8140699 0.8144331 0.8147915 0.8151452 0.8154941 0.8158382 0.8161776 [302] 0.8165123 0.8168422 0.8171673 0.8174877 0.8178033 0.8181142 0.8184203 [309] 0.8187217 0.8190183 0.8193102 0.8195973 0.8198798 0.8201574 0.8204304 [316] 0.8206986 0.8209621 0.8212209 0.8214750 0.8217244 0.8219690 0.8222090 [323] 0.8224443 0.8226750 0.8229009 0.8231222 0.8233388 0.8235508 0.8237582 [330] 0.8239609 0.8241590 0.8243525 0.8245415 0.8247258 0.8249055 0.8250807 [337] 0.8252513 0.8254173 0.8255789 0.8257359 0.8258883 0.8260363 0.8261798 [344] 0.8263189 0.8264534 0.8265835 0.8267092 0.8268305 0.8269473 0.8270598 [351] 0.8271678 0.8272715 0.8273709 0.8274659 0.8275566 0.8276430 0.8277251 [358] 0.8278029 0.8278765 0.8279458 0.8280109 0.8280718 0.8281284 0.8281810 [365] 0.8282293 0.8282735 0.8283136 0.8283495 0.8283814 0.8284092 0.8284329 [372] 0.8284526 0.8284683 0.8284799 0.8284876 0.8284913 0.8284911 0.8284869 [379] 0.8284788 0.8284668 0.8284510 0.8284313 0.8284077 0.8283803 0.8283492 [386] 0.8283142 0.8282755 0.8282330 0.8281869 0.8281370 0.8280834 0.8280262 [393] 0.8279653 0.8279008 0.8278327 0.8277610 0.8276858 0.8276070 0.8275247 [400] 0.8274389 0.8273495 > mx [1] 0.8284913 > mxli [1] 1.75 > 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/1cm7c1257964325.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/2zx401257964325.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/3ts151257964325.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/4gqg31257964325.tab") > > system("convert tmp/1cm7c1257964325.ps tmp/1cm7c1257964325.png") > system("convert tmp/2zx401257964325.ps tmp/2zx401257964325.png") > system("convert tmp/3ts151257964325.ps tmp/3ts151257964325.png") > > > proc.time() user system elapsed 0.775 0.503 0.964