R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(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.4,121.1,122.2,127.7,137.4,132.2,129.2,124.9,124.8,128.2,134.4,118.6,132.6,123.2,112.8,138.7,137.3,122.3,136.9,117.1) > x <- c(71.7,77.5,89.8,80.3,78.7,93.8,57.6,60.6,91,85.3,77.4,77.3,68.3,69.9,81.7,75.1,69.9,84,54.3,60,89.9,77,85.3,77.6,69.2,75.5,85.7,72.2,79.9,85.3,52.2,61.2,82.4,85.4,78.2,70.2,70.2,69.3,77.5,66.1,69,79.2,56.2,63.3,77.8,92,78.1,65.1,71.1,70.9,72,81.9,70.6,72.5,65.1,54.9,80,77.4,59.6,57.4,50.8) > #'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.4973415 0.4974741 0.4976065 0.4977386 0.4978706 0.4980024 0.4981339 [8] 0.4982653 0.4983964 0.4985273 0.4986580 0.4987885 0.4989188 0.4990489 [15] 0.4991788 0.4993084 0.4994379 0.4995671 0.4996961 0.4998249 0.4999535 [22] 0.5000818 0.5002099 0.5003378 0.5004655 0.5005930 0.5007202 0.5008473 [29] 0.5009740 0.5011006 0.5012270 0.5013531 0.5014790 0.5016046 0.5017301 [36] 0.5018553 0.5019802 0.5021050 0.5022295 0.5023537 0.5024778 0.5026016 [43] 0.5027252 0.5028485 0.5029716 0.5030945 0.5032171 0.5033395 0.5034616 [50] 0.5035835 0.5037052 0.5038266 0.5039478 0.5040687 0.5041894 0.5043099 [57] 0.5044301 0.5045500 0.5046697 0.5047892 0.5049084 0.5050274 0.5051461 [64] 0.5052645 0.5053827 0.5055007 0.5056184 0.5057359 0.5058531 0.5059700 [71] 0.5060867 0.5062031 0.5063193 0.5064352 0.5065509 0.5066663 0.5067814 [78] 0.5068963 0.5070109 0.5071253 0.5072394 0.5073532 0.5074668 0.5075801 [85] 0.5076931 0.5078059 0.5079184 0.5080306 0.5081426 0.5082543 0.5083657 [92] 0.5084768 0.5085877 0.5086983 0.5088087 0.5089187 0.5090285 0.5091381 [99] 0.5092473 0.5093563 0.5094650 0.5095734 0.5096815 0.5097894 0.5098970 [106] 0.5100043 0.5101113 0.5102180 0.5103245 0.5104306 0.5105365 0.5106421 [113] 0.5107475 0.5108525 0.5109572 0.5110617 0.5111659 0.5112698 0.5113734 [120] 0.5114767 0.5115797 0.5116825 0.5117849 0.5118871 0.5119889 0.5120905 [127] 0.5121918 0.5122927 0.5123934 0.5124938 0.5125939 0.5126937 0.5127932 [134] 0.5128924 0.5129913 0.5130899 0.5131882 0.5132862 0.5133840 0.5134814 [141] 0.5135785 0.5136753 0.5137718 0.5138680 0.5139639 0.5140594 0.5141547 [148] 0.5142497 0.5143444 0.5144387 0.5145328 0.5146265 0.5147200 0.5148131 [155] 0.5149059 0.5149984 0.5150906 0.5151825 0.5152741 0.5153654 0.5154563 [162] 0.5155470 0.5156373 0.5157273 0.5158170 0.5159064 0.5159954 0.5160842 [169] 0.5161726 0.5162607 0.5163485 0.5164360 0.5165231 0.5166100 0.5166965 [176] 0.5167827 0.5168685 0.5169541 0.5170393 0.5171242 0.5172088 0.5172931 [183] 0.5173770 0.5174606 0.5175439 0.5176268 0.5177095 0.5177918 0.5178738 [190] 0.5179554 0.5180367 0.5181177 0.5181984 0.5182787 0.5183587 0.5184384 [197] 0.5185177 0.5185967 0.5186754 0.5187538 0.5188318 0.5189095 0.5189868 [204] 0.5190638 0.5191405 0.5192169 0.5192929 0.5193685 0.5194439 0.5195189 [211] 0.5195935 0.5196679 0.5197419 0.5198155 0.5198888 0.5199618 0.5200344 [218] 0.5201067 0.5201787 0.5202503 0.5203216 0.5203925 0.5204631 0.5205334 [225] 0.5206033 0.5206728 0.5207421 0.5208109 0.5208795 0.5209477 0.5210155 [232] 0.5210830 0.5211502 0.5212170 0.5212835 0.5213496 0.5214153 0.5214808 [239] 0.5215459 0.5216106 0.5216750 0.5217390 0.5218027 0.5218660 0.5219290 [246] 0.5219917 0.5220540 0.5221159 0.5221775 0.5222387 0.5222996 0.5223602 [253] 0.5224203 0.5224802 0.5225397 0.5225988 0.5226576 0.5227160 0.5227741 [260] 0.5228318 0.5228891 0.5229462 0.5230028 0.5230591 0.5231151 0.5231707 [267] 0.5232259 0.5232808 0.5233353 0.5233895 0.5234433 0.5234968 0.5235499 [274] 0.5236026 0.5236550 0.5237070 0.5237587 0.5238100 0.5238610 0.5239116 [281] 0.5239618 0.5240117 0.5240612 0.5241104 0.5241592 0.5242077 0.5242557 [288] 0.5243035 0.5243508 0.5243979 0.5244445 0.5244908 0.5245367 0.5245823 [295] 0.5246275 0.5246723 0.5247168 0.5247610 0.5248047 0.5248481 0.5248912 [302] 0.5249339 0.5249762 0.5250181 0.5250597 0.5251010 0.5251418 0.5251823 [309] 0.5252225 0.5252623 0.5253017 0.5253407 0.5253794 0.5254178 0.5254557 [316] 0.5254933 0.5255306 0.5255674 0.5256040 0.5256401 0.5256759 0.5257113 [323] 0.5257464 0.5257811 0.5258154 0.5258494 0.5258830 0.5259162 0.5259491 [330] 0.5259816 0.5260138 0.5260455 0.5260770 0.5261080 0.5261387 0.5261690 [337] 0.5261990 0.5262286 0.5262578 0.5262867 0.5263152 0.5263433 0.5263711 [344] 0.5263985 0.5264255 0.5264522 0.5264785 0.5265045 0.5265301 0.5265553 [351] 0.5265802 0.5266046 0.5266288 0.5266525 0.5266759 0.5266990 0.5267216 [358] 0.5267440 0.5267659 0.5267875 0.5268087 0.5268295 0.5268500 0.5268701 [365] 0.5268899 0.5269093 0.5269283 0.5269470 0.5269653 0.5269832 0.5270008 [372] 0.5270180 0.5270349 0.5270514 0.5270675 0.5270832 0.5270986 0.5271137 [379] 0.5271283 0.5271427 0.5271566 0.5271702 0.5271834 0.5271963 0.5272088 [386] 0.5272209 0.5272327 0.5272441 0.5272551 0.5272658 0.5272761 0.5272861 [393] 0.5272957 0.5273049 0.5273138 0.5273223 0.5273305 0.5273383 0.5273457 [400] 0.5273528 0.5273595 > mx [1] 0.5273595 > 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/10kwf1258120253.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/2xk561258120253.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/332bj1258120253.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/4umj61258120253.tab") > system("convert tmp/10kwf1258120253.ps tmp/10kwf1258120253.png") > system("convert tmp/2xk561258120253.ps tmp/2xk561258120253.png") > system("convert tmp/332bj1258120253.ps tmp/332bj1258120253.png") > > > proc.time() user system elapsed 0.798 0.518 0.921