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(14.2,13.5,11.9,14.6,15.6,14.1,14.9,14.2,14.6,17.2,15.4,14.3,17.5,14.5,14.4,16.6,16.7,16.6,16.9,15.7,16.4,18.4,16.9,16.5,18.3,15.1,15.7,18.1,16.8,18.9,19,18.1,17.8,21.5,17.1,18.7,19,16.4,16.9,18.6,19.3,19.4,17.6,18.6,18.1,20.4,18.1,19.6,19.9,19.2,17.8,19.2,22,21.1,19.5,22.2,20.9,22.2,23.5,21.5,24.3,22.8,20.3,23.7,23.3,19.6,18,17.3,16.8,18.2,16.5,16,18.4) > x <- 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) > #'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.8900586 0.8904448 0.8908296 0.8912131 0.8915953 0.8919761 0.8923555 [8] 0.8927336 0.8931104 0.8934857 0.8938598 0.8942325 0.8946038 0.8949738 [15] 0.8953425 0.8957097 0.8960757 0.8964403 0.8968035 0.8971654 0.8975260 [22] 0.8978852 0.8982430 0.8985995 0.8989547 0.8993085 0.8996610 0.9000121 [29] 0.9003619 0.9007103 0.9010574 0.9014032 0.9017476 0.9020907 0.9024324 [36] 0.9027728 0.9031119 0.9034496 0.9037860 0.9041210 0.9044547 0.9047871 [43] 0.9051182 0.9054479 0.9057762 0.9061033 0.9064290 0.9067534 0.9070765 [50] 0.9073982 0.9077186 0.9080377 0.9083554 0.9086719 0.9089870 0.9093007 [57] 0.9096132 0.9099244 0.9102342 0.9105427 0.9108499 0.9111558 0.9114604 [64] 0.9117636 0.9120656 0.9123662 0.9126655 0.9129635 0.9132603 0.9135557 [71] 0.9138498 0.9141426 0.9144341 0.9147243 0.9150132 0.9153008 0.9155871 [78] 0.9158721 0.9161558 0.9164383 0.9167194 0.9169993 0.9172779 0.9175551 [85] 0.9178311 0.9181059 0.9183793 0.9186515 0.9189223 0.9191919 0.9194603 [92] 0.9197273 0.9199931 0.9202576 0.9205209 0.9207829 0.9210436 0.9213030 [99] 0.9215612 0.9218181 0.9220738 0.9223282 0.9225814 0.9228333 0.9230839 [106] 0.9233334 0.9235815 0.9238284 0.9240741 0.9243185 0.9245617 0.9248036 [113] 0.9250443 0.9252838 0.9255221 0.9257591 0.9259948 0.9262294 0.9264627 [120] 0.9266948 0.9269257 0.9271553 0.9273838 0.9276110 0.9278370 0.9280618 [127] 0.9282854 0.9285077 0.9287289 0.9289489 0.9291676 0.9293852 0.9296015 [134] 0.9298167 0.9300307 0.9302434 0.9304550 0.9306654 0.9308746 0.9310826 [141] 0.9312894 0.9314951 0.9316996 0.9319029 0.9321050 0.9323059 0.9325057 [148] 0.9327043 0.9329018 0.9330981 0.9332932 0.9334871 0.9336799 0.9338716 [155] 0.9340621 0.9342514 0.9344396 0.9346266 0.9348125 0.9349973 0.9351809 [162] 0.9353634 0.9355447 0.9357249 0.9359040 0.9360819 0.9362587 0.9364344 [169] 0.9366090 0.9367824 0.9369547 0.9371259 0.9372960 0.9374650 0.9376329 [176] 0.9377996 0.9379653 0.9381298 0.9382933 0.9384556 0.9386169 0.9387770 [183] 0.9389361 0.9390941 0.9392510 0.9394068 0.9395615 0.9397151 0.9398677 [190] 0.9400192 0.9401696 0.9403189 0.9404672 0.9406144 0.9407605 0.9409056 [197] 0.9410496 0.9411925 0.9413344 0.9414752 0.9416150 0.9417538 0.9418915 [204] 0.9420281 0.9421637 0.9422983 0.9424318 0.9425643 0.9426957 0.9428262 [211] 0.9429555 0.9430839 0.9432113 0.9433376 0.9434629 0.9435872 0.9437104 [218] 0.9438327 0.9439539 0.9440742 0.9441934 0.9443116 0.9444289 0.9445451 [225] 0.9446603 0.9447745 0.9448878 0.9450000 0.9451113 0.9452216 0.9453309 [232] 0.9454392 0.9455465 0.9456529 0.9457583 0.9458627 0.9459661 0.9460686 [239] 0.9461701 0.9462707 0.9463703 0.9464689 0.9465666 0.9466633 0.9467591 [246] 0.9468539 0.9469478 0.9470407 0.9471327 0.9472238 0.9473139 0.9474031 [253] 0.9474913 0.9475787 0.9476651 0.9477505 0.9478351 0.9479187 0.9480014 [260] 0.9480832 0.9481640 0.9482440 0.9483230 0.9484012 0.9484784 0.9485547 [267] 0.9486301 0.9487047 0.9487783 0.9488510 0.9489229 0.9489938 0.9490639 [274] 0.9491331 0.9492014 0.9492688 0.9493353 0.9494010 0.9494658 0.9495297 [281] 0.9495928 0.9496549 0.9497162 0.9497767 0.9498363 0.9498950 0.9499529 [288] 0.9500099 0.9500661 0.9501214 0.9501758 0.9502295 0.9502822 0.9503342 [295] 0.9503853 0.9504355 0.9504850 0.9505335 0.9505813 0.9506282 0.9506743 [302] 0.9507196 0.9507641 0.9508077 0.9508505 0.9508925 0.9509337 0.9509741 [309] 0.9510137 0.9510525 0.9510904 0.9511276 0.9511639 0.9511995 0.9512342 [316] 0.9512682 0.9513014 0.9513338 0.9513654 0.9513962 0.9514262 0.9514554 [323] 0.9514839 0.9515116 0.9515385 0.9515646 0.9515900 0.9516146 0.9516384 [330] 0.9516615 0.9516838 0.9517053 0.9517261 0.9517461 0.9517654 0.9517839 [337] 0.9518017 0.9518187 0.9518349 0.9518505 0.9518652 0.9518793 0.9518926 [344] 0.9519051 0.9519170 0.9519281 0.9519384 0.9519480 0.9519570 0.9519651 [351] 0.9519726 0.9519793 0.9519853 0.9519906 0.9519952 0.9519991 0.9520023 [358] 0.9520047 0.9520064 0.9520075 0.9520078 0.9520074 0.9520064 0.9520046 [365] 0.9520021 0.9519990 0.9519951 0.9519906 0.9519854 0.9519794 0.9519728 [372] 0.9519656 0.9519576 0.9519490 0.9519396 0.9519296 0.9519190 0.9519076 [379] 0.9518956 0.9518829 0.9518696 0.9518556 0.9518409 0.9518256 0.9518096 [386] 0.9517930 0.9517757 0.9517577 0.9517391 0.9517198 0.9516999 0.9516794 [393] 0.9516582 0.9516364 0.9516139 0.9515908 0.9515670 0.9515426 0.9515176 [400] 0.9514920 0.9514657 > mx [1] 0.9520078 > mxli [1] 1.6 > 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/1uhg41257417344.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/2qhm21257417344.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/3ds7u1257417344.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/4stz01257417344.tab") > > system("convert tmp/1uhg41257417344.ps tmp/1uhg41257417344.png") > system("convert tmp/2qhm21257417344.ps tmp/2qhm21257417344.png") > system("convert tmp/3ds7u1257417344.ps tmp/3ds7u1257417344.png") > > > proc.time() user system elapsed 0.803 0.526 1.067