R version 2.8.1 (2008-12-22) 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(10,9.2,9.2,9.5,9.6,9.5,9.1,8.9,9,10.1,10.3,10.2,9.6,9.2,9.3,9.4,9.4,9.2,9,9,9,9.8,10,9.8,9.3,9,9,9.1,9.1,9.1,9.2,8.8,8.3,8.4,8.1,7.7,7.9,7.9,8,7.9,7.6,7.1,6.8,6.5,6.9,8.2,8.7,8.3,7.9,7.5,7.8,8.3,8.4,8.2,7.7,7.2,7.3,8.1,8.5,8.4) > x <- c(7.7,7.5,7.6,7.8,7.8,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.2,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,7.9,7.7,7.4,7.5,8,8.1,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.5843855 0.5842724 0.5841593 0.5840459 0.5839324 0.5838188 0.5837050 [8] 0.5835911 0.5834770 0.5833628 0.5832484 0.5831339 0.5830192 0.5829044 [15] 0.5827895 0.5826744 0.5825591 0.5824437 0.5823282 0.5822125 0.5820967 [22] 0.5819807 0.5818646 0.5817483 0.5816319 0.5815154 0.5813987 0.5812819 [29] 0.5811649 0.5810478 0.5809305 0.5808131 0.5806955 0.5805778 0.5804600 [36] 0.5803420 0.5802239 0.5801056 0.5799872 0.5798687 0.5797500 0.5796312 [43] 0.5795122 0.5793931 0.5792738 0.5791545 0.5790349 0.5789153 0.5787955 [50] 0.5786755 0.5785554 0.5784352 0.5783148 0.5781943 0.5780737 0.5779529 [57] 0.5778320 0.5777109 0.5775897 0.5774684 0.5773469 0.5772253 0.5771036 [64] 0.5769817 0.5768597 0.5767375 0.5766152 0.5764928 0.5763702 0.5762475 [71] 0.5761247 0.5760017 0.5758786 0.5757554 0.5756320 0.5755085 0.5753848 [78] 0.5752611 0.5751371 0.5750131 0.5748889 0.5747646 0.5746402 0.5745156 [85] 0.5743909 0.5742660 0.5741411 0.5740159 0.5738907 0.5737653 0.5736398 [92] 0.5735142 0.5733884 0.5732625 0.5731365 0.5730103 0.5728841 0.5727576 [99] 0.5726311 0.5725044 0.5723776 0.5722507 0.5721236 0.5719964 0.5718691 [106] 0.5717416 0.5716140 0.5714863 0.5713585 0.5712305 0.5711024 0.5709742 [113] 0.5708459 0.5707174 0.5705888 0.5704601 0.5703312 0.5702022 0.5700731 [120] 0.5699439 0.5698146 0.5696851 0.5695555 0.5694257 0.5692959 0.5691659 [127] 0.5690358 0.5689056 0.5687752 0.5686448 0.5685142 0.5683834 0.5682526 [134] 0.5681216 0.5679905 0.5678593 0.5677280 0.5675965 0.5674650 0.5673333 [141] 0.5672014 0.5670695 0.5669374 0.5668053 0.5666730 0.5665405 0.5664080 [148] 0.5662753 0.5661426 0.5660097 0.5658766 0.5657435 0.5656103 0.5654769 [155] 0.5653434 0.5652098 0.5650761 0.5649422 0.5648082 0.5646742 0.5645400 [162] 0.5644057 0.5642712 0.5641367 0.5640020 0.5638672 0.5637323 0.5635973 [169] 0.5634622 0.5633270 0.5631916 0.5630562 0.5629206 0.5627849 0.5626491 [176] 0.5625132 0.5623771 0.5622410 0.5621047 0.5619683 0.5618318 0.5616953 [183] 0.5615585 0.5614217 0.5612848 0.5611477 0.5610106 0.5608733 0.5607359 [190] 0.5605984 0.5604609 0.5603231 0.5601853 0.5600474 0.5599094 0.5597712 [197] 0.5596330 0.5594946 0.5593561 0.5592175 0.5590789 0.5589401 0.5588012 [204] 0.5586621 0.5585230 0.5583838 0.5582445 0.5581050 0.5579655 0.5578258 [211] 0.5576861 0.5575462 0.5574063 0.5572662 0.5571260 0.5569857 0.5568454 [218] 0.5567049 0.5565643 0.5564236 0.5562828 0.5561419 0.5560009 0.5558598 [225] 0.5557186 0.5555772 0.5554358 0.5552943 0.5551527 0.5550110 0.5548692 [232] 0.5547272 0.5545852 0.5544431 0.5543009 0.5541585 0.5540161 0.5538736 [239] 0.5537310 0.5535883 0.5534454 0.5533025 0.5531595 0.5530164 0.5528732 [246] 0.5527299 0.5525865 0.5524430 0.5522994 0.5521557 0.5520119 0.5518680 [253] 0.5517240 0.5515799 0.5514357 0.5512915 0.5511471 0.5510026 0.5508581 [260] 0.5507134 0.5505687 0.5504238 0.5502789 0.5501339 0.5499888 0.5498435 [267] 0.5496982 0.5495528 0.5494073 0.5492618 0.5491161 0.5489703 0.5488245 [274] 0.5486785 0.5485325 0.5483863 0.5482401 0.5480938 0.5479474 0.5478009 [281] 0.5476543 0.5475077 0.5473609 0.5472141 0.5470671 0.5469201 0.5467730 [288] 0.5466258 0.5464785 0.5463311 0.5461837 0.5460361 0.5458885 0.5457408 [295] 0.5455929 0.5454450 0.5452971 0.5451490 0.5450009 0.5448526 0.5447043 [302] 0.5445559 0.5444074 0.5442588 0.5441102 0.5439614 0.5438126 0.5436637 [309] 0.5435147 0.5433656 0.5432165 0.5430672 0.5429179 0.5427685 0.5426190 [316] 0.5424695 0.5423198 0.5421701 0.5420203 0.5418704 0.5417204 0.5415704 [323] 0.5414202 0.5412700 0.5411198 0.5409694 0.5408189 0.5406684 0.5405178 [330] 0.5403671 0.5402164 0.5400656 0.5399147 0.5397637 0.5396126 0.5394615 [337] 0.5393102 0.5391589 0.5390076 0.5388561 0.5387046 0.5385530 0.5384013 [344] 0.5382496 0.5380978 0.5379459 0.5377939 0.5376419 0.5374898 0.5373376 [351] 0.5371853 0.5370330 0.5368806 0.5367281 0.5365755 0.5364229 0.5362702 [358] 0.5361175 0.5359646 0.5358117 0.5356587 0.5355057 0.5353526 0.5351994 [365] 0.5350461 0.5348928 0.5347394 0.5345859 0.5344324 0.5342788 0.5341251 [372] 0.5339714 0.5338176 0.5336637 0.5335098 0.5333557 0.5332017 0.5330475 [379] 0.5328933 0.5327390 0.5325847 0.5324303 0.5322758 0.5321213 0.5319667 [386] 0.5318120 0.5316573 0.5315025 0.5313476 0.5311927 0.5310377 0.5308826 [393] 0.5307275 0.5305723 0.5304171 0.5302618 0.5301064 0.5299510 0.5297955 [400] 0.5296400 0.5294844 > mx [1] 0.5843855 > 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/rcomp/tmp/1s6bt1258055298.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/rcomp/tmp/21wfd1258055298.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/rcomp/tmp/3xavo1258055298.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/4jg881258055298.tab") > > system("convert tmp/1s6bt1258055298.ps tmp/1s6bt1258055298.png") > system("convert tmp/21wfd1258055298.ps tmp/21wfd1258055298.png") > system("convert tmp/3xavo1258055298.ps tmp/3xavo1258055298.png") > > > proc.time() user system elapsed 0.870 0.680 1.342