R version 2.8.0 (2008-10-20) 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(8.3,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) > x <- c(9.4,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) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2007), Box-Cox Linearity Plot (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxlin.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description > 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.9394048 0.9395061 0.9396069 0.9397073 0.9398071 0.9399064 0.9400052 [8] 0.9401036 0.9402014 0.9402988 0.9403956 0.9404920 0.9405878 0.9406832 [15] 0.9407780 0.9408724 0.9409662 0.9410596 0.9411525 0.9412448 0.9413367 [22] 0.9414280 0.9415188 0.9416092 0.9416990 0.9417883 0.9418771 0.9419654 [29] 0.9420532 0.9421405 0.9422273 0.9423136 0.9423993 0.9424846 0.9425693 [36] 0.9426535 0.9427372 0.9428204 0.9429031 0.9429852 0.9430669 0.9431480 [43] 0.9432286 0.9433087 0.9433883 0.9434673 0.9435459 0.9436239 0.9437014 [50] 0.9437784 0.9438548 0.9439307 0.9440062 0.9440810 0.9441554 0.9442292 [57] 0.9443025 0.9443753 0.9444476 0.9445193 0.9445905 0.9446612 0.9447313 [64] 0.9448009 0.9448700 0.9449386 0.9450066 0.9450741 0.9451410 0.9452075 [71] 0.9452734 0.9453387 0.9454035 0.9454678 0.9455316 0.9455948 0.9456575 [78] 0.9457196 0.9457812 0.9458423 0.9459028 0.9459628 0.9460223 0.9460812 [85] 0.9461396 0.9461974 0.9462547 0.9463114 0.9463676 0.9464233 0.9464784 [92] 0.9465330 0.9465870 0.9466405 0.9466935 0.9467459 0.9467977 0.9468490 [99] 0.9468998 0.9469500 0.9469996 0.9470487 0.9470973 0.9471453 0.9471928 [106] 0.9472397 0.9472860 0.9473318 0.9473771 0.9474218 0.9474659 0.9475095 [113] 0.9475526 0.9475951 0.9476370 0.9476784 0.9477192 0.9477595 0.9477992 [120] 0.9478384 0.9478770 0.9479150 0.9479525 0.9479894 0.9480258 0.9480616 [127] 0.9480968 0.9481315 0.9481657 0.9481992 0.9482322 0.9482647 0.9482966 [134] 0.9483279 0.9483587 0.9483889 0.9484185 0.9484476 0.9484761 0.9485040 [141] 0.9485314 0.9485582 0.9485845 0.9486101 0.9486353 0.9486598 0.9486838 [148] 0.9487072 0.9487301 0.9487524 0.9487741 0.9487952 0.9488158 0.9488358 [155] 0.9488552 0.9488741 0.9488924 0.9489101 0.9489273 0.9489439 0.9489599 [162] 0.9489754 0.9489902 0.9490045 0.9490183 0.9490314 0.9490440 0.9490560 [169] 0.9490675 0.9490783 0.9490886 0.9490984 0.9491075 0.9491161 0.9491241 [176] 0.9491315 0.9491383 0.9491446 0.9491503 0.9491554 0.9491600 0.9491639 [183] 0.9491673 0.9491701 0.9491724 0.9491740 0.9491751 0.9491756 0.9491755 [190] 0.9491749 0.9491736 0.9491718 0.9491694 0.9491664 0.9491629 0.9491588 [197] 0.9491541 0.9491488 0.9491429 0.9491364 0.9491294 0.9491218 0.9491136 [204] 0.9491048 0.9490955 0.9490856 0.9490750 0.9490639 0.9490523 0.9490400 [211] 0.9490272 0.9490137 0.9489997 0.9489851 0.9489700 0.9489542 0.9489379 [218] 0.9489209 0.9489034 0.9488854 0.9488667 0.9488474 0.9488276 0.9488072 [225] 0.9487862 0.9487646 0.9487424 0.9487196 0.9486963 0.9486724 0.9486479 [232] 0.9486228 0.9485971 0.9485708 0.9485440 0.9485166 0.9484885 0.9484599 [239] 0.9484308 0.9484010 0.9483706 0.9483397 0.9483082 0.9482761 0.9482434 [246] 0.9482101 0.9481762 0.9481418 0.9481067 0.9480711 0.9480349 0.9479981 [253] 0.9479607 0.9479228 0.9478842 0.9478451 0.9478054 0.9477650 0.9477242 [260] 0.9476827 0.9476406 0.9475980 0.9475547 0.9475109 0.9474665 0.9474215 [267] 0.9473760 0.9473298 0.9472831 0.9472357 0.9471878 0.9471393 0.9470902 [274] 0.9470406 0.9469903 0.9469395 0.9468881 0.9468360 0.9467835 0.9467303 [281] 0.9466765 0.9466222 0.9465672 0.9465117 0.9464556 0.9463989 0.9463417 [288] 0.9462838 0.9462254 0.9461664 0.9461068 0.9460466 0.9459858 0.9459245 [295] 0.9458625 0.9458000 0.9457369 0.9456732 0.9456090 0.9455441 0.9454787 [302] 0.9454127 0.9453461 0.9452789 0.9452111 0.9451428 0.9450739 0.9450044 [309] 0.9449343 0.9448636 0.9447924 0.9447205 0.9446481 0.9445752 0.9445016 [316] 0.9444274 0.9443527 0.9442774 0.9442015 0.9441250 0.9440480 0.9439704 [323] 0.9438922 0.9438134 0.9437340 0.9436541 0.9435736 0.9434925 0.9434108 [330] 0.9433286 0.9432457 0.9431623 0.9430784 0.9429938 0.9429087 0.9428230 [337] 0.9427367 0.9426498 0.9425624 0.9424744 0.9423858 0.9422967 0.9422069 [344] 0.9421166 0.9420257 0.9419343 0.9418423 0.9417497 0.9416565 0.9415628 [351] 0.9414685 0.9413736 0.9412781 0.9411821 0.9410855 0.9409883 0.9408906 [358] 0.9407923 0.9406934 0.9405940 0.9404940 0.9403934 0.9402923 0.9401905 [365] 0.9400883 0.9399854 0.9398820 0.9397780 0.9396735 0.9395683 0.9394627 [372] 0.9393564 0.9392496 0.9391422 0.9390343 0.9389258 0.9388167 0.9387071 [379] 0.9385969 0.9384862 0.9383749 0.9382630 0.9381505 0.9380376 0.9379240 [386] 0.9378099 0.9376952 0.9375800 0.9374642 0.9373478 0.9372309 0.9371135 [393] 0.9369954 0.9368769 0.9367577 0.9366380 0.9365178 0.9363970 0.9362756 [400] 0.9361537 0.9360313 > mx [1] 0.9491756 > mxli [1] -0.13 > 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/14guc1229039951.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/2p2qu1229039951.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/3nd321229039951.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/4rzec1229039951.tab") > > system("convert tmp/14guc1229039951.ps tmp/14guc1229039951.png") > system("convert tmp/2p2qu1229039951.ps tmp/2p2qu1229039951.png") > system("convert tmp/3nd321229039951.ps tmp/3nd321229039951.png") > > > proc.time() user system elapsed 0.781 0.513 0.957