R version 2.7.0 (2008-04-22) 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(15.1,14.8,16.1,14.3,15.2,14.9,13.1,12.6,13.6,14.4,14,12.9,13.4,13.5,14.8,14.3,14.3,14,13.2,12.2,14.3,15.7,14.2,14.6,14.5,14.3,15.3,14.4,13.7,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) > x <- c(15,14.9,16.8,14.3,15.5,15.6,14.6,12.5,14.8,15.9,14.8,12.9,14.3,14.2,15.9,15.3,15.5,15.1,15,12.1,15.8,16.9,15.1,13.7,14.8,14.7,16,15.4,15,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) > #'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.8847398 0.8850505 0.8853606 0.8856699 0.8859786 0.8862865 0.8865938 [8] 0.8869003 0.8872062 0.8875113 0.8878158 0.8881195 0.8884225 0.8887249 [15] 0.8890265 0.8893274 0.8896276 0.8899271 0.8902259 0.8905239 0.8908213 [22] 0.8911179 0.8914138 0.8917091 0.8920036 0.8922973 0.8925904 0.8928827 [29] 0.8931744 0.8934653 0.8937554 0.8940449 0.8943336 0.8946217 0.8949089 [36] 0.8951955 0.8954814 0.8957665 0.8960509 0.8963345 0.8966175 0.8968997 [43] 0.8971812 0.8974619 0.8977419 0.8980212 0.8982998 0.8985776 0.8988547 [50] 0.8991310 0.8994066 0.8996815 0.8999557 0.9002291 0.9005018 0.9007737 [57] 0.9010449 0.9013154 0.9015851 0.9018541 0.9021223 0.9023898 0.9026566 [64] 0.9029226 0.9031879 0.9034524 0.9037162 0.9039793 0.9042416 0.9045031 [71] 0.9047639 0.9050240 0.9052833 0.9055419 0.9057997 0.9060568 0.9063131 [78] 0.9065687 0.9068236 0.9070777 0.9073310 0.9075836 0.9078354 0.9080865 [85] 0.9083369 0.9085864 0.9088353 0.9090834 0.9093307 0.9095773 0.9098231 [92] 0.9100682 0.9103125 0.9105561 0.9107989 0.9110409 0.9112822 0.9115228 [99] 0.9117626 0.9120016 0.9122399 0.9124774 0.9127142 0.9129502 0.9131855 [106] 0.9134200 0.9136537 0.9138867 0.9141189 0.9143504 0.9145811 0.9148111 [113] 0.9150403 0.9152687 0.9154964 0.9157233 0.9159495 0.9161749 0.9163995 [120] 0.9166234 0.9168466 0.9170689 0.9172905 0.9175114 0.9177315 0.9179508 [127] 0.9181694 0.9183872 0.9186043 0.9188206 0.9190361 0.9192509 0.9194649 [134] 0.9196781 0.9198906 0.9201024 0.9203134 0.9205236 0.9207330 0.9209417 [141] 0.9211497 0.9213569 0.9215633 0.9217689 0.9219738 0.9221780 0.9223814 [148] 0.9225840 0.9227858 0.9229870 0.9231873 0.9233869 0.9235857 0.9237838 [155] 0.9239811 0.9241776 0.9243734 0.9245685 0.9247627 0.9249563 0.9251490 [162] 0.9253410 0.9255323 0.9257228 0.9259125 0.9261015 0.9262897 0.9264772 [169] 0.9266639 0.9268498 0.9270350 0.9272194 0.9274031 0.9275861 0.9277682 [176] 0.9279496 0.9281303 0.9283102 0.9284894 0.9286678 0.9288454 0.9290223 [183] 0.9291985 0.9293739 0.9295485 0.9297224 0.9298955 0.9300679 0.9302395 [190] 0.9304104 0.9305805 0.9307499 0.9309185 0.9310864 0.9312535 0.9314199 [197] 0.9315856 0.9317505 0.9319146 0.9320780 0.9322406 0.9324025 0.9325637 [204] 0.9327241 0.9328837 0.9330427 0.9332008 0.9333583 0.9335149 0.9336709 [211] 0.9338261 0.9339805 0.9341342 0.9342872 0.9344395 0.9345909 0.9347417 [218] 0.9348917 0.9350410 0.9351895 0.9353373 0.9354844 0.9356307 0.9357763 [225] 0.9359211 0.9360652 0.9362086 0.9363512 0.9364931 0.9366343 0.9367747 [232] 0.9369144 0.9370534 0.9371917 0.9373292 0.9374660 0.9376020 0.9377373 [239] 0.9378719 0.9380058 0.9381389 0.9382713 0.9384030 0.9385340 0.9386642 [246] 0.9387937 0.9389225 0.9390505 0.9391779 0.9393045 0.9394304 0.9395555 [253] 0.9396800 0.9398037 0.9399267 0.9400490 0.9401706 0.9402914 0.9404116 [260] 0.9405310 0.9406497 0.9407677 0.9408850 0.9410015 0.9411174 0.9412325 [267] 0.9413470 0.9414607 0.9415737 0.9416860 0.9417975 0.9419084 0.9420186 [274] 0.9421281 0.9422368 0.9423449 0.9424522 0.9425589 0.9426648 0.9427700 [281] 0.9428746 0.9429784 0.9430815 0.9431840 0.9432857 0.9433867 0.9434871 [288] 0.9435867 0.9436856 0.9437839 0.9438814 0.9439783 0.9440745 0.9441699 [295] 0.9442647 0.9443588 0.9444522 0.9445449 0.9446369 0.9447283 0.9448189 [302] 0.9449089 0.9449982 0.9450868 0.9451747 0.9452619 0.9453484 0.9454343 [309] 0.9455195 0.9456040 0.9456878 0.9457709 0.9458534 0.9459352 0.9460163 [316] 0.9460967 0.9461765 0.9462556 0.9463340 0.9464117 0.9464888 0.9465652 [323] 0.9466409 0.9467160 0.9467904 0.9468641 0.9469372 0.9470096 0.9470813 [330] 0.9471524 0.9472228 0.9472925 0.9473616 0.9474300 0.9474978 0.9475649 [337] 0.9476313 0.9476971 0.9477623 0.9478267 0.9478906 0.9479537 0.9480163 [344] 0.9480781 0.9481393 0.9481999 0.9482598 0.9483191 0.9483777 0.9484357 [351] 0.9484930 0.9485497 0.9486058 0.9486611 0.9487159 0.9487700 0.9488235 [358] 0.9488763 0.9489285 0.9489801 0.9490310 0.9490813 0.9491310 0.9491800 [365] 0.9492284 0.9492761 0.9493232 0.9493697 0.9494156 0.9494608 0.9495054 [372] 0.9495494 0.9495928 0.9496355 0.9496776 0.9497191 0.9497600 0.9498002 [379] 0.9498398 0.9498788 0.9499172 0.9499550 0.9499921 0.9500287 0.9500646 [386] 0.9500999 0.9501346 0.9501687 0.9502021 0.9502350 0.9502672 0.9502989 [393] 0.9503299 0.9503604 0.9503902 0.9504194 0.9504480 0.9504760 0.9505034 [400] 0.9505302 0.9505565 > mx [1] 0.9505565 > 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/1jpuo1226412561.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/2nm0s1226412561.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/3duyq1226412561.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/4wdei1226412561.tab") > > system("convert tmp/1jpuo1226412561.ps tmp/1jpuo1226412561.png") > system("convert tmp/2nm0s1226412561.ps tmp/2nm0s1226412561.png") > system("convert tmp/3duyq1226412561.ps tmp/3duyq1226412561.png") > > > proc.time() user system elapsed 1.866 0.826 1.993