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(98.6,98,106.8,96.6,100.1,107.7,91.5,97.8,107.4,117.5,105.6,97.4,99.5,98,104.3,100.6,101.1,103.9,96.9,95.5,108.4,117,103.8,100.8,110.6,104,112.6,107.3,98.9,109.8,104.9,102.2,123.9,124.9,112.7,121.9,100.6,104.3,120.4,107.5,102.9,125.6,107.5,108.8,128.4,121.1,119.5,128.7,108.7,105.5,119.8,111.3,110.6,120.1,97.5,107.7,127.3,117.2,119.8,116.2,111,112.4,130.6,109.1,118.8,123.9,101.6,112.8,128,129.6,125.8,119.5,115.7,113.6,129.7,112,116.8,126.3,112.9,115.9) > x <- c(98.6,98,106.8,96.7,100.2,107.7,92,98.4,107.4,117.7,105.7,97.5,99.9,98.2,104.5,100.8,101.5,103.9,99.6,98.4,112.7,118.4,108.1,105.4,114.6,106.9,115.9,109.8,101.8,114.2,110.8,108.4,127.5,128.6,116.6,127.4,105,108.3,125,111.6,106.5,130.3,115,116.1,134,126.5,125.8,136.4,114.9,110.9,125.5,116.8,116.8,125.5,104.2,115.1,132.8,123.3,124.8,122,117.4,117.9,137.4,114.6,124.7,129.6,109.4,120.9,134.9,136.3,133.2,127.2,122.7,120.5,137.8,119.1,124.3,134.3,121.7,125) > #'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.9613181 0.9614227 0.9615270 0.9616311 0.9617350 0.9618386 0.9619421 [8] 0.9620452 0.9621482 0.9622509 0.9623534 0.9624556 0.9625576 0.9626594 [15] 0.9627610 0.9628623 0.9629634 0.9630642 0.9631649 0.9632652 0.9633654 [22] 0.9634653 0.9635650 0.9636644 0.9637636 0.9638626 0.9639614 0.9640599 [29] 0.9641581 0.9642562 0.9643540 0.9644515 0.9645489 0.9646460 0.9647428 [36] 0.9648395 0.9649358 0.9650320 0.9651279 0.9652236 0.9653190 0.9654142 [43] 0.9655092 0.9656039 0.9656984 0.9657926 0.9658866 0.9659804 0.9660739 [50] 0.9661672 0.9662603 0.9663531 0.9664457 0.9665380 0.9666301 0.9667220 [57] 0.9668136 0.9669050 0.9669961 0.9670870 0.9671777 0.9672681 0.9673583 [64] 0.9674482 0.9675379 0.9676274 0.9677166 0.9678056 0.9678943 0.9679828 [71] 0.9680710 0.9681590 0.9682468 0.9683343 0.9684216 0.9685086 0.9685954 [78] 0.9686820 0.9687683 0.9688544 0.9689402 0.9690258 0.9691111 0.9691962 [85] 0.9692811 0.9693657 0.9694500 0.9695341 0.9696180 0.9697016 0.9697850 [92] 0.9698682 0.9699511 0.9700337 0.9701161 0.9701983 0.9702802 0.9703619 [99] 0.9704433 0.9705245 0.9706054 0.9706861 0.9707665 0.9708467 0.9709267 [106] 0.9710064 0.9710858 0.9711650 0.9712440 0.9713227 0.9714012 0.9714794 [113] 0.9715574 0.9716351 0.9717126 0.9717898 0.9718668 0.9719436 0.9720200 [120] 0.9720963 0.9721723 0.9722480 0.9723235 0.9723988 0.9724738 0.9725485 [127] 0.9726230 0.9726973 0.9727713 0.9728450 0.9729185 0.9729918 0.9730648 [134] 0.9731376 0.9732101 0.9732823 0.9733543 0.9734261 0.9734976 0.9735688 [141] 0.9736399 0.9737106 0.9737811 0.9738514 0.9739214 0.9739911 0.9740606 [148] 0.9741299 0.9741989 0.9742676 0.9743361 0.9744044 0.9744724 0.9745401 [155] 0.9746076 0.9746749 0.9747419 0.9748086 0.9748751 0.9749413 0.9750073 [162] 0.9750730 0.9751385 0.9752037 0.9752687 0.9753334 0.9753979 0.9754621 [169] 0.9755261 0.9755898 0.9756532 0.9757164 0.9757794 0.9758421 0.9759045 [176] 0.9759667 0.9760287 0.9760904 0.9761518 0.9762130 0.9762739 0.9763346 [183] 0.9763950 0.9764551 0.9765150 0.9765747 0.9766341 0.9766932 0.9767521 [190] 0.9768108 0.9768691 0.9769273 0.9769851 0.9770428 0.9771001 0.9771572 [197] 0.9772141 0.9772707 0.9773270 0.9773831 0.9774390 0.9774945 0.9775499 [204] 0.9776049 0.9776597 0.9777143 0.9777686 0.9778226 0.9778764 0.9779300 [211] 0.9779833 0.9780363 0.9780890 0.9781416 0.9781938 0.9782458 0.9782976 [218] 0.9783491 0.9784003 0.9784513 0.9785020 0.9785524 0.9786027 0.9786526 [225] 0.9787023 0.9787517 0.9788009 0.9788499 0.9788985 0.9789469 0.9789951 [232] 0.9790430 0.9790906 0.9791380 0.9791852 0.9792320 0.9792787 0.9793250 [239] 0.9793711 0.9794170 0.9794626 0.9795079 0.9795530 0.9795978 0.9796424 [246] 0.9796867 0.9797307 0.9797745 0.9798180 0.9798613 0.9799043 0.9799471 [253] 0.9799896 0.9800318 0.9800738 0.9801156 0.9801570 0.9801983 0.9802392 [260] 0.9802799 0.9803204 0.9803606 0.9804005 0.9804402 0.9804796 0.9805188 [267] 0.9805577 0.9805963 0.9806347 0.9806728 0.9807107 0.9807483 0.9807857 [274] 0.9808228 0.9808596 0.9808962 0.9809325 0.9809686 0.9810044 0.9810399 [281] 0.9810752 0.9811103 0.9811451 0.9811796 0.9812139 0.9812479 0.9812816 [288] 0.9813151 0.9813483 0.9813813 0.9814140 0.9814465 0.9814787 0.9815107 [295] 0.9815423 0.9815738 0.9816050 0.9816359 0.9816665 0.9816969 0.9817271 [302] 0.9817570 0.9817866 0.9818160 0.9818451 0.9818739 0.9819025 0.9819309 [309] 0.9819590 0.9819868 0.9820144 0.9820417 0.9820687 0.9820955 0.9821221 [316] 0.9821484 0.9821744 0.9822001 0.9822257 0.9822509 0.9822759 0.9823007 [323] 0.9823251 0.9823494 0.9823733 0.9823970 0.9824205 0.9824437 0.9824666 [330] 0.9824893 0.9825118 0.9825339 0.9825558 0.9825775 0.9825989 0.9826200 [337] 0.9826409 0.9826616 0.9826819 0.9827020 0.9827219 0.9827415 0.9827609 [344] 0.9827800 0.9827988 0.9828174 0.9828357 0.9828538 0.9828716 0.9828891 [351] 0.9829064 0.9829235 0.9829402 0.9829568 0.9829730 0.9829891 0.9830048 [358] 0.9830203 0.9830356 0.9830506 0.9830653 0.9830798 0.9830940 0.9831080 [365] 0.9831217 0.9831352 0.9831484 0.9831613 0.9831740 0.9831865 0.9831987 [372] 0.9832106 0.9832223 0.9832337 0.9832449 0.9832558 0.9832664 0.9832768 [379] 0.9832870 0.9832969 0.9833065 0.9833159 0.9833251 0.9833339 0.9833426 [386] 0.9833509 0.9833590 0.9833669 0.9833745 0.9833819 0.9833890 0.9833958 [393] 0.9834024 0.9834087 0.9834148 0.9834207 0.9834262 0.9834316 0.9834366 [400] 0.9834415 0.9834460 > mx [1] 0.983446 > 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/1ozzg1194695576.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/2nwxo1194695576.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/306811194695576.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/4seu41194695576.tab") > > system("convert tmp/1ozzg1194695576.ps tmp/1ozzg1194695576.png") > system("convert tmp/2nwxo1194695576.ps tmp/2nwxo1194695576.png") > system("convert tmp/306811194695576.ps tmp/306811194695576.png") > > > proc.time() user system elapsed 1.844 0.831 1.973