R version 2.6.0 (2007-10-03) Copyright (C) 2007 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(96.8,87.0,96.3,107.1,115.2,106.1,89.5,91.3,97.6,100.7,104.6,94.7,101.8,102.5,105.3,110.3,109.8,117.3,118.8,131.3,125.9,133.1,147.0,145.8,164.4,149.8,137.7,151.7,156.8,180.0,180.4,170.4,191.6,199.5,218.2,217.5,205.0,194.0,199.3,219.3,211.1,215.2,240.2,242.2,240.7,255.4,253.0,218.2,203.7,205.6,215.6,188.5,202.9,214.0,230.3,230.0,241.0,259.6,247.8,270.3) > x <- c(96.8,91.2,97.1,104.9,110.9,104.8,94.1,95.8,99.3,101.1,104.0,99.0,105.4,107.1,110.7,117.1,118.7,126.5,127.5,134.6,131.8,135.9,142.7,141.7,153.4,145.0,137.7,148.3,152.2,169.4,168.6,161.1,174.1,179.0,190.6,190.0,181.6,174.8,180.5,196.8,193.8,197.0,216.3,221.4,217.9,229.7,227.4,204.2,196.6,198.8,207.5,190.7,201.6,210.5,223.5,223.8,231.2,244.0,234.7,250.2) > #'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.9349364 0.9352888 0.9356406 0.9359917 0.9363421 0.9366919 0.9370410 [8] 0.9373895 0.9377373 0.9380844 0.9384308 0.9387765 0.9391215 0.9394659 [15] 0.9398095 0.9401524 0.9404946 0.9408361 0.9411769 0.9415169 0.9418563 [22] 0.9421948 0.9425326 0.9428697 0.9432060 0.9435416 0.9438764 0.9442104 [29] 0.9445437 0.9448762 0.9452078 0.9455387 0.9458689 0.9461982 0.9465267 [36] 0.9468544 0.9471812 0.9475073 0.9478325 0.9481569 0.9484805 0.9488032 [43] 0.9491251 0.9494462 0.9497664 0.9500857 0.9504041 0.9507217 0.9510385 [50] 0.9513543 0.9516692 0.9519833 0.9522965 0.9526087 0.9529201 0.9532306 [57] 0.9535401 0.9538487 0.9541564 0.9544632 0.9547690 0.9550739 0.9553778 [64] 0.9556808 0.9559829 0.9562840 0.9565841 0.9568833 0.9571814 0.9574786 [71] 0.9577748 0.9580701 0.9583643 0.9586575 0.9589498 0.9592410 0.9595312 [78] 0.9598204 0.9601086 0.9603957 0.9606819 0.9609669 0.9612510 0.9615340 [85] 0.9618159 0.9620968 0.9623766 0.9626554 0.9629331 0.9632097 0.9634852 [92] 0.9637597 0.9640330 0.9643053 0.9645765 0.9648465 0.9651155 0.9653833 [99] 0.9656501 0.9659157 0.9661802 0.9664435 0.9667057 0.9669668 0.9672268 [106] 0.9674856 0.9677432 0.9679997 0.9682550 0.9685092 0.9687621 0.9690140 [113] 0.9692646 0.9695140 0.9697623 0.9700094 0.9702553 0.9704999 0.9707434 [120] 0.9709857 0.9712267 0.9714665 0.9717051 0.9719425 0.9721787 0.9724136 [127] 0.9726473 0.9728797 0.9731109 0.9733409 0.9735696 0.9737970 0.9740232 [134] 0.9742481 0.9744717 0.9746941 0.9749151 0.9751349 0.9753535 0.9755707 [141] 0.9757866 0.9760012 0.9762146 0.9764266 0.9766373 0.9768467 0.9770548 [148] 0.9772616 0.9774671 0.9776712 0.9778740 0.9780754 0.9782756 0.9784744 [155] 0.9786718 0.9788679 0.9790626 0.9792560 0.9794481 0.9796387 0.9798280 [162] 0.9800160 0.9802025 0.9803877 0.9805716 0.9807540 0.9809350 0.9811147 [169] 0.9812930 0.9814699 0.9816454 0.9818194 0.9819921 0.9821634 0.9823333 [176] 0.9825018 0.9826688 0.9828344 0.9829987 0.9831614 0.9833228 0.9834828 [183] 0.9836413 0.9837983 0.9839540 0.9841082 0.9842610 0.9844123 0.9845621 [190] 0.9847106 0.9848575 0.9850031 0.9851471 0.9852897 0.9854309 0.9855706 [197] 0.9857088 0.9858456 0.9859808 0.9861146 0.9862470 0.9863779 0.9865072 [204] 0.9866351 0.9867616 0.9868865 0.9870100 0.9871319 0.9872524 0.9873714 [211] 0.9874889 0.9876049 0.9877194 0.9878324 0.9879439 0.9880539 0.9881624 [218] 0.9882694 0.9883749 0.9884788 0.9885813 0.9886822 0.9887817 0.9888796 [225] 0.9889760 0.9890709 0.9891643 0.9892561 0.9893465 0.9894353 0.9895226 [232] 0.9896084 0.9896926 0.9897753 0.9898565 0.9899362 0.9900143 0.9900909 [239] 0.9901660 0.9902395 0.9903115 0.9903820 0.9904509 0.9905183 0.9905842 [246] 0.9906485 0.9907113 0.9907725 0.9908322 0.9908904 0.9909470 0.9910021 [253] 0.9910557 0.9911077 0.9911582 0.9912071 0.9912545 0.9913004 0.9913447 [260] 0.9913874 0.9914286 0.9914683 0.9915065 0.9915430 0.9915781 0.9916116 [267] 0.9916436 0.9916740 0.9917029 0.9917302 0.9917560 0.9917802 0.9918029 [274] 0.9918241 0.9918437 0.9918618 0.9918784 0.9918934 0.9919068 0.9919188 [281] 0.9919291 0.9919380 0.9919453 0.9919511 0.9919553 0.9919580 0.9919592 [288] 0.9919588 0.9919569 0.9919535 0.9919485 0.9919420 0.9919340 0.9919244 [295] 0.9919133 0.9919007 0.9918866 0.9918709 0.9918537 0.9918350 0.9918147 [302] 0.9917930 0.9917697 0.9917449 0.9917186 0.9916908 0.9916614 0.9916306 [309] 0.9915982 0.9915643 0.9915289 0.9914920 0.9914536 0.9914137 0.9913723 [316] 0.9913294 0.9912850 0.9912391 0.9911916 0.9911427 0.9910923 0.9910405 [323] 0.9909871 0.9909322 0.9908759 0.9908180 0.9907587 0.9906979 0.9906356 [330] 0.9905719 0.9905067 0.9904400 0.9903718 0.9903022 0.9902310 0.9901585 [337] 0.9900844 0.9900090 0.9899320 0.9898536 0.9897738 0.9896925 0.9896097 [344] 0.9895255 0.9894399 0.9893528 0.9892642 0.9891743 0.9890829 0.9889901 [351] 0.9888958 0.9888001 0.9887030 0.9886045 0.9885046 0.9884032 0.9883004 [358] 0.9881962 0.9880907 0.9879837 0.9878753 0.9877655 0.9876543 0.9875417 [365] 0.9874277 0.9873123 0.9871956 0.9870774 0.9869579 0.9868370 0.9867148 [372] 0.9865911 0.9864661 0.9863397 0.9862120 0.9860829 0.9859525 0.9858207 [379] 0.9856875 0.9855530 0.9854172 0.9852800 0.9851415 0.9850016 0.9848605 [386] 0.9847180 0.9845741 0.9844290 0.9842825 0.9841347 0.9839856 0.9838352 [393] 0.9836835 0.9835305 0.9833762 0.9832206 0.9830637 0.9829056 0.9827461 [400] 0.9825854 0.9824234 > mx [1] 0.9919592 > mxli [1] 0.86 > 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/1vr5e1194260043.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/2t67v1194260043.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/34bnq1194260043.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 > 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/4cvgu1194260043.tab") > > system("convert tmp/1vr5e1194260043.ps tmp/1vr5e1194260043.png") > system("convert tmp/2t67v1194260043.ps tmp/2t67v1194260043.png") > system("convert tmp/34bnq1194260043.ps tmp/34bnq1194260043.png") > > > proc.time() user system elapsed 1.037 0.511 1.244