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(33,34,36,36,38,42,35,25,24,22,27,17,30,30,34,37,36,33,33,33,37,40,35,37,43,42,33,39,40,37,44,42,43,40,30,30,31,18,24,22,26,28,23,17,12,9,19,21,18,18,15,24,18,19,30,33,35,36,47,46,43) > x <- c(24,23,24,24,27,28,25,19,19,19,20,16,22,21,25,29,28,25,26,24,28,28,28,28,32,31,22,29,31,29,32,32,31,29,28,28,29,22,26,24,27,27,23,21,19,17,19,21,13,8,5,10,6,6,8,11,12,13,19,19,18) > #'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.4207482 0.4212014 0.4216563 0.4221128 0.4225709 0.4230306 0.4234919 [8] 0.4239548 0.4244194 0.4248855 0.4253532 0.4258225 0.4262934 0.4267659 [15] 0.4272400 0.4277157 0.4281930 0.4286719 0.4291523 0.4296343 0.4301179 [22] 0.4306031 0.4310899 0.4315782 0.4320681 0.4325595 0.4330525 0.4335470 [29] 0.4340431 0.4345408 0.4350399 0.4355406 0.4360429 0.4365466 0.4370519 [36] 0.4375586 0.4380669 0.4385767 0.4390880 0.4396007 0.4401149 0.4406306 [43] 0.4411478 0.4416664 0.4421864 0.4427079 0.4432308 0.4437552 0.4442809 [50] 0.4448081 0.4453367 0.4458666 0.4463979 0.4469306 0.4474647 0.4480001 [57] 0.4485368 0.4490748 0.4496142 0.4501549 0.4506968 0.4512401 0.4517846 [64] 0.4523304 0.4528774 0.4534257 0.4539751 0.4545258 0.4550777 0.4556308 [71] 0.4561850 0.4567404 0.4572969 0.4578546 0.4584134 0.4589733 0.4595342 [78] 0.4600962 0.4606593 0.4612235 0.4617886 0.4623548 0.4629219 0.4634901 [85] 0.4640592 0.4646292 0.4652002 0.4657720 0.4663448 0.4669185 0.4674930 [92] 0.4680683 0.4686445 0.4692215 0.4697993 0.4703778 0.4709571 0.4715372 [99] 0.4721179 0.4726994 0.4732815 0.4738643 0.4744477 0.4750318 0.4756164 [106] 0.4762017 0.4767874 0.4773738 0.4779606 0.4785480 0.4791358 0.4797241 [113] 0.4803128 0.4809020 0.4814915 0.4820815 0.4826717 0.4832623 0.4838533 [120] 0.4844445 0.4850360 0.4856277 0.4862196 0.4868118 0.4874041 0.4879966 [127] 0.4885893 0.4891820 0.4897749 0.4903678 0.4909608 0.4915538 0.4921468 [134] 0.4927398 0.4933327 0.4939256 0.4945184 0.4951111 0.4957036 0.4962960 [141] 0.4968882 0.4974803 0.4980721 0.4986636 0.4992549 0.4998459 0.5004366 [148] 0.5010270 0.5016170 0.5022066 0.5027958 0.5033846 0.5039729 0.5045608 [155] 0.5051482 0.5057350 0.5063213 0.5069071 0.5074923 0.5080769 0.5086608 [162] 0.5092441 0.5098267 0.5104087 0.5109899 0.5115704 0.5121501 0.5127290 [169] 0.5133072 0.5138845 0.5144610 0.5150366 0.5156113 0.5161851 0.5167580 [176] 0.5173299 0.5179009 0.5184709 0.5190399 0.5196078 0.5201747 0.5207405 [183] 0.5213052 0.5218689 0.5224314 0.5229927 0.5235529 0.5241119 0.5246696 [190] 0.5252262 0.5257815 0.5263356 0.5268883 0.5274398 0.5279900 0.5285388 [197] 0.5290863 0.5296324 0.5301771 0.5307205 0.5312624 0.5318029 0.5323419 [204] 0.5328794 0.5334155 0.5339501 0.5344832 0.5350147 0.5355447 0.5360731 [211] 0.5366000 0.5371252 0.5376489 0.5381710 0.5386914 0.5392101 0.5397273 [218] 0.5402427 0.5407565 0.5412685 0.5417789 0.5422875 0.5427944 0.5432996 [225] 0.5438030 0.5443046 0.5448044 0.5453025 0.5457988 0.5462932 0.5467858 [232] 0.5472766 0.5477656 0.5482526 0.5487379 0.5492212 0.5497027 0.5501823 [239] 0.5506600 0.5511358 0.5516096 0.5520816 0.5525516 0.5530197 0.5534858 [246] 0.5539500 0.5544122 0.5548725 0.5553308 0.5557871 0.5562414 0.5566937 [253] 0.5571441 0.5575924 0.5580387 0.5584830 0.5589254 0.5593656 0.5598039 [260] 0.5602401 0.5606743 0.5611065 0.5615366 0.5619646 0.5623907 0.5628146 [267] 0.5632365 0.5636564 0.5640742 0.5644899 0.5649036 0.5653152 0.5657248 [274] 0.5661322 0.5665376 0.5669410 0.5673422 0.5677414 0.5681385 0.5685336 [281] 0.5689265 0.5693174 0.5697062 0.5700930 0.5704776 0.5708602 0.5712407 [288] 0.5716192 0.5719955 0.5723698 0.5727421 0.5731122 0.5734803 0.5738463 [295] 0.5742103 0.5745722 0.5749320 0.5752898 0.5756455 0.5759991 0.5763507 [302] 0.5767003 0.5770478 0.5773933 0.5777367 0.5780781 0.5784174 0.5787547 [309] 0.5790900 0.5794233 0.5797545 0.5800838 0.5804110 0.5807362 0.5810594 [316] 0.5813806 0.5816998 0.5820170 0.5823322 0.5826454 0.5829567 0.5832659 [323] 0.5835732 0.5838786 0.5841819 0.5844834 0.5847828 0.5850803 0.5853759 [330] 0.5856696 0.5859613 0.5862511 0.5865389 0.5868249 0.5871089 0.5873910 [337] 0.5876713 0.5879496 0.5882261 0.5885007 0.5887734 0.5890442 0.5893132 [344] 0.5895803 0.5898455 0.5901090 0.5903705 0.5906303 0.5908882 0.5911443 [351] 0.5913986 0.5916511 0.5919017 0.5921506 0.5923977 0.5926430 0.5928866 [358] 0.5931283 0.5933683 0.5936066 0.5938431 0.5940779 0.5943109 0.5945422 [365] 0.5947717 0.5949996 0.5952258 0.5954502 0.5956729 0.5958940 0.5961134 [372] 0.5963311 0.5965471 0.5967615 0.5969742 0.5971853 0.5973947 0.5976025 [379] 0.5978087 0.5980133 0.5982162 0.5984175 0.5986173 0.5988154 0.5990119 [386] 0.5992069 0.5994003 0.5995922 0.5997824 0.5999712 0.6001583 0.6003440 [393] 0.6005281 0.6007107 0.6008918 0.6010713 0.6012494 0.6014260 0.6016010 [400] 0.6017746 0.6019467 > mx [1] 0.6019467 > 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/1ej721257943055.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/264lf1257943055.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/3f9da1257943055.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/41luc1257943055.tab") > > system("convert tmp/1ej721257943055.ps tmp/1ej721257943055.png") > system("convert tmp/264lf1257943055.ps tmp/264lf1257943055.png") > system("convert tmp/3f9da1257943055.ps tmp/3f9da1257943055.png") > > > proc.time() user system elapsed 0.771 0.497 0.907