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.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,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(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,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.8999851 0.9003373 0.9006881 0.9010378 0.9013861 0.9017332 0.9020790 [8] 0.9024235 0.9027668 0.9031088 0.9034495 0.9037890 0.9041272 0.9044642 [15] 0.9047999 0.9051343 0.9054674 0.9057993 0.9061300 0.9064594 0.9067875 [22] 0.9071144 0.9074400 0.9077643 0.9080874 0.9084093 0.9087299 0.9090492 [29] 0.9093673 0.9096842 0.9099998 0.9103142 0.9106273 0.9109391 0.9112498 [36] 0.9115591 0.9118673 0.9121742 0.9124798 0.9127842 0.9130874 0.9133894 [43] 0.9136901 0.9139895 0.9142878 0.9145848 0.9148806 0.9151751 0.9154685 [50] 0.9157606 0.9160514 0.9163411 0.9166295 0.9169167 0.9172027 0.9174875 [57] 0.9177710 0.9180533 0.9183345 0.9186144 0.9188930 0.9191705 0.9194468 [64] 0.9197219 0.9199957 0.9202684 0.9205398 0.9208101 0.9210791 0.9213469 [71] 0.9216136 0.9218790 0.9221433 0.9224064 0.9226682 0.9229289 0.9231884 [78] 0.9234467 0.9237038 0.9239597 0.9242145 0.9244680 0.9247204 0.9249716 [85] 0.9252217 0.9254705 0.9257182 0.9259647 0.9262101 0.9264542 0.9266972 [92] 0.9269391 0.9271797 0.9274192 0.9276576 0.9278948 0.9281308 0.9283657 [99] 0.9285994 0.9288320 0.9290634 0.9292937 0.9295228 0.9297508 0.9299776 [106] 0.9302033 0.9304278 0.9306512 0.9308735 0.9310947 0.9313147 0.9315335 [113] 0.9317513 0.9319679 0.9321834 0.9323977 0.9326110 0.9328231 0.9330341 [120] 0.9332440 0.9334527 0.9336604 0.9338669 0.9340724 0.9342767 0.9344799 [127] 0.9346820 0.9348830 0.9350829 0.9352817 0.9354794 0.9356760 0.9358715 [134] 0.9360659 0.9362593 0.9364515 0.9366427 0.9368327 0.9370217 0.9372096 [141] 0.9373964 0.9375822 0.9377669 0.9379505 0.9381330 0.9383145 0.9384948 [148] 0.9386742 0.9388524 0.9390296 0.9392058 0.9393808 0.9395548 0.9397278 [155] 0.9398997 0.9400706 0.9402404 0.9404092 0.9405769 0.9407436 0.9409092 [162] 0.9410738 0.9412373 0.9413999 0.9415614 0.9417218 0.9418812 0.9420396 [169] 0.9421970 0.9423533 0.9425087 0.9426630 0.9428163 0.9429685 0.9431198 [176] 0.9432700 0.9434193 0.9435675 0.9437147 0.9438609 0.9440061 0.9441503 [183] 0.9442935 0.9444358 0.9445770 0.9447172 0.9448564 0.9449947 0.9451319 [190] 0.9452682 0.9454035 0.9455378 0.9456711 0.9458035 0.9459349 0.9460653 [197] 0.9461947 0.9463231 0.9464506 0.9465772 0.9467027 0.9468273 0.9469510 [204] 0.9470736 0.9471954 0.9473161 0.9474359 0.9475548 0.9476727 0.9477897 [211] 0.9479057 0.9480208 0.9481350 0.9482482 0.9483604 0.9484718 0.9485822 [218] 0.9486917 0.9488002 0.9489078 0.9490145 0.9491203 0.9492251 0.9493290 [225] 0.9494321 0.9495341 0.9496353 0.9497356 0.9498350 0.9499334 0.9500310 [232] 0.9501276 0.9502233 0.9503182 0.9504121 0.9505052 0.9505973 0.9506886 [239] 0.9507789 0.9508684 0.9509570 0.9510447 0.9511316 0.9512175 0.9513026 [246] 0.9513868 0.9514701 0.9515525 0.9516341 0.9517148 0.9517946 0.9518736 [253] 0.9519517 0.9520289 0.9521053 0.9521808 0.9522555 0.9523293 0.9524022 [260] 0.9524744 0.9525456 0.9526160 0.9526856 0.9527543 0.9528222 0.9528892 [267] 0.9529554 0.9530208 0.9530853 0.9531490 0.9532119 0.9532740 0.9533352 [274] 0.9533956 0.9534551 0.9535139 0.9535718 0.9536289 0.9536852 0.9537407 [281] 0.9537954 0.9538492 0.9539023 0.9539545 0.9540060 0.9540566 0.9541064 [288] 0.9541555 0.9542037 0.9542512 0.9542978 0.9543437 0.9543887 0.9544330 [295] 0.9544765 0.9545192 0.9545612 0.9546023 0.9546427 0.9546822 0.9547211 [302] 0.9547591 0.9547964 0.9548329 0.9548686 0.9549035 0.9549377 0.9549712 [309] 0.9550038 0.9550357 0.9550669 0.9550973 0.9551269 0.9551558 0.9551839 [316] 0.9552113 0.9552379 0.9552638 0.9552890 0.9553134 0.9553370 0.9553599 [323] 0.9553821 0.9554036 0.9554243 0.9554442 0.9554635 0.9554820 0.9554998 [330] 0.9555169 0.9555332 0.9555488 0.9555637 0.9555779 0.9555914 0.9556041 [337] 0.9556161 0.9556275 0.9556381 0.9556480 0.9556571 0.9556656 0.9556734 [344] 0.9556805 0.9556869 0.9556925 0.9556975 0.9557018 0.9557054 0.9557083 [351] 0.9557105 0.9557120 0.9557128 0.9557130 0.9557124 0.9557112 0.9557093 [358] 0.9557067 0.9557035 0.9556995 0.9556949 0.9556896 0.9556836 0.9556770 [365] 0.9556697 0.9556617 0.9556531 0.9556438 0.9556339 0.9556232 0.9556120 [372] 0.9556000 0.9555874 0.9555742 0.9555603 0.9555457 0.9555305 0.9555147 [379] 0.9554982 0.9554810 0.9554632 0.9554448 0.9554257 0.9554060 0.9553857 [386] 0.9553647 0.9553431 0.9553208 0.9552979 0.9552744 0.9552503 0.9552255 [393] 0.9552001 0.9551741 0.9551474 0.9551202 0.9550923 0.9550638 0.9550347 [400] 0.9550049 0.9549746 > mx [1] 0.955713 > mxli [1] 1.53 > 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/1ls211257887079.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/2wrnu1257887079.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/3pycw1257887079.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/42aat1257887079.tab") > > system("convert tmp/1ls211257887079.ps tmp/1ls211257887079.png") > system("convert tmp/2wrnu1257887079.ps tmp/2wrnu1257887079.png") > system("convert tmp/3pycw1257887079.ps tmp/3pycw1257887079.png") > > > proc.time() user system elapsed 0.788 0.515 0.953