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(101.30,97.60,96.40,97.00,96.40,94.70,89.30,85.90,83.30,81.50,85.00,84.80,87.50,89.00,90.00,89.60,87.40,84.80,81.90,81.10,79.10,80.50,88.50,90.90,84.90,80.00,76.50,75.40,73.50,74.30,77.70,77.90,76.70,77.20,86.00,86.90,92.00,101.70,104.50,101.70,100.60,100.30,102.50,101.00,108.60,103.40,106.40,106.60,108.90,110.50,114.00,112.80,109.60,116.00,124.60,129.00,131.50,138.60,138.10,146.30,157.60,158.40,176.30,199.90,210.40,202.60,207.10,202.00,203.40,216.30,207.30,203.50,204.40,203.70,205.70,208.00,209.30,208.70,206.50,204.50) > x <- c(100.70,97.90,96.50,96.60,96.60,95.50,91.80,89.30,87.00,85.90,88.00,87.90,89.20,90.90,91.60,90.20,89.10,87.50,86.30,86.00,84.40,86.10,91.00,92.70,88.00,84.30,82.20,80.80,79.40,80.20,82.20,82.20,81.20,82.10,88.10,88.50,92.10,98.60,100.90,100.60,101.10,102.10,103.60,102.80,108.30,104.00,106.10,106.30,109.00,111.00,113.70,112.70,110.30,114.50,119.30,121.80,125.40,129.70,129.40,134.50,141.20,141.40,152.20,167.70,173.30,168.70,172.60,169.80,172.00,179.40,174.60,172.50,172.60,176.30,178.90,179.60,179.90,180.30,180.90,177.70) > #'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.9459506 0.9462660 0.9465806 0.9468944 0.9472075 0.9475198 0.9478313 [8] 0.9481420 0.9484520 0.9487612 0.9490696 0.9493772 0.9496840 0.9499900 [15] 0.9502952 0.9505997 0.9509033 0.9512061 0.9515081 0.9518093 0.9521096 [22] 0.9524092 0.9527079 0.9530059 0.9533029 0.9535992 0.9538946 0.9541892 [29] 0.9544830 0.9547759 0.9550679 0.9553592 0.9556495 0.9559390 0.9562277 [36] 0.9565155 0.9568025 0.9570886 0.9573738 0.9576581 0.9579416 0.9582242 [43] 0.9585060 0.9587868 0.9590668 0.9593459 0.9596241 0.9599014 0.9601778 [50] 0.9604533 0.9607280 0.9610017 0.9612746 0.9615465 0.9618175 0.9620876 [57] 0.9623568 0.9626251 0.9628925 0.9631590 0.9634245 0.9636891 0.9639528 [64] 0.9642156 0.9644774 0.9647383 0.9649983 0.9652573 0.9655154 0.9657726 [71] 0.9660288 0.9662841 0.9665384 0.9667918 0.9670442 0.9672957 0.9675462 [78] 0.9677958 0.9680444 0.9682920 0.9685387 0.9687844 0.9690291 0.9692729 [85] 0.9695157 0.9697576 0.9699984 0.9702383 0.9704772 0.9707151 0.9709521 [92] 0.9711880 0.9714230 0.9716570 0.9718900 0.9721220 0.9723530 0.9725831 [99] 0.9728121 0.9730401 0.9732672 0.9734932 0.9737182 0.9739423 0.9741653 [106] 0.9743873 0.9746083 0.9748283 0.9750473 0.9752653 0.9754823 0.9756983 [113] 0.9759132 0.9761271 0.9763400 0.9765519 0.9767628 0.9769726 0.9771815 [120] 0.9773893 0.9775960 0.9778018 0.9780065 0.9782102 0.9784129 0.9786145 [127] 0.9788151 0.9790147 0.9792132 0.9794107 0.9796072 0.9798026 0.9799970 [134] 0.9801904 0.9803827 0.9805739 0.9807642 0.9809534 0.9811415 0.9813286 [141] 0.9815147 0.9816997 0.9818837 0.9820666 0.9822485 0.9824294 0.9826092 [148] 0.9827879 0.9829656 0.9831423 0.9833179 0.9834924 0.9836659 0.9838384 [155] 0.9840098 0.9841801 0.9843494 0.9845176 0.9846848 0.9848510 0.9850161 [162] 0.9851801 0.9853431 0.9855050 0.9856659 0.9858257 0.9859845 0.9861422 [169] 0.9862989 0.9864545 0.9866090 0.9867625 0.9869150 0.9870664 0.9872167 [176] 0.9873660 0.9875142 0.9876614 0.9878075 0.9879526 0.9880966 0.9882396 [183] 0.9883815 0.9885224 0.9886622 0.9888009 0.9889387 0.9890753 0.9892109 [190] 0.9893455 0.9894790 0.9896115 0.9897429 0.9898732 0.9900026 0.9901308 [197] 0.9902581 0.9903842 0.9905094 0.9906335 0.9907565 0.9908785 0.9909995 [204] 0.9911194 0.9912383 0.9913561 0.9914729 0.9915887 0.9917034 0.9918171 [211] 0.9919297 0.9920414 0.9921519 0.9922615 0.9923700 0.9924775 0.9925839 [218] 0.9926894 0.9927938 0.9928971 0.9929995 0.9931008 0.9932011 0.9933003 [225] 0.9933986 0.9934958 0.9935920 0.9936872 0.9937814 0.9938745 0.9939667 [232] 0.9940578 0.9941479 0.9942370 0.9943251 0.9944122 0.9944983 0.9945834 [239] 0.9946675 0.9947505 0.9948326 0.9949137 0.9949938 0.9950729 0.9951509 [246] 0.9952280 0.9953041 0.9953792 0.9954534 0.9955265 0.9955986 0.9956698 [253] 0.9957400 0.9958092 0.9958774 0.9959447 0.9960110 0.9960763 0.9961406 [260] 0.9962039 0.9962663 0.9963278 0.9963882 0.9964477 0.9965063 0.9965639 [267] 0.9966205 0.9966762 0.9967309 0.9967846 0.9968375 0.9968893 0.9969403 [274] 0.9969902 0.9970393 0.9970874 0.9971346 0.9971808 0.9972261 0.9972705 [281] 0.9973139 0.9973564 0.9973980 0.9974387 0.9974784 0.9975173 0.9975552 [288] 0.9975922 0.9976283 0.9976635 0.9976977 0.9977311 0.9977636 0.9977952 [295] 0.9978258 0.9978556 0.9978845 0.9979125 0.9979396 0.9979658 0.9979912 [302] 0.9980156 0.9980392 0.9980619 0.9980837 0.9981047 0.9981248 0.9981440 [309] 0.9981624 0.9981799 0.9981965 0.9982123 0.9982272 0.9982413 0.9982545 [316] 0.9982669 0.9982785 0.9982892 0.9982990 0.9983080 0.9983162 0.9983236 [323] 0.9983301 0.9983358 0.9983407 0.9983448 0.9983480 0.9983504 0.9983520 [330] 0.9983528 0.9983528 0.9983520 0.9983504 0.9983480 0.9983448 0.9983408 [337] 0.9983360 0.9983304 0.9983240 0.9983169 0.9983090 0.9983003 0.9982908 [344] 0.9982805 0.9982695 0.9982577 0.9982451 0.9982318 0.9982177 0.9982029 [351] 0.9981873 0.9981710 0.9981539 0.9981361 0.9981175 0.9980982 0.9980782 [358] 0.9980574 0.9980359 0.9980136 0.9979907 0.9979670 0.9979426 0.9979175 [365] 0.9978916 0.9978651 0.9978379 0.9978099 0.9977812 0.9977519 0.9977218 [372] 0.9976911 0.9976597 0.9976275 0.9975947 0.9975612 0.9975271 0.9974922 [379] 0.9974567 0.9974205 0.9973836 0.9973461 0.9973079 0.9972691 0.9972296 [386] 0.9971894 0.9971486 0.9971072 0.9970651 0.9970224 0.9969790 0.9969350 [393] 0.9968903 0.9968451 0.9967992 0.9967526 0.9967055 0.9966577 0.9966094 [400] 0.9965604 0.9965108 > mx [1] 0.9983528 > mxli [1] 1.29 > 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/16avd1194280150.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/2u7uz1194280150.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/3sim81194280150.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/4czdo1194280151.tab") > > system("convert tmp/16avd1194280150.ps tmp/16avd1194280150.png") > system("convert tmp/2u7uz1194280150.ps tmp/2u7uz1194280150.png") > system("convert tmp/3sim81194280150.ps tmp/3sim81194280150.png") > > > proc.time() user system elapsed 1.877 0.837 2.113