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(9.5,9.1,9,9.3,9.9,9.8,9.4,8.3,8,8.5,10.4,11.1,10.9,9.9,9.2,9.2,9.5,9.6,9.5,9.1,8.9,9,10.1,10.3,10.2,9.6,9.2,9.3,9.4,9.4,9.2,9,9,9,9.8,10,9.9,9.3,9,9,9.1,9.1,9.1,9.2,8.8,8.3,8.4,8.1,7.8,7.9,7.9,8,7.9,7.5,7.2,6.9,6.6,6.7,7.3,7.5) > x <- c(8.4,8.4,8.4,8.6,8.9,8.8,8.3,7.5,7.2,7.5,8.8,9.3,9.3,8.7,8.2,8.3,8.5,8.6,8.6,8.2,8.1,8,8.6,8.7,8.8,8.5,8.4,8.5,8.7,8.7,8.6,8.5,8.3,8.1,8.2,8.1,8.1,7.9,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.6,6.2,6.2,6.8,6.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!) > 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.9403467 0.9404099 0.9404729 0.9405356 0.9405980 0.9406601 0.9407219 [8] 0.9407835 0.9408448 0.9409059 0.9409666 0.9410271 0.9410873 0.9411472 [15] 0.9412069 0.9412662 0.9413253 0.9413841 0.9414427 0.9415010 0.9415590 [22] 0.9416167 0.9416741 0.9417313 0.9417882 0.9418448 0.9419011 0.9419572 [29] 0.9420130 0.9420685 0.9421238 0.9421787 0.9422334 0.9422878 0.9423420 [36] 0.9423959 0.9424495 0.9425028 0.9425558 0.9426086 0.9426611 0.9427133 [43] 0.9427653 0.9428170 0.9428684 0.9429195 0.9429704 0.9430209 0.9430713 [50] 0.9431213 0.9431711 0.9432206 0.9432698 0.9433187 0.9433674 0.9434158 [57] 0.9434639 0.9435118 0.9435594 0.9436067 0.9436537 0.9437005 0.9437470 [64] 0.9437932 0.9438392 0.9438848 0.9439302 0.9439754 0.9440202 0.9440648 [71] 0.9441092 0.9441532 0.9441970 0.9442405 0.9442837 0.9443267 0.9443694 [78] 0.9444118 0.9444540 0.9444959 0.9445375 0.9445788 0.9446199 0.9446607 [85] 0.9447013 0.9447415 0.9447815 0.9448212 0.9448607 0.9448999 0.9449388 [92] 0.9449775 0.9450158 0.9450539 0.9450918 0.9451294 0.9451667 0.9452037 [99] 0.9452405 0.9452770 0.9453132 0.9453492 0.9453849 0.9454203 0.9454555 [106] 0.9454904 0.9455250 0.9455593 0.9455934 0.9456273 0.9456608 0.9456941 [113] 0.9457271 0.9457599 0.9457924 0.9458246 0.9458566 0.9458883 0.9459197 [120] 0.9459508 0.9459817 0.9460124 0.9460427 0.9460728 0.9461027 0.9461322 [127] 0.9461615 0.9461906 0.9462194 0.9462479 0.9462761 0.9463041 0.9463318 [134] 0.9463593 0.9463865 0.9464134 0.9464400 0.9464664 0.9464926 0.9465185 [141] 0.9465441 0.9465694 0.9465945 0.9466193 0.9466439 0.9466682 0.9466922 [148] 0.9467160 0.9467395 0.9467627 0.9467857 0.9468084 0.9468309 0.9468531 [155] 0.9468750 0.9468967 0.9469181 0.9469393 0.9469602 0.9469808 0.9470012 [162] 0.9470213 0.9470412 0.9470608 0.9470801 0.9470992 0.9471180 0.9471365 [169] 0.9471548 0.9471729 0.9471907 0.9472082 0.9472254 0.9472424 0.9472592 [176] 0.9472757 0.9472919 0.9473079 0.9473236 0.9473390 0.9473542 0.9473692 [183] 0.9473839 0.9473983 0.9474125 0.9474264 0.9474400 0.9474534 0.9474666 [190] 0.9474795 0.9474921 0.9475045 0.9475166 0.9475285 0.9475401 0.9475514 [197] 0.9475625 0.9475734 0.9475840 0.9475943 0.9476044 0.9476142 0.9476238 [204] 0.9476331 0.9476421 0.9476510 0.9476595 0.9476678 0.9476759 0.9476837 [211] 0.9476912 0.9476985 0.9477055 0.9477123 0.9477189 0.9477252 0.9477312 [218] 0.9477370 0.9477425 0.9477478 0.9477528 0.9477576 0.9477621 0.9477664 [225] 0.9477704 0.9477742 0.9477777 0.9477810 0.9477840 0.9477868 0.9477893 [232] 0.9477915 0.9477936 0.9477953 0.9477969 0.9477981 0.9477992 0.9478000 [239] 0.9478005 0.9478008 0.9478008 0.9478006 0.9478001 0.9477994 0.9477985 [246] 0.9477973 0.9477958 0.9477941 0.9477922 0.9477900 0.9477876 0.9477849 [253] 0.9477820 0.9477788 0.9477754 0.9477717 0.9477678 0.9477636 0.9477592 [260] 0.9477546 0.9477497 0.9477446 0.9477392 0.9477336 0.9477277 0.9477216 [267] 0.9477153 0.9477087 0.9477018 0.9476947 0.9476874 0.9476798 0.9476720 [274] 0.9476640 0.9476557 0.9476472 0.9476384 0.9476294 0.9476201 0.9476106 [281] 0.9476009 0.9475909 0.9475806 0.9475702 0.9475595 0.9475485 0.9475373 [288] 0.9475259 0.9475143 0.9475024 0.9474902 0.9474778 0.9474652 0.9474523 [295] 0.9474392 0.9474259 0.9474123 0.9473985 0.9473845 0.9473702 0.9473556 [302] 0.9473409 0.9473259 0.9473106 0.9472952 0.9472795 0.9472635 0.9472473 [309] 0.9472309 0.9472142 0.9471974 0.9471802 0.9471629 0.9471453 0.9471274 [316] 0.9471094 0.9470911 0.9470725 0.9470538 0.9470347 0.9470155 0.9469960 [323] 0.9469763 0.9469564 0.9469362 0.9469158 0.9468952 0.9468743 0.9468532 [330] 0.9468319 0.9468103 0.9467885 0.9467664 0.9467442 0.9467217 0.9466990 [337] 0.9466760 0.9466528 0.9466294 0.9466057 0.9465819 0.9465578 0.9465334 [344] 0.9465089 0.9464841 0.9464590 0.9464338 0.9464083 0.9463826 0.9463566 [351] 0.9463305 0.9463041 0.9462774 0.9462506 0.9462235 0.9461962 0.9461686 [358] 0.9461409 0.9461129 0.9460847 0.9460562 0.9460275 0.9459986 0.9459695 [365] 0.9459402 0.9459106 0.9458808 0.9458508 0.9458205 0.9457900 0.9457593 [372] 0.9457284 0.9456973 0.9456659 0.9456343 0.9456025 0.9455704 0.9455382 [379] 0.9455057 0.9454730 0.9454400 0.9454069 0.9453735 0.9453399 0.9453060 [386] 0.9452720 0.9452377 0.9452032 0.9451685 0.9451336 0.9450984 0.9450631 [393] 0.9450275 0.9449916 0.9449556 0.9449194 0.9448829 0.9448462 0.9448093 [400] 0.9447721 0.9447348 > mx [1] 0.9478008 > mxli [1] 0.4 > 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/1t0in1226421707.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/2beoi1226421707.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/39m9z1226421707.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/4naso1226421707.tab") > > system("convert tmp/1t0in1226421707.ps tmp/1t0in1226421707.png") > system("convert tmp/2beoi1226421707.ps tmp/2beoi1226421707.png") > system("convert tmp/39m9z1226421707.ps tmp/39m9z1226421707.png") > > > proc.time() user system elapsed 1.002 0.514 1.160