R version 2.8.0 (2008-10-20) 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. > x <- c(99.3,98.7,107.9,101.0,97.6,103.0,94.1,94.1,115.1,116.5,103.4,112.5,95.6,97.5,119.3,100.9,97.7,115.3,92.8,99.2,118.7,110.1,110.3,112.9,102.2,99.4,116.1,103.8,101.8,113.7,89.7,99.5,122.9,108.6,114.4,110.5,104.1,103.6,121.6,101.1,116.0,120.1,96.0,105.0,124.7,123.9,123.6,114.8,108.8,106.1,123.2,106.2,115.2,120.6,109.5,114.4,121.4,129.5,124.3,112.6) > #'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(qnorm(ppoints(x), mean=0, sd=1),x1) + if (mx < c[i]) + { + mx <- c[i] + mxli <- l[i] + } + } > c [1] 0.5120777 0.5121401 0.5122024 0.5122646 0.5123267 0.5123887 0.5124506 [8] 0.5125123 0.5125739 0.5126355 0.5126969 0.5127582 0.5128193 0.5128804 [15] 0.5129413 0.5130022 0.5130629 0.5131235 0.5131840 0.5132443 0.5133046 [22] 0.5133647 0.5134248 0.5134847 0.5135445 0.5136042 0.5136637 0.5137232 [29] 0.5137825 0.5138418 0.5139009 0.5139599 0.5140188 0.5140775 0.5141362 [36] 0.5141947 0.5142532 0.5143115 0.5143697 0.5144278 0.5144857 0.5145436 [43] 0.5146013 0.5146590 0.5147165 0.5147739 0.5148312 0.5148884 0.5149454 [50] 0.5150024 0.5150592 0.5151159 0.5151725 0.5152290 0.5152854 0.5153416 [57] 0.5153978 0.5154538 0.5155097 0.5155655 0.5156212 0.5156768 0.5157323 [64] 0.5157876 0.5158429 0.5158980 0.5159530 0.5160079 0.5160627 0.5161174 [71] 0.5161719 0.5162264 0.5162807 0.5163349 0.5163890 0.5164430 0.5164969 [78] 0.5165506 0.5166043 0.5166578 0.5167112 0.5167645 0.5168177 0.5168708 [85] 0.5169238 0.5169766 0.5170294 0.5170820 0.5171345 0.5171869 0.5172392 [92] 0.5172914 0.5173435 0.5173954 0.5174472 0.5174990 0.5175506 0.5176021 [99] 0.5176535 0.5177047 0.5177559 0.5178070 0.5178579 0.5179087 0.5179594 [106] 0.5180100 0.5180605 0.5181109 0.5181611 0.5182113 0.5182613 0.5183112 [113] 0.5183610 0.5184107 0.5184603 0.5185098 0.5185591 0.5186084 0.5186575 [120] 0.5187065 0.5187554 0.5188042 0.5188529 0.5189015 0.5189500 0.5189983 [127] 0.5190465 0.5190947 0.5191427 0.5191906 0.5192384 0.5192860 0.5193336 [134] 0.5193811 0.5194284 0.5194756 0.5195228 0.5195698 0.5196166 0.5196634 [141] 0.5197101 0.5197567 0.5198031 0.5198494 0.5198957 0.5199418 0.5199878 [148] 0.5200337 0.5200794 0.5201251 0.5201707 0.5202161 0.5202614 0.5203067 [155] 0.5203518 0.5203968 0.5204417 0.5204864 0.5205311 0.5205757 0.5206201 [162] 0.5206644 0.5207087 0.5207528 0.5207968 0.5208407 0.5208845 0.5209281 [169] 0.5209717 0.5210151 0.5210585 0.5211017 0.5211448 0.5211878 0.5212307 [176] 0.5212735 0.5213162 0.5213587 0.5214012 0.5214435 0.5214858 0.5215279 [183] 0.5215699 0.5216118 0.5216536 0.5216953 0.5217369 0.5217783 0.5218197 [190] 0.5218609 0.5219020 0.5219431 0.5219840 0.5220248 0.5220655 0.5221061 [197] 0.5221465 0.5221869 0.5222272 0.5222673 0.5223074 0.5223473 0.5223871 [204] 0.5224268 0.5224664 0.5225059 0.5225453 0.5225846 0.5226237 0.5226628 [211] 0.5227017 0.5227406 0.5227793 0.5228179 0.5228564 0.5228948 0.5229331 [218] 0.5229713 0.5230094 0.5230474 0.5230852 0.5231230 0.5231606 0.5231981 [225] 0.5232356 0.5232729 0.5233101 0.5233472 0.5233842 0.5234211 0.5234579 [232] 0.5234945 0.5235311 0.5235675 0.5236039 0.5236401 0.5236762 0.5237123 [239] 0.5237482 0.5237840 0.5238197 0.5238553 0.5238908 0.5239261 0.5239614 [246] 0.5239966 0.5240316 0.5240666 0.5241014 0.5241361 0.5241708 0.5242053 [253] 0.5242397 0.5242740 0.5243082 0.5243423 0.5243763 0.5244102 0.5244439 [260] 0.5244776 0.5245111 0.5245446 0.5245779 0.5246112 0.5246443 0.5246773 [267] 0.5247103 0.5247431 0.5247758 0.5248084 0.5248409 0.5248733 0.5249055 [274] 0.5249377 0.5249698 0.5250017 0.5250336 0.5250654 0.5250970 0.5251285 [281] 0.5251600 0.5251913 0.5252225 0.5252537 0.5252847 0.5253156 0.5253464 [288] 0.5253771 0.5254077 0.5254382 0.5254685 0.5254988 0.5255290 0.5255591 [295] 0.5255890 0.5256189 0.5256486 0.5256783 0.5257078 0.5257373 0.5257666 [302] 0.5257958 0.5258250 0.5258540 0.5258829 0.5259117 0.5259404 0.5259690 [309] 0.5259975 0.5260259 0.5260542 0.5260824 0.5261105 0.5261385 0.5261663 [316] 0.5261941 0.5262218 0.5262493 0.5262768 0.5263042 0.5263314 0.5263586 [323] 0.5263856 0.5264126 0.5264394 0.5264662 0.5264928 0.5265193 0.5265458 [330] 0.5265721 0.5265983 0.5266244 0.5266505 0.5266764 0.5267022 0.5267279 [337] 0.5267535 0.5267790 0.5268044 0.5268297 0.5268549 0.5268800 0.5269050 [344] 0.5269299 0.5269547 0.5269794 0.5270040 0.5270285 0.5270528 0.5270771 [351] 0.5271013 0.5271254 0.5271494 0.5271732 0.5271970 0.5272207 0.5272443 [358] 0.5272677 0.5272911 0.5273144 0.5273375 0.5273606 0.5273836 0.5274064 [365] 0.5274292 0.5274519 0.5274744 0.5274969 0.5275192 0.5275415 0.5275637 [372] 0.5275857 0.5276077 0.5276295 0.5276513 0.5276730 0.5276945 0.5277160 [379] 0.5277373 0.5277586 0.5277797 0.5278008 0.5278218 0.5278426 0.5278634 [386] 0.5278840 0.5279046 0.5279251 0.5279454 0.5279657 0.5279859 0.5280059 [393] 0.5280259 0.5280458 0.5280655 0.5280852 0.5281048 0.5281242 0.5281436 [400] 0.5281629 0.5281821 > mx [1] 0.5281821 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1kxaz1229085948.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(l,c,main='Box-Cox Normality Plot',xlab='Lambda',ylab='correlation') > mtext(paste('Optimal Lambda =',mxli)) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/2gh4r1229085948.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(x,main='Histogram of Original Data',xlab='X',ylab='frequency') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/38czl1229085948.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(x1,main='Histogram of Transformed Data',xlab='X',ylab='frequency') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/4oj6n1229085948.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x) > qqline(x) > grid() > mtext('Original Data') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/52ey31229085948.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x1) > qqline(x1) > grid() > mtext('Transformed Data') > 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 Normality 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',header=TRUE) > a<-table.element(a,mxli) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/6gha21229085949.tab") > > system("convert tmp/1kxaz1229085948.ps tmp/1kxaz1229085948.png") > system("convert tmp/2gh4r1229085948.ps tmp/2gh4r1229085948.png") > system("convert tmp/38czl1229085948.ps tmp/38czl1229085948.png") > system("convert tmp/4oj6n1229085948.ps tmp/4oj6n1229085948.png") > system("convert tmp/52ey31229085948.ps tmp/52ey31229085948.png") > > > proc.time() user system elapsed 1.084 0.782 1.467