R version 2.7.2 (2008-08-25) 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(6942,6879,6835,6805,6774,6743,6724,6715,6709) > x <- c(4931,4879,4804,4735,4685,4670,4616,4569,4550) > #'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.9798292 0.9798477 0.9798662 0.9798847 0.9799032 0.9799217 0.9799401 [8] 0.9799586 0.9799770 0.9799954 0.9800139 0.9800323 0.9800506 0.9800690 [15] 0.9800874 0.9801057 0.9801241 0.9801424 0.9801607 0.9801790 0.9801973 [22] 0.9802155 0.9802338 0.9802520 0.9802703 0.9802885 0.9803067 0.9803249 [29] 0.9803431 0.9803612 0.9803794 0.9803975 0.9804157 0.9804338 0.9804519 [36] 0.9804700 0.9804880 0.9805061 0.9805241 0.9805422 0.9805602 0.9805782 [43] 0.9805962 0.9806142 0.9806322 0.9806501 0.9806681 0.9806860 0.9807039 [50] 0.9807218 0.9807397 0.9807576 0.9807755 0.9807934 0.9808112 0.9808290 [57] 0.9808468 0.9808646 0.9808824 0.9809002 0.9809180 0.9809357 0.9809535 [64] 0.9809712 0.9809889 0.9810066 0.9810243 0.9810420 0.9810596 0.9810773 [71] 0.9810949 0.9811126 0.9811302 0.9811478 0.9811654 0.9811829 0.9812005 [78] 0.9812180 0.9812356 0.9812531 0.9812706 0.9812881 0.9813056 0.9813230 [85] 0.9813405 0.9813579 0.9813754 0.9813928 0.9814102 0.9814276 0.9814449 [92] 0.9814623 0.9814797 0.9814970 0.9815143 0.9815316 0.9815489 0.9815662 [99] 0.9815835 0.9816008 0.9816180 0.9816352 0.9816525 0.9816697 0.9816869 [106] 0.9817040 0.9817212 0.9817384 0.9817555 0.9817726 0.9817898 0.9818069 [113] 0.9818240 0.9818410 0.9818581 0.9818751 0.9818922 0.9819092 0.9819262 [120] 0.9819432 0.9819602 0.9819772 0.9819941 0.9820111 0.9820280 0.9820450 [127] 0.9820619 0.9820788 0.9820956 0.9821125 0.9821294 0.9821462 0.9821630 [134] 0.9821799 0.9821967 0.9822135 0.9822302 0.9822470 0.9822638 0.9822805 [141] 0.9822972 0.9823139 0.9823306 0.9823473 0.9823640 0.9823807 0.9823973 [148] 0.9824140 0.9824306 0.9824472 0.9824638 0.9824804 0.9824969 0.9825135 [155] 0.9825300 0.9825466 0.9825631 0.9825796 0.9825961 0.9826126 0.9826290 [162] 0.9826455 0.9826619 0.9826783 0.9826948 0.9827112 0.9827276 0.9827439 [169] 0.9827603 0.9827766 0.9827930 0.9828093 0.9828256 0.9828419 0.9828582 [176] 0.9828745 0.9828907 0.9829070 0.9829232 0.9829394 0.9829556 0.9829718 [183] 0.9829880 0.9830042 0.9830203 0.9830364 0.9830526 0.9830687 0.9830848 [190] 0.9831009 0.9831169 0.9831330 0.9831491 0.9831651 0.9831811 0.9831971 [197] 0.9832131 0.9832291 0.9832451 0.9832610 0.9832770 0.9832929 0.9833088 [204] 0.9833247 0.9833406 0.9833565 0.9833724 0.9833882 0.9834041 0.9834199 [211] 0.9834357 0.9834515 0.9834673 0.9834831 0.9834988 0.9835146 0.9835303 [218] 0.9835460 0.9835617 0.9835774 0.9835931 0.9836088 0.9836244 0.9836401 [225] 0.9836557 0.9836713 0.9836869 0.9837025 0.9837181 0.9837337 0.9837492 [232] 0.9837647 0.9837803 0.9837958 0.9838113 0.9838268 0.9838422 0.9838577 [239] 0.9838731 0.9838886 0.9839040 0.9839194 0.9839348 0.9839502 0.9839656 [246] 0.9839809 0.9839962 0.9840116 0.9840269 0.9840422 0.9840575 0.9840728 [253] 0.9840880 0.9841033 0.9841185 0.9841337 0.9841489 0.9841641 0.9841793 [260] 0.9841945 0.9842097 0.9842248 0.9842399 0.9842551 0.9842702 0.9842853 [267] 0.9843003 0.9843154 0.9843305 0.9843455 0.9843605 0.9843755 0.9843905 [274] 0.9844055 0.9844205 0.9844355 0.9844504 0.9844653 0.9844803 0.9844952 [281] 0.9845101 0.9845250 0.9845398 0.9845547 0.9845695 0.9845844 0.9845992 [288] 0.9846140 0.9846288 0.9846435 0.9846583 0.9846731 0.9846878 0.9847025 [295] 0.9847172 0.9847319 0.9847466 0.9847613 0.9847760 0.9847906 0.9848052 [302] 0.9848199 0.9848345 0.9848491 0.9848636 0.9848782 0.9848928 0.9849073 [309] 0.9849218 0.9849363 0.9849508 0.9849653 0.9849798 0.9849943 0.9850087 [316] 0.9850232 0.9850376 0.9850520 0.9850664 0.9850808 0.9850951 0.9851095 [323] 0.9851238 0.9851382 0.9851525 0.9851668 0.9851811 0.9851954 0.9852096 [330] 0.9852239 0.9852381 0.9852524 0.9852666 0.9852808 0.9852950 0.9853091 [337] 0.9853233 0.9853374 0.9853516 0.9853657 0.9853798 0.9853939 0.9854080 [344] 0.9854221 0.9854361 0.9854501 0.9854642 0.9854782 0.9854922 0.9855062 [351] 0.9855202 0.9855341 0.9855481 0.9855620 0.9855759 0.9855899 0.9856037 [358] 0.9856176 0.9856315 0.9856454 0.9856592 0.9856730 0.9856869 0.9857007 [365] 0.9857145 0.9857282 0.9857420 0.9857558 0.9857695 0.9857832 0.9857969 [372] 0.9858106 0.9858243 0.9858380 0.9858517 0.9858653 0.9858789 0.9858926 [379] 0.9859062 0.9859198 0.9859334 0.9859469 0.9859605 0.9859740 0.9859876 [386] 0.9860011 0.9860146 0.9860281 0.9860415 0.9860550 0.9860685 0.9860819 [393] 0.9860953 0.9861087 0.9861221 0.9861355 0.9861489 0.9861622 0.9861756 [400] 0.9861889 0.9862022 > mx [1] 0.9862022 > 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/1cq0y1226566359.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/23o271226566359.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/39atb1226566359.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/4bt161226566359.tab") > > system("convert tmp/1cq0y1226566359.ps tmp/1cq0y1226566359.png") > system("convert tmp/23o271226566359.ps tmp/23o271226566359.png") > system("convert tmp/39atb1226566359.ps tmp/39atb1226566359.png") > > > proc.time() user system elapsed 1.021 0.519 1.181