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(-3,-2,-3,-1,3,-4,-15,-17,-14,-9,-17,-7,-6,-1,0,-2,-4,-6,-2,1,7,2,2,13,7,-1,1,0,0,5,3,6,7,-6,-8,-5,-14,-13,-15,-14,-10,-14,-18,-22,-24,-17,-16,-17,-22,-25,-18,-23,-20,-9,-4,0,3,14,13,12) > x <- c(8.6,8.3,8.3,8.3,8.4,8.5,8.4,8.6,8.5,8.5,8.4,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.6,8.4,8.1,8.0,8.0,8.0,8.0,7.9,7.8,7.8,7.9,8.1,8.0,7.6,7.3,7.0,6.8,7.0,7.1,7.2,7.1,6.9,6.7,6.7,6.6,6.9,7.3,7.5,7.3,7.1,6.9,7.1,7.5,7.7,7.8,7.8,7.7,7.8,7.8,7.9,7.9) > #'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.5131511 0.5130542 0.5129572 0.5128601 0.5127628 0.5126654 0.5125679 [8] 0.5124703 0.5123726 0.5122747 0.5121767 0.5120786 0.5119804 0.5118821 [15] 0.5117836 0.5116850 0.5115863 0.5114875 0.5113886 0.5112895 0.5111903 [22] 0.5110910 0.5109916 0.5108921 0.5107924 0.5106926 0.5105928 0.5104927 [29] 0.5103926 0.5102924 0.5101920 0.5100915 0.5099909 0.5098902 0.5097893 [36] 0.5096884 0.5095873 0.5094861 0.5093848 0.5092833 0.5091818 0.5090801 [43] 0.5089783 0.5088764 0.5087744 0.5086723 0.5085700 0.5084676 0.5083651 [50] 0.5082625 0.5081598 0.5080570 0.5079540 0.5078509 0.5077477 0.5076444 [57] 0.5075410 0.5074374 0.5073338 0.5072300 0.5071261 0.5070221 0.5069180 [64] 0.5068137 0.5067094 0.5066049 0.5065003 0.5063956 0.5062908 0.5061859 [71] 0.5060808 0.5059756 0.5058704 0.5057650 0.5056594 0.5055538 0.5054481 [78] 0.5053422 0.5052363 0.5051302 0.5050240 0.5049176 0.5048112 0.5047047 [85] 0.5045980 0.5044912 0.5043844 0.5042774 0.5041702 0.5040630 0.5039557 [92] 0.5038482 0.5037406 0.5036330 0.5035252 0.5034172 0.5033092 0.5032011 [99] 0.5030928 0.5029845 0.5028760 0.5027674 0.5026587 0.5025499 0.5024410 [106] 0.5023319 0.5022228 0.5021135 0.5020042 0.5018947 0.5017851 0.5016754 [113] 0.5015655 0.5014556 0.5013456 0.5012354 0.5011251 0.5010148 0.5009043 [120] 0.5007937 0.5006829 0.5005721 0.5004612 0.5003501 0.5002390 0.5001277 [127] 0.5000163 0.4999049 0.4997933 0.4996816 0.4995697 0.4994578 0.4993458 [134] 0.4992336 0.4991214 0.4990090 0.4988965 0.4987839 0.4986713 0.4985585 [141] 0.4984455 0.4983325 0.4982194 0.4981062 0.4979928 0.4978793 0.4977658 [148] 0.4976521 0.4975383 0.4974244 0.4973104 0.4971963 0.4970821 0.4969678 [155] 0.4968534 0.4967388 0.4966242 0.4965094 0.4963946 0.4962796 0.4961646 [162] 0.4960494 0.4959341 0.4958187 0.4957032 0.4955876 0.4954719 0.4953561 [169] 0.4952401 0.4951241 0.4950080 0.4948917 0.4947754 0.4946589 0.4945424 [176] 0.4944257 0.4943089 0.4941921 0.4940751 0.4939580 0.4938408 0.4937235 [183] 0.4936061 0.4934886 0.4933710 0.4932533 0.4931355 0.4930175 0.4928995 [190] 0.4927814 0.4926631 0.4925448 0.4924264 0.4923078 0.4921892 0.4920704 [197] 0.4919516 0.4918326 0.4917135 0.4915944 0.4914751 0.4913557 0.4912363 [204] 0.4911167 0.4909970 0.4908772 0.4907574 0.4906374 0.4905173 0.4903971 [211] 0.4902768 0.4901564 0.4900359 0.4899153 0.4897946 0.4896738 0.4895529 [218] 0.4894320 0.4893109 0.4891897 0.4890684 0.4889470 0.4888255 0.4887039 [225] 0.4885822 0.4884604 0.4883385 0.4882165 0.4880944 0.4879722 0.4878499 [232] 0.4877275 0.4876050 0.4874824 0.4873597 0.4872369 0.4871140 0.4869910 [239] 0.4868679 0.4867447 0.4866214 0.4864980 0.4863746 0.4862510 0.4861273 [246] 0.4860035 0.4858796 0.4857557 0.4856316 0.4855074 0.4853832 0.4852588 [253] 0.4851344 0.4850098 0.4848852 0.4847604 0.4846356 0.4845106 0.4843856 [260] 0.4842605 0.4841352 0.4840099 0.4838845 0.4837590 0.4836334 0.4835077 [267] 0.4833819 0.4832560 0.4831300 0.4830039 0.4828777 0.4827514 0.4826251 [274] 0.4824986 0.4823720 0.4822454 0.4821187 0.4819918 0.4818649 0.4817379 [281] 0.4816107 0.4814835 0.4813562 0.4812288 0.4811013 0.4809737 0.4808461 [288] 0.4807183 0.4805904 0.4804625 0.4803344 0.4802063 0.4800780 0.4799497 [295] 0.4798213 0.4796928 0.4795642 0.4794355 0.4793067 0.4791779 0.4790489 [302] 0.4789198 0.4787907 0.4786615 0.4785321 0.4784027 0.4782732 0.4781436 [309] 0.4780139 0.4778841 0.4777543 0.4776243 0.4774943 0.4773641 0.4772339 [316] 0.4771036 0.4769732 0.4768427 0.4767121 0.4765815 0.4764507 0.4763198 [323] 0.4761889 0.4760579 0.4759268 0.4757956 0.4756643 0.4755329 0.4754015 [330] 0.4752699 0.4751383 0.4750066 0.4748748 0.4747429 0.4746109 0.4744788 [337] 0.4743466 0.4742144 0.4740821 0.4739497 0.4738172 0.4736846 0.4735519 [344] 0.4734191 0.4732863 0.4731534 0.4730204 0.4728873 0.4727541 0.4726208 [351] 0.4724875 0.4723540 0.4722205 0.4720869 0.4719532 0.4718194 0.4716856 [358] 0.4715516 0.4714176 0.4712835 0.4711493 0.4710151 0.4708807 0.4707463 [365] 0.4706117 0.4704771 0.4703424 0.4702077 0.4700728 0.4699379 0.4698029 [372] 0.4696678 0.4695326 0.4693973 0.4692620 0.4691266 0.4689911 0.4688555 [379] 0.4687198 0.4685841 0.4684482 0.4683123 0.4681763 0.4680403 0.4679041 [386] 0.4677679 0.4676316 0.4674952 0.4673587 0.4672222 0.4670856 0.4669489 [393] 0.4668121 0.4666752 0.4665383 0.4664012 0.4662641 0.4661270 0.4659897 [400] 0.4658524 0.4657150 > mx [1] 0.5131511 > 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/1z3dt1257947898.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/20r381257947898.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/3x8lc1257947898.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/4ywyr1257947898.tab") > > system("convert tmp/1z3dt1257947898.ps tmp/1z3dt1257947898.png") > system("convert tmp/20r381257947898.ps tmp/20r381257947898.png") > system("convert tmp/3x8lc1257947898.ps tmp/3x8lc1257947898.png") > > > proc.time() user system elapsed 0.764 0.486 0.998