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(7.6,7.9,7.9,8.1,8.2,8,7.5,6.8,6.5,6.6,7.6,8,8,7.7,7.5,7.6,7.7,7.9,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.1,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.7,6.4,6.3,6.2,6.5,6.8,6.8,6.5,6.3,5.9,5.9,6.4,6.4,6.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,6.8) > #'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.8976239 0.8977403 0.8978564 0.8979723 0.8980878 0.8982031 0.8983181 [8] 0.8984328 0.8985472 0.8986614 0.8987752 0.8988888 0.8990021 0.8991151 [15] 0.8992279 0.8993403 0.8994525 0.8995644 0.8996760 0.8997873 0.8998984 [22] 0.9000091 0.9001196 0.9002298 0.9003397 0.9004494 0.9005587 0.9006678 [29] 0.9007766 0.9008851 0.9009933 0.9011012 0.9012089 0.9013163 0.9014234 [36] 0.9015302 0.9016367 0.9017429 0.9018489 0.9019545 0.9020599 0.9021650 [43] 0.9022698 0.9023744 0.9024786 0.9025826 0.9026863 0.9027897 0.9028928 [50] 0.9029956 0.9030981 0.9032004 0.9033023 0.9034040 0.9035054 0.9036065 [57] 0.9037074 0.9038079 0.9039081 0.9040081 0.9041078 0.9042072 0.9043063 [64] 0.9044051 0.9045037 0.9046019 0.9046999 0.9047976 0.9048950 0.9049921 [71] 0.9050889 0.9051854 0.9052817 0.9053776 0.9054733 0.9055687 0.9056638 [78] 0.9057586 0.9058531 0.9059473 0.9060413 0.9061349 0.9062283 0.9063214 [85] 0.9064142 0.9065067 0.9065989 0.9066909 0.9067825 0.9068739 0.9069649 [92] 0.9070557 0.9071462 0.9072364 0.9073263 0.9074159 0.9075053 0.9075943 [99] 0.9076831 0.9077716 0.9078597 0.9079476 0.9080352 0.9081226 0.9082096 [106] 0.9082963 0.9083828 0.9084689 0.9085548 0.9086404 0.9087257 0.9088107 [113] 0.9088954 0.9089798 0.9090639 0.9091478 0.9092313 0.9093146 0.9093976 [120] 0.9094803 0.9095627 0.9096448 0.9097266 0.9098081 0.9098893 0.9099703 [127] 0.9100509 0.9101313 0.9102114 0.9102911 0.9103706 0.9104498 0.9105287 [134] 0.9106074 0.9106857 0.9107637 0.9108415 0.9109189 0.9109961 0.9110730 [141] 0.9111495 0.9112258 0.9113018 0.9113776 0.9114530 0.9115281 0.9116029 [148] 0.9116775 0.9117517 0.9118257 0.9118994 0.9119728 0.9120458 0.9121186 [155] 0.9121911 0.9122634 0.9123353 0.9124069 0.9124783 0.9125493 0.9126201 [162] 0.9126905 0.9127607 0.9128306 0.9129002 0.9129695 0.9130385 0.9131072 [169] 0.9131756 0.9132437 0.9133116 0.9133791 0.9134464 0.9135133 0.9135800 [176] 0.9136464 0.9137125 0.9137783 0.9138438 0.9139090 0.9139739 0.9140385 [183] 0.9141029 0.9141669 0.9142306 0.9142941 0.9143573 0.9144201 0.9144827 [190] 0.9145450 0.9146070 0.9146687 0.9147301 0.9147912 0.9148520 0.9149126 [197] 0.9149728 0.9150328 0.9150924 0.9151518 0.9152108 0.9152696 0.9153281 [204] 0.9153863 0.9154442 0.9155018 0.9155591 0.9156161 0.9156729 0.9157293 [211] 0.9157854 0.9158413 0.9158968 0.9159521 0.9160071 0.9160618 0.9161161 [218] 0.9161702 0.9162240 0.9162775 0.9163307 0.9163837 0.9164363 0.9164886 [225] 0.9165407 0.9165924 0.9166439 0.9166950 0.9167459 0.9167965 0.9168468 [232] 0.9168968 0.9169465 0.9169959 0.9170450 0.9170938 0.9171423 0.9171906 [239] 0.9172385 0.9172862 0.9173335 0.9173806 0.9174274 0.9174738 0.9175200 [246] 0.9175659 0.9176115 0.9176568 0.9177019 0.9177466 0.9177910 0.9178351 [253] 0.9178790 0.9179225 0.9179658 0.9180088 0.9180514 0.9180938 0.9181359 [260] 0.9181777 0.9182192 0.9182604 0.9183013 0.9183419 0.9183823 0.9184223 [267] 0.9184621 0.9185015 0.9185407 0.9185795 0.9186181 0.9186564 0.9186944 [274] 0.9187321 0.9187695 0.9188066 0.9188434 0.9188800 0.9189162 0.9189521 [281] 0.9189878 0.9190231 0.9190582 0.9190930 0.9191275 0.9191617 0.9191956 [288] 0.9192292 0.9192625 0.9192955 0.9193282 0.9193607 0.9193928 0.9194247 [295] 0.9194562 0.9194875 0.9195185 0.9195491 0.9195795 0.9196096 0.9196394 [302] 0.9196689 0.9196982 0.9197271 0.9197557 0.9197841 0.9198121 0.9198399 [309] 0.9198674 0.9198946 0.9199215 0.9199481 0.9199744 0.9200004 0.9200261 [316] 0.9200515 0.9200767 0.9201015 0.9201261 0.9201503 0.9201743 0.9201980 [323] 0.9202214 0.9202445 0.9202673 0.9202898 0.9203120 0.9203340 0.9203556 [330] 0.9203770 0.9203980 0.9204188 0.9204393 0.9204595 0.9204794 0.9204990 [337] 0.9205183 0.9205373 0.9205561 0.9205745 0.9205927 0.9206105 0.9206281 [344] 0.9206454 0.9206624 0.9206791 0.9206955 0.9207116 0.9207274 0.9207430 [351] 0.9207582 0.9207732 0.9207879 0.9208022 0.9208163 0.9208301 0.9208436 [358] 0.9208569 0.9208698 0.9208824 0.9208948 0.9209069 0.9209186 0.9209301 [365] 0.9209413 0.9209522 0.9209628 0.9209731 0.9209832 0.9209929 0.9210024 [372] 0.9210115 0.9210204 0.9210290 0.9210373 0.9210453 0.9210530 0.9210605 [379] 0.9210676 0.9210745 0.9210810 0.9210873 0.9210933 0.9210990 0.9211044 [386] 0.9211095 0.9211144 0.9211189 0.9211232 0.9211272 0.9211308 0.9211342 [393] 0.9211373 0.9211402 0.9211427 0.9211449 0.9211469 0.9211486 0.9211499 [400] 0.9211510 0.9211518 > mx [1] 0.9211518 > 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/1nc7y1226515360.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/2lfky1226515360.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/3gl6x1226515360.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/405qs1226515361.tab") > > system("convert tmp/1nc7y1226515360.ps tmp/1nc7y1226515360.png") > system("convert tmp/2lfky1226515360.ps tmp/2lfky1226515360.png") > system("convert tmp/3gl6x1226515360.ps tmp/3gl6x1226515360.png") > > > proc.time() user system elapsed 0.998 0.491 1.529