R version 2.7.2 (2008-08-25) 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(101.2,100.5,98,106.6,90.1,96.9,125.9,112,100,123.9,79.8,83.4,113.6,112.9,104,109.9,99,106.3,128.9,111.1,102.9,130,87,87.5,117.6,103.4,110.8,112.6,102.5,112.4,135.6,105.1,127.7,137,91,90.5,122.4,123.3,124.3,120,118.1,119,142.7,123.6,129.6,151.6,110.4,99.2,130.5,136.2,129.7,128,121.6,135.8,143.8,147.5,136.2,156.6,123.3,100.4) > #'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.5004970 0.5007398 0.5009823 0.5012245 0.5014663 0.5017078 0.5019490 [8] 0.5021898 0.5024304 0.5026706 0.5029104 0.5031500 0.5033892 0.5036280 [15] 0.5038665 0.5041047 0.5043426 0.5045801 0.5048173 0.5050541 0.5052906 [22] 0.5055268 0.5057626 0.5059981 0.5062332 0.5064679 0.5067024 0.5069364 [29] 0.5071702 0.5074035 0.5076365 0.5078692 0.5081015 0.5083334 0.5085650 [36] 0.5087963 0.5090271 0.5092577 0.5094878 0.5097176 0.5099470 0.5101761 [43] 0.5104048 0.5106331 0.5108611 0.5110886 0.5113159 0.5115427 0.5117692 [50] 0.5119953 0.5122210 0.5124463 0.5126713 0.5128959 0.5131201 0.5133440 [57] 0.5135674 0.5137905 0.5140132 0.5142355 0.5144574 0.5146789 0.5149001 [64] 0.5151208 0.5153412 0.5155612 0.5157808 0.5160000 0.5162188 0.5164372 [71] 0.5166552 0.5168728 0.5170900 0.5173068 0.5175233 0.5177393 0.5179549 [78] 0.5181701 0.5183849 0.5185993 0.5188134 0.5190269 0.5192401 0.5194529 [85] 0.5196653 0.5198773 0.5200888 0.5203000 0.5205107 0.5207210 0.5209309 [92] 0.5211404 0.5213494 0.5215581 0.5217663 0.5219741 0.5221815 0.5223885 [99] 0.5225950 0.5228012 0.5230069 0.5232121 0.5234170 0.5236214 0.5238254 [106] 0.5240290 0.5242321 0.5244348 0.5246371 0.5248389 0.5250403 0.5252413 [113] 0.5254418 0.5256419 0.5258416 0.5260408 0.5262396 0.5264380 0.5266359 [120] 0.5268334 0.5270304 0.5272270 0.5274231 0.5276188 0.5278141 0.5280089 [127] 0.5282033 0.5283972 0.5285906 0.5287837 0.5289762 0.5291683 0.5293600 [134] 0.5295512 0.5297420 0.5299323 0.5301221 0.5303115 0.5305004 0.5306889 [141] 0.5308769 0.5310645 0.5312516 0.5314383 0.5316244 0.5318102 0.5319954 [148] 0.5321802 0.5323645 0.5325484 0.5327318 0.5329147 0.5330972 0.5332792 [155] 0.5334607 0.5336418 0.5338224 0.5340025 0.5341821 0.5343613 0.5345400 [162] 0.5347182 0.5348960 0.5350733 0.5352501 0.5354264 0.5356022 0.5357776 [169] 0.5359525 0.5361269 0.5363009 0.5364743 0.5366473 0.5368198 0.5369918 [176] 0.5371633 0.5373343 0.5375049 0.5376750 0.5378446 0.5380137 0.5381823 [183] 0.5383504 0.5385180 0.5386852 0.5388518 0.5390180 0.5391837 0.5393489 [190] 0.5395136 0.5396778 0.5398415 0.5400047 0.5401674 0.5403296 0.5404913 [197] 0.5406526 0.5408133 0.5409736 0.5411333 0.5412925 0.5414513 0.5416095 [204] 0.5417673 0.5419245 0.5420813 0.5422375 0.5423932 0.5425485 0.5427032 [211] 0.5428574 0.5430112 0.5431644 0.5433171 0.5434693 0.5436210 0.5437722 [218] 0.5439229 0.5440731 0.5442228 0.5443719 0.5445206 0.5446687 0.5448164 [225] 0.5449635 0.5451101 0.5452562 0.5454018 0.5455469 0.5456914 0.5458355 [232] 0.5459790 0.5461221 0.5462646 0.5464066 0.5465480 0.5466890 0.5468294 [239] 0.5469694 0.5471088 0.5472477 0.5473861 0.5475239 0.5476613 0.5477981 [246] 0.5479344 0.5480702 0.5482054 0.5483402 0.5484744 0.5486081 0.5487413 [253] 0.5488739 0.5490060 0.5491377 0.5492687 0.5493993 0.5495293 0.5496589 [260] 0.5497878 0.5499163 0.5500443 0.5501717 0.5502986 0.5504249 0.5505508 [267] 0.5506761 0.5508009 0.5509251 0.5510488 0.5511720 0.5512947 0.5514169 [274] 0.5515385 0.5516596 0.5517801 0.5519001 0.5520196 0.5521386 0.5522570 [281] 0.5523750 0.5524923 0.5526092 0.5527255 0.5528413 0.5529565 0.5530712 [288] 0.5531854 0.5532991 0.5534122 0.5535248 0.5536369 0.5537484 0.5538594 [295] 0.5539698 0.5540798 0.5541891 0.5542980 0.5544063 0.5545141 0.5546214 [302] 0.5547281 0.5548343 0.5549399 0.5550450 0.5551496 0.5552536 0.5553571 [309] 0.5554601 0.5555626 0.5556645 0.5557658 0.5558666 0.5559669 0.5560667 [316] 0.5561659 0.5562646 0.5563627 0.5564603 0.5565574 0.5566539 0.5567499 [323] 0.5568454 0.5569403 0.5570347 0.5571285 0.5572219 0.5573146 0.5574069 [330] 0.5574986 0.5575897 0.5576803 0.5577704 0.5578600 0.5579490 0.5580374 [337] 0.5581254 0.5582128 0.5582996 0.5583859 0.5584717 0.5585570 0.5586417 [344] 0.5587258 0.5588094 0.5588925 0.5589751 0.5590571 0.5591386 0.5592195 [351] 0.5592999 0.5593798 0.5594591 0.5595379 0.5596161 0.5596938 0.5597710 [358] 0.5598476 0.5599237 0.5599993 0.5600743 0.5601488 0.5602228 0.5602962 [365] 0.5603690 0.5604414 0.5605132 0.5605844 0.5606552 0.5607253 0.5607950 [372] 0.5608641 0.5609327 0.5610007 0.5610682 0.5611352 0.5612016 0.5612675 [379] 0.5613329 0.5613977 0.5614620 0.5615258 0.5615890 0.5616517 0.5617138 [386] 0.5617754 0.5618365 0.5618971 0.5619571 0.5620166 0.5620755 0.5621339 [393] 0.5621918 0.5622491 0.5623059 0.5623622 0.5624180 0.5624732 0.5625279 [400] 0.5625820 0.5626356 > mx [1] 0.5626356 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/17fk61226610781.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/2nkje1226610781.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/30n361226610781.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/4c5co1226610781.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/53oly1226610781.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/6mpba1226610781.tab") > > system("convert tmp/17fk61226610781.ps tmp/17fk61226610781.png") > system("convert tmp/2nkje1226610781.ps tmp/2nkje1226610781.png") > system("convert tmp/30n361226610781.ps tmp/30n361226610781.png") > system("convert tmp/4c5co1226610781.ps tmp/4c5co1226610781.png") > system("convert tmp/53oly1226610781.ps tmp/53oly1226610781.png") > > > proc.time() user system elapsed 1.329 0.826 2.252