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(392,394,392,396,392,396,419,421,420,418,410,418,426,428,430,424,423,427,441,449,452,462,455,461,461,463,462,456,455,456,472,472,471,465,459,465,468,467,463,460,462,461,476,476,471,453,443,442,444,438,427,424,416,406,431,434,418,412,404,409,412,406,398,397,385,390,413,413,401,397,397,409) > x <- c(127,123,118,114,108,111,151,159,158,148,138,137,136,133,126,120,114,116,153,162,161,149,139,135,130,127,122,117,112,113,149,157,157,147,137,132,125,123,117,114,111,112,144,150,149,134,123,116,117,111,105,102,95,93,124,130,124,115,106,105,105,101,95,93,84,87,116,120,117,109,105,107) > #'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.5717931 0.5717819 0.5717702 0.5717577 0.5717446 0.5717309 0.5717165 [8] 0.5717014 0.5716857 0.5716693 0.5716523 0.5716347 0.5716164 0.5715974 [15] 0.5715778 0.5715576 0.5715367 0.5715151 0.5714929 0.5714701 0.5714466 [22] 0.5714224 0.5713977 0.5713722 0.5713461 0.5713194 0.5712920 0.5712640 [29] 0.5712353 0.5712060 0.5711760 0.5711454 0.5711142 0.5710823 0.5710497 [36] 0.5710165 0.5709827 0.5709482 0.5709131 0.5708774 0.5708410 0.5708039 [43] 0.5707662 0.5707279 0.5706889 0.5706493 0.5706091 0.5705682 0.5705267 [50] 0.5704845 0.5704417 0.5703983 0.5703542 0.5703095 0.5702641 0.5702182 [57] 0.5701715 0.5701243 0.5700764 0.5700279 0.5699787 0.5699290 0.5698785 [64] 0.5698275 0.5697758 0.5697235 0.5696706 0.5696170 0.5695628 0.5695080 [71] 0.5694525 0.5693965 0.5693398 0.5692824 0.5692245 0.5691659 0.5691067 [78] 0.5690469 0.5689865 0.5689254 0.5688637 0.5688014 0.5687385 0.5686749 [85] 0.5686108 0.5685460 0.5684806 0.5684146 0.5683480 0.5682807 0.5682129 [92] 0.5681444 0.5680754 0.5680057 0.5679354 0.5678645 0.5677930 0.5677208 [99] 0.5676481 0.5675748 0.5675008 0.5674263 0.5673511 0.5672754 0.5671990 [106] 0.5671221 0.5670445 0.5669664 0.5668876 0.5668082 0.5667283 0.5666477 [113] 0.5665666 0.5664849 0.5664025 0.5663196 0.5662361 0.5661520 0.5660673 [120] 0.5659820 0.5658961 0.5658097 0.5657226 0.5656350 0.5655468 0.5654580 [127] 0.5653686 0.5652787 0.5651881 0.5650970 0.5650053 0.5649130 0.5648202 [134] 0.5647268 0.5646328 0.5645382 0.5644430 0.5643473 0.5642510 0.5641542 [141] 0.5640568 0.5639588 0.5638602 0.5637611 0.5636614 0.5635612 0.5634604 [148] 0.5633590 0.5632571 0.5631546 0.5630515 0.5629479 0.5628438 0.5627391 [155] 0.5626338 0.5625280 0.5624216 0.5623147 0.5622073 0.5620993 0.5619907 [162] 0.5618816 0.5617720 0.5616618 0.5615511 0.5614398 0.5613280 0.5612157 [169] 0.5611028 0.5609894 0.5608754 0.5607609 0.5606459 0.5605304 0.5604143 [176] 0.5602977 0.5601806 0.5600629 0.5599448 0.5598261 0.5597069 0.5595871 [183] 0.5594669 0.5593461 0.5592248 0.5591030 0.5589806 0.5588578 0.5587344 [190] 0.5586106 0.5584862 0.5583613 0.5582359 0.5581101 0.5579837 0.5578568 [197] 0.5577294 0.5576015 0.5574731 0.5573442 0.5572148 0.5570849 0.5569545 [204] 0.5568236 0.5566922 0.5565604 0.5564280 0.5562952 0.5561619 0.5560281 [211] 0.5558938 0.5557590 0.5556238 0.5554881 0.5553519 0.5552152 0.5550780 [218] 0.5549404 0.5548023 0.5546637 0.5545247 0.5543851 0.5542452 0.5541047 [225] 0.5539638 0.5538224 0.5536806 0.5535383 0.5533956 0.5532523 0.5531087 [232] 0.5529646 0.5528200 0.5526750 0.5525295 0.5523835 0.5522372 0.5520904 [239] 0.5519431 0.5517954 0.5516472 0.5514986 0.5513496 0.5512001 0.5510502 [246] 0.5508999 0.5507491 0.5505979 0.5504463 0.5502942 0.5501417 0.5499888 [253] 0.5498355 0.5496817 0.5495275 0.5493729 0.5492179 0.5490624 0.5489066 [260] 0.5487503 0.5485936 0.5484365 0.5482790 0.5481211 0.5479627 0.5478040 [267] 0.5476448 0.5474853 0.5473253 0.5471650 0.5470042 0.5468431 0.5466816 [274] 0.5465196 0.5463573 0.5461946 0.5460315 0.5458680 0.5457041 0.5455398 [281] 0.5453751 0.5452101 0.5450447 0.5448788 0.5447127 0.5445461 0.5443792 [288] 0.5442119 0.5440442 0.5438761 0.5437077 0.5435389 0.5433697 0.5432002 [295] 0.5430303 0.5428600 0.5426894 0.5425184 0.5423471 0.5421754 0.5420034 [302] 0.5418310 0.5416582 0.5414851 0.5413116 0.5411378 0.5409637 0.5407892 [309] 0.5406144 0.5404392 0.5402636 0.5400878 0.5399116 0.5397350 0.5395582 [316] 0.5393810 0.5392034 0.5390255 0.5388473 0.5386688 0.5384900 0.5383108 [323] 0.5381313 0.5379515 0.5377713 0.5375908 0.5374101 0.5372290 0.5370475 [330] 0.5368658 0.5366838 0.5365014 0.5363188 0.5361358 0.5359525 0.5357689 [337] 0.5355851 0.5354009 0.5352164 0.5350316 0.5348465 0.5346612 0.5344755 [344] 0.5342895 0.5341033 0.5339167 0.5337299 0.5335427 0.5333553 0.5331676 [351] 0.5329797 0.5327914 0.5326029 0.5324140 0.5322249 0.5320356 0.5318459 [358] 0.5316560 0.5314658 0.5312753 0.5310846 0.5308936 0.5307023 0.5305108 [365] 0.5303190 0.5301269 0.5299346 0.5297420 0.5295492 0.5293561 0.5291627 [372] 0.5289691 0.5287753 0.5285811 0.5283868 0.5281922 0.5279973 0.5278022 [379] 0.5276069 0.5274113 0.5272155 0.5270194 0.5268231 0.5266265 0.5264298 [386] 0.5262327 0.5260355 0.5258380 0.5256403 0.5254424 0.5252442 0.5250458 [393] 0.5248472 0.5246483 0.5244493 0.5242500 0.5240505 0.5238507 0.5236508 [400] 0.5234506 0.5232502 > mx [1] 0.5717931 > 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/1cwbz1258116365.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/27q7q1258116365.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/3c06d1258116365.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/4cf0l1258116365.tab") > > system("convert tmp/1cwbz1258116365.ps tmp/1cwbz1258116365.png") > system("convert tmp/27q7q1258116365.ps tmp/27q7q1258116365.png") > system("convert tmp/3c06d1258116365.ps tmp/3c06d1258116365.png") > > > proc.time() user system elapsed 0.760 0.488 1.188