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(98,97,96,96,96,96,96,96,96,97,97,98,99,101,102,103,104,105,106,107,106,105,105,105,105,105,105,105,105,106,106,106,105,105,107,108,110,111,111,112,112,112,112,113,115,117,118,118,118,118,118,118,119,121,121,122,123,123,124,124) > x <- c(105.8,105.7,105.5,105.4,105.4,105.6,105.7,105.6,105.6,105.6,105.4,105.4,105.9,106.6,107.3,107.8,108.1,108.4,108.8,109,109,109,108.8,108.4,107.9,107.5,107.2,107.1,107.2,107.4,107.5,107.5,107.8,108.6,109.7,110.6,111.2,111.8,112.7,113.8,115.1,116.2,117.2,118.5,120.2,122.1,123.7,125,126,127,128,129.1,130.1,130.7,131,131.5,132.4,132.8,132.7,132.7) > #'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.9573436 0.9573015 0.9572594 0.9572173 0.9571751 0.9571329 0.9570907 [8] 0.9570484 0.9570060 0.9569636 0.9569212 0.9568787 0.9568362 0.9567936 [15] 0.9567510 0.9567084 0.9566657 0.9566229 0.9565801 0.9565373 0.9564944 [22] 0.9564515 0.9564085 0.9563655 0.9563225 0.9562794 0.9562362 0.9561931 [29] 0.9561498 0.9561066 0.9560632 0.9560199 0.9559765 0.9559330 0.9558895 [36] 0.9558460 0.9558024 0.9557588 0.9557151 0.9556714 0.9556277 0.9555839 [43] 0.9555400 0.9554961 0.9554522 0.9554082 0.9553642 0.9553202 0.9552761 [50] 0.9552319 0.9551877 0.9551435 0.9550992 0.9550549 0.9550105 0.9549661 [57] 0.9549217 0.9548772 0.9548326 0.9547880 0.9547434 0.9546987 0.9546540 [64] 0.9546093 0.9545645 0.9545196 0.9544747 0.9544298 0.9543848 0.9543398 [71] 0.9542948 0.9542497 0.9542045 0.9541593 0.9541141 0.9540688 0.9540235 [78] 0.9539781 0.9539327 0.9538873 0.9538418 0.9537962 0.9537507 0.9537050 [85] 0.9536594 0.9536137 0.9535679 0.9535221 0.9534763 0.9534304 0.9533845 [92] 0.9533385 0.9532925 0.9532464 0.9532003 0.9531542 0.9531080 0.9530618 [99] 0.9530155 0.9529692 0.9529229 0.9528765 0.9528300 0.9527835 0.9527370 [106] 0.9526905 0.9526438 0.9525972 0.9525505 0.9525038 0.9524570 0.9524101 [113] 0.9523633 0.9523164 0.9522694 0.9522224 0.9521754 0.9521283 0.9520812 [120] 0.9520340 0.9519868 0.9519396 0.9518923 0.9518449 0.9517976 0.9517501 [127] 0.9517027 0.9516552 0.9516076 0.9515600 0.9515124 0.9514647 0.9514170 [134] 0.9513693 0.9513215 0.9512736 0.9512257 0.9511778 0.9511298 0.9510818 [141] 0.9510338 0.9509857 0.9509375 0.9508894 0.9508411 0.9507929 0.9507446 [148] 0.9506962 0.9506478 0.9505994 0.9505509 0.9505024 0.9504538 0.9504052 [155] 0.9503566 0.9503079 0.9502592 0.9502104 0.9501616 0.9501128 0.9500639 [162] 0.9500149 0.9499660 0.9499170 0.9498679 0.9498188 0.9497696 0.9497205 [169] 0.9496712 0.9496220 0.9495727 0.9495233 0.9494739 0.9494245 0.9493750 [176] 0.9493255 0.9492759 0.9492263 0.9491767 0.9491270 0.9490773 0.9490275 [183] 0.9489777 0.9489279 0.9488780 0.9488281 0.9487781 0.9487281 0.9486780 [190] 0.9486279 0.9485778 0.9485276 0.9484774 0.9484271 0.9483768 0.9483265 [197] 0.9482761 0.9482257 0.9481752 0.9481247 0.9480742 0.9480236 0.9479730 [204] 0.9479223 0.9478716 0.9478209 0.9477701 0.9477192 0.9476684 0.9476175 [211] 0.9475665 0.9475155 0.9474645 0.9474134 0.9473623 0.9473111 0.9472599 [218] 0.9472087 0.9471574 0.9471061 0.9470547 0.9470033 0.9469519 0.9469004 [225] 0.9468489 0.9467974 0.9467458 0.9466941 0.9466424 0.9465907 0.9465390 [232] 0.9464872 0.9464353 0.9463834 0.9463315 0.9462795 0.9462275 0.9461755 [239] 0.9461234 0.9460713 0.9460191 0.9459669 0.9459147 0.9458624 0.9458101 [246] 0.9457577 0.9457053 0.9456529 0.9456004 0.9455479 0.9454953 0.9454427 [253] 0.9453901 0.9453374 0.9452847 0.9452320 0.9451792 0.9451263 0.9450734 [260] 0.9450205 0.9449676 0.9449146 0.9448616 0.9448085 0.9447554 0.9447022 [267] 0.9446490 0.9445958 0.9445425 0.9444892 0.9444359 0.9443825 0.9443291 [274] 0.9442756 0.9442221 0.9441686 0.9441150 0.9440614 0.9440077 0.9439540 [281] 0.9439003 0.9438465 0.9437927 0.9437388 0.9436849 0.9436310 0.9435770 [288] 0.9435230 0.9434690 0.9434149 0.9433608 0.9433066 0.9432524 0.9431982 [295] 0.9431439 0.9430896 0.9430352 0.9429808 0.9429264 0.9428719 0.9428174 [302] 0.9427628 0.9427083 0.9426536 0.9425990 0.9425443 0.9424895 0.9424348 [309] 0.9423799 0.9423251 0.9422702 0.9422153 0.9421603 0.9421053 0.9420503 [316] 0.9419952 0.9419401 0.9418849 0.9418297 0.9417745 0.9417192 0.9416639 [323] 0.9416086 0.9415532 0.9414978 0.9414423 0.9413868 0.9413313 0.9412757 [330] 0.9412201 0.9411644 0.9411088 0.9410530 0.9409973 0.9409415 0.9408857 [337] 0.9408298 0.9407739 0.9407179 0.9406620 0.9406059 0.9405499 0.9404938 [344] 0.9404377 0.9403815 0.9403253 0.9402690 0.9402128 0.9401565 0.9401001 [351] 0.9400437 0.9399873 0.9399308 0.9398743 0.9398178 0.9397612 0.9397046 [358] 0.9396480 0.9395913 0.9395346 0.9394778 0.9394210 0.9393642 0.9393073 [365] 0.9392504 0.9391935 0.9391365 0.9390795 0.9390225 0.9389654 0.9389083 [372] 0.9388511 0.9387939 0.9387367 0.9386794 0.9386221 0.9385648 0.9385074 [379] 0.9384500 0.9383926 0.9383351 0.9382776 0.9382200 0.9381624 0.9381048 [386] 0.9380471 0.9379894 0.9379317 0.9378739 0.9378161 0.9377583 0.9377004 [393] 0.9376425 0.9375846 0.9375266 0.9374686 0.9374105 0.9373525 0.9372943 [400] 0.9372362 0.9371780 > mx [1] 0.9573436 > 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/1ga9l1226318505.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/2bt571226318505.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/3oywr1226318505.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/40qsp1226318505.tab") > > system("convert tmp/1ga9l1226318505.ps tmp/1ga9l1226318505.png") > system("convert tmp/2bt571226318505.ps tmp/2bt571226318505.png") > system("convert tmp/3oywr1226318505.ps tmp/3oywr1226318505.png") > > > proc.time() user system elapsed 1.042 0.533 1.262