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(7.5,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) > #'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.9333505 0.9333226 0.9332945 0.9332662 0.9332377 0.9332090 0.9331801 [8] 0.9331510 0.9331218 0.9330923 0.9330626 0.9330328 0.9330028 0.9329725 [15] 0.9329421 0.9329115 0.9328807 0.9328497 0.9328185 0.9327871 0.9327555 [22] 0.9327238 0.9326918 0.9326597 0.9326273 0.9325948 0.9325621 0.9325292 [29] 0.9324961 0.9324628 0.9324293 0.9323956 0.9323617 0.9323277 0.9322935 [36] 0.9322590 0.9322244 0.9321896 0.9321546 0.9321194 0.9320841 0.9320485 [43] 0.9320127 0.9319768 0.9319407 0.9319044 0.9318679 0.9318312 0.9317943 [50] 0.9317573 0.9317200 0.9316826 0.9316450 0.9316072 0.9315692 0.9315310 [57] 0.9314926 0.9314541 0.9314154 0.9313764 0.9313373 0.9312980 0.9312586 [64] 0.9312189 0.9311791 0.9311390 0.9310988 0.9310584 0.9310179 0.9309771 [71] 0.9309362 0.9308950 0.9308537 0.9308122 0.9307705 0.9307287 0.9306866 [78] 0.9306444 0.9306020 0.9305594 0.9305167 0.9304737 0.9304306 0.9303873 [85] 0.9303438 0.9303001 0.9302562 0.9302122 0.9301680 0.9301236 0.9300790 [92] 0.9300343 0.9299893 0.9299442 0.9298989 0.9298534 0.9298078 0.9297620 [99] 0.9297159 0.9296698 0.9296234 0.9295769 0.9295301 0.9294832 0.9294362 [106] 0.9293889 0.9293415 0.9292939 0.9292461 0.9291981 0.9291500 0.9291017 [113] 0.9290532 0.9290045 0.9289557 0.9289066 0.9288574 0.9288081 0.9287585 [120] 0.9287088 0.9286589 0.9286089 0.9285586 0.9285082 0.9284576 0.9284068 [127] 0.9283559 0.9283048 0.9282535 0.9282021 0.9281504 0.9280986 0.9280467 [134] 0.9279945 0.9279422 0.9278897 0.9278370 0.9277842 0.9277312 0.9276780 [141] 0.9276247 0.9275711 0.9275175 0.9274636 0.9274096 0.9273554 0.9273010 [148] 0.9272465 0.9271917 0.9271369 0.9270818 0.9270266 0.9269712 0.9269157 [155] 0.9268599 0.9268040 0.9267480 0.9266917 0.9266354 0.9265788 0.9265221 [162] 0.9264652 0.9264081 0.9263509 0.9262935 0.9262359 0.9261782 0.9261203 [169] 0.9260622 0.9260040 0.9259456 0.9258870 0.9258283 0.9257694 0.9257104 [176] 0.9256511 0.9255918 0.9255322 0.9254725 0.9254126 0.9253526 0.9252924 [183] 0.9252320 0.9251715 0.9251108 0.9250499 0.9249889 0.9249277 0.9248664 [190] 0.9248049 0.9247432 0.9246814 0.9246194 0.9245573 0.9244950 0.9244325 [197] 0.9243699 0.9243071 0.9242441 0.9241810 0.9241177 0.9240543 0.9239907 [204] 0.9239270 0.9238630 0.9237990 0.9237347 0.9236704 0.9236058 0.9235411 [211] 0.9234763 0.9234112 0.9233461 0.9232807 0.9232152 0.9231496 0.9230838 [218] 0.9230178 0.9229517 0.9228854 0.9228190 0.9227524 0.9226857 0.9226188 [225] 0.9225517 0.9224845 0.9224172 0.9223497 0.9222820 0.9222142 0.9221462 [232] 0.9220780 0.9220098 0.9219413 0.9218727 0.9218040 0.9217351 0.9216660 [239] 0.9215968 0.9215275 0.9214580 0.9213883 0.9213185 0.9212485 0.9211784 [246] 0.9211081 0.9210377 0.9209671 0.9208964 0.9208256 0.9207545 0.9206834 [253] 0.9206120 0.9205406 0.9204690 0.9203972 0.9203253 0.9202532 0.9201810 [260] 0.9201086 0.9200361 0.9199634 0.9198906 0.9198177 0.9197446 0.9196713 [267] 0.9195979 0.9195244 0.9194507 0.9193769 0.9193029 0.9192287 0.9191545 [274] 0.9190800 0.9190055 0.9189308 0.9188559 0.9187809 0.9187057 0.9186304 [281] 0.9185550 0.9184794 0.9184037 0.9183278 0.9182518 0.9181757 0.9180994 [288] 0.9180229 0.9179463 0.9178696 0.9177927 0.9177157 0.9176386 0.9175613 [295] 0.9174838 0.9174062 0.9173285 0.9172507 0.9171727 0.9170945 0.9170162 [302] 0.9169378 0.9168592 0.9167805 0.9167017 0.9166227 0.9165436 0.9164643 [309] 0.9163849 0.9163054 0.9162257 0.9161459 0.9160659 0.9159858 0.9159056 [316] 0.9158252 0.9157447 0.9156641 0.9155833 0.9155024 0.9154213 0.9153401 [323] 0.9152588 0.9151773 0.9150957 0.9150140 0.9149321 0.9148501 0.9147680 [330] 0.9146857 0.9146033 0.9145208 0.9144381 0.9143553 0.9142723 0.9141892 [337] 0.9141060 0.9140227 0.9139392 0.9138556 0.9137718 0.9136880 0.9136040 [344] 0.9135198 0.9134355 0.9133511 0.9132666 0.9131819 0.9130971 0.9130122 [351] 0.9129271 0.9128419 0.9127566 0.9126712 0.9125856 0.9124999 0.9124140 [358] 0.9123280 0.9122419 0.9121557 0.9120694 0.9119829 0.9118963 0.9118095 [365] 0.9117226 0.9116356 0.9115485 0.9114613 0.9113739 0.9112864 0.9111987 [372] 0.9111110 0.9110231 0.9109351 0.9108469 0.9107587 0.9106703 0.9105817 [379] 0.9104931 0.9104043 0.9103154 0.9102264 0.9101373 0.9100480 0.9099586 [386] 0.9098691 0.9097795 0.9096897 0.9095998 0.9095098 0.9094197 0.9093294 [393] 0.9092390 0.9091485 0.9090579 0.9089672 0.9088763 0.9087853 0.9086942 [400] 0.9086030 0.9085116 > mx [1] 0.9333505 > 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/1c4z01229896183.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/2rjcs1229896183.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/3g2hf1229896183.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/413n21229896183.tab") > > system("convert tmp/1c4z01229896183.ps tmp/1c4z01229896183.png") > system("convert tmp/2rjcs1229896183.ps tmp/2rjcs1229896183.png") > system("convert tmp/3g2hf1229896183.ps tmp/3g2hf1229896183.png") > > > proc.time() user system elapsed 0.774 0.504 0.909