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(147.5,164.7,176.2,161.8,171.7,169,161.4,157.2,166.2,162.1,169.1,158.4,139.7,145.2,165.3,154.4,147.4,165.3,145.7,147.2,156.1,152.9,153.8,151.7,131.8,131,155.8,143.8,139.8,160.1,136.5,131,153.7,141.3,138.9,141.2,120.3,118.9,141.7,126.2,130.6,139.8,119.5,115.8,142.6,127.7,131.8,129.5,111.1,112.6,130.8,115.4,120.5,131.9,111.2,108.9,128.1,110.7,124.1,121.5) > x <- c(136.5,146.4,157.7,148.7,154.6,152.1,144.8,142.1,157,159.1,164,151.5,135.9,138.5,161,151.7,142.9,157.4,138.9,141,150.9,149.9,153,144.3,128.1,123.3,155.9,144.1,134.1,153.1,131,129.8,139.9,135.6,126.8,134.4,113.5,107.5,133.8,119,125.9,130.1,114.2,111.6,131.2,124.1,127.1,123.4,100.7,100.3,121.6,110.5,110.3,122.7,102.6,101.8,113.6,107.2,116.8,112.5) > #'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.9452284 0.9453705 0.9455122 0.9456535 0.9457944 0.9459349 0.9460750 [8] 0.9462147 0.9463540 0.9464929 0.9466314 0.9467695 0.9469072 0.9470444 [15] 0.9471813 0.9473178 0.9474538 0.9475894 0.9477247 0.9478595 0.9479939 [22] 0.9481279 0.9482615 0.9483947 0.9485274 0.9486598 0.9487917 0.9489233 [29] 0.9490544 0.9491851 0.9493154 0.9494453 0.9495747 0.9497038 0.9498324 [36] 0.9499606 0.9500884 0.9502158 0.9503428 0.9504693 0.9505955 0.9507212 [43] 0.9508465 0.9509714 0.9510958 0.9512198 0.9513435 0.9514667 0.9515894 [50] 0.9517118 0.9518337 0.9519552 0.9520763 0.9521970 0.9523172 0.9524370 [57] 0.9525564 0.9526754 0.9527939 0.9529120 0.9530297 0.9531470 0.9532638 [64] 0.9533802 0.9534962 0.9536117 0.9537269 0.9538415 0.9539558 0.9540697 [71] 0.9541831 0.9542960 0.9544086 0.9545207 0.9546324 0.9547437 0.9548545 [78] 0.9549649 0.9550748 0.9551844 0.9552935 0.9554021 0.9555104 0.9556182 [85] 0.9557255 0.9558325 0.9559390 0.9560450 0.9561506 0.9562558 0.9563606 [92] 0.9564649 0.9565688 0.9566722 0.9567753 0.9568778 0.9569800 0.9570817 [99] 0.9571829 0.9572838 0.9573841 0.9574841 0.9575836 0.9576827 0.9577813 [106] 0.9578795 0.9579772 0.9580745 0.9581714 0.9582678 0.9583638 0.9584594 [113] 0.9585545 0.9586492 0.9587434 0.9588372 0.9589305 0.9590234 0.9591159 [120] 0.9592079 0.9592994 0.9593906 0.9594812 0.9595715 0.9596613 0.9597506 [127] 0.9598395 0.9599280 0.9600160 0.9601036 0.9601907 0.9602774 0.9603637 [134] 0.9604494 0.9605348 0.9606197 0.9607042 0.9607882 0.9608717 0.9609549 [141] 0.9610375 0.9611198 0.9612015 0.9612829 0.9613637 0.9614442 0.9615242 [148] 0.9616037 0.9616828 0.9617615 0.9618397 0.9619174 0.9619947 0.9620716 [155] 0.9621480 0.9622239 0.9622994 0.9623745 0.9624491 0.9625233 0.9625970 [162] 0.9626703 0.9627431 0.9628154 0.9628874 0.9629588 0.9630298 0.9631004 [169] 0.9631705 0.9632402 0.9633094 0.9633782 0.9634465 0.9635144 0.9635818 [176] 0.9636488 0.9637153 0.9637813 0.9638470 0.9639121 0.9639768 0.9640411 [183] 0.9641049 0.9641683 0.9642312 0.9642937 0.9643557 0.9644172 0.9644784 [190] 0.9645390 0.9645992 0.9646590 0.9647183 0.9647772 0.9648356 0.9648935 [197] 0.9649510 0.9650081 0.9650647 0.9651208 0.9651765 0.9652318 0.9652866 [204] 0.9653409 0.9653948 0.9654483 0.9655013 0.9655538 0.9656059 0.9656576 [211] 0.9657088 0.9657595 0.9658098 0.9658596 0.9659090 0.9659580 0.9660065 [218] 0.9660545 0.9661021 0.9661492 0.9661959 0.9662422 0.9662879 0.9663333 [225] 0.9663782 0.9664226 0.9664666 0.9665101 0.9665532 0.9665959 0.9666381 [232] 0.9666798 0.9667211 0.9667620 0.9668023 0.9668423 0.9668818 0.9669208 [239] 0.9669594 0.9669976 0.9670353 0.9670725 0.9671094 0.9671457 0.9671816 [246] 0.9672171 0.9672521 0.9672867 0.9673208 0.9673545 0.9673877 0.9674205 [253] 0.9674528 0.9674847 0.9675161 0.9675471 0.9675777 0.9676078 0.9676374 [260] 0.9676666 0.9676954 0.9677237 0.9677516 0.9677790 0.9678060 0.9678325 [267] 0.9678586 0.9678842 0.9679094 0.9679342 0.9679585 0.9679824 0.9680058 [274] 0.9680288 0.9680513 0.9680734 0.9680951 0.9681163 0.9681370 0.9681574 [281] 0.9681773 0.9681967 0.9682157 0.9682343 0.9682524 0.9682701 0.9682873 [288] 0.9683041 0.9683204 0.9683364 0.9683518 0.9683669 0.9683815 0.9683956 [295] 0.9684093 0.9684226 0.9684355 0.9684479 0.9684598 0.9684714 0.9684825 [302] 0.9684931 0.9685033 0.9685131 0.9685224 0.9685314 0.9685398 0.9685479 [309] 0.9685555 0.9685626 0.9685694 0.9685757 0.9685815 0.9685869 0.9685919 [316] 0.9685965 0.9686006 0.9686043 0.9686076 0.9686104 0.9686128 0.9686148 [323] 0.9686163 0.9686174 0.9686181 0.9686184 0.9686182 0.9686176 0.9686165 [330] 0.9686150 0.9686131 0.9686108 0.9686080 0.9686049 0.9686012 0.9685972 [337] 0.9685927 0.9685878 0.9685825 0.9685768 0.9685706 0.9685640 0.9685570 [344] 0.9685495 0.9685417 0.9685334 0.9685247 0.9685155 0.9685060 0.9684960 [351] 0.9684856 0.9684747 0.9684635 0.9684518 0.9684397 0.9684272 0.9684143 [358] 0.9684009 0.9683872 0.9683730 0.9683584 0.9683434 0.9683279 0.9683121 [365] 0.9682958 0.9682791 0.9682620 0.9682445 0.9682265 0.9682082 0.9681894 [372] 0.9681702 0.9681506 0.9681306 0.9681102 0.9680894 0.9680681 0.9680465 [379] 0.9680244 0.9680019 0.9679790 0.9679557 0.9679320 0.9679079 0.9678834 [386] 0.9678585 0.9678331 0.9678074 0.9677812 0.9677546 0.9677277 0.9677003 [393] 0.9676725 0.9676443 0.9676157 0.9675868 0.9675574 0.9675276 0.9674974 [400] 0.9674668 0.9674358 > mx [1] 0.9686184 > mxli [1] 1.25 > 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/1c6x41226327267.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/2wb121226327267.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/3108g1226327267.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/4ehqf1226327267.tab") > > system("convert tmp/1c6x41226327267.ps tmp/1c6x41226327267.png") > system("convert tmp/2wb121226327267.ps tmp/2wb121226327267.png") > system("convert tmp/3108g1226327267.ps tmp/3108g1226327267.png") > > > proc.time() user system elapsed 0.982 0.499 3.164