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(93.4,101.1,114.2,104.8,113.3,118.2,83.6,73.9,99.5,97.7,103,106.3,92.2,101.8,122.8,111.8,106.3,121.5,81.9,85.4,110.9,117.3,106.3,105.6,101.2,105.9,126.3,111.9,108.9,127.2,94.2,85.7,116.2,107.2,110.5,112,104.4,112,132.8,110.8,128.7,136.8,94.8,88.8,123.2,125.3,122.7,125.8,116.3,118.6,142.1,127.9,132,152.4,110.8,99.1,134.9,133.2,131,133.9,119.9) > #'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.4858201 0.4861034 0.4863863 0.4866689 0.4869511 0.4872330 0.4875146 [8] 0.4877958 0.4880767 0.4883573 0.4886375 0.4889173 0.4891969 0.4894760 [15] 0.4897548 0.4900333 0.4903114 0.4905892 0.4908666 0.4911436 0.4914203 [22] 0.4916966 0.4919726 0.4922482 0.4925234 0.4927983 0.4930728 0.4933469 [29] 0.4936207 0.4938941 0.4941671 0.4944397 0.4947120 0.4949839 0.4952554 [36] 0.4955265 0.4957972 0.4960676 0.4963376 0.4966072 0.4968763 0.4971452 [43] 0.4974136 0.4976816 0.4979492 0.4982165 0.4984833 0.4987497 0.4990158 [50] 0.4992814 0.4995467 0.4998115 0.5000759 0.5003399 0.5006035 0.5008668 [57] 0.5011295 0.5013919 0.5016539 0.5019154 0.5021766 0.5024373 0.5026976 [64] 0.5029575 0.5032169 0.5034760 0.5037346 0.5039928 0.5042505 0.5045079 [71] 0.5047648 0.5050212 0.5052773 0.5055329 0.5057881 0.5060428 0.5062971 [78] 0.5065509 0.5068044 0.5070573 0.5073099 0.5075620 0.5078136 0.5080648 [85] 0.5083155 0.5085658 0.5088157 0.5090651 0.5093140 0.5095625 0.5098106 [92] 0.5100581 0.5103053 0.5105519 0.5107981 0.5110439 0.5112891 0.5115339 [99] 0.5117783 0.5120222 0.5122656 0.5125085 0.5127510 0.5129930 0.5132345 [106] 0.5134756 0.5137161 0.5139562 0.5141959 0.5144350 0.5146737 0.5149119 [113] 0.5151496 0.5153868 0.5156235 0.5158598 0.5160955 0.5163308 0.5165656 [120] 0.5167999 0.5170337 0.5172670 0.5174998 0.5177322 0.5179640 0.5181953 [127] 0.5184261 0.5186565 0.5188863 0.5191156 0.5193445 0.5195728 0.5198006 [134] 0.5200279 0.5202547 0.5204810 0.5207068 0.5209321 0.5211569 0.5213812 [141] 0.5216049 0.5218281 0.5220508 0.5222730 0.5224947 0.5227159 0.5229365 [148] 0.5231567 0.5233763 0.5235953 0.5238139 0.5240319 0.5242494 0.5244664 [155] 0.5246829 0.5248988 0.5251142 0.5253291 0.5255434 0.5257572 0.5259705 [162] 0.5261832 0.5263954 0.5266071 0.5268182 0.5270288 0.5272388 0.5274484 [169] 0.5276573 0.5278658 0.5280736 0.5282810 0.5284878 0.5286940 0.5288997 [176] 0.5291049 0.5293095 0.5295136 0.5297171 0.5299201 0.5301225 0.5303243 [183] 0.5305256 0.5307264 0.5309266 0.5311262 0.5313253 0.5315239 0.5317218 [190] 0.5319192 0.5321161 0.5323124 0.5325081 0.5327033 0.5328979 0.5330919 [197] 0.5332854 0.5334783 0.5336707 0.5338624 0.5340537 0.5342443 0.5344344 [204] 0.5346239 0.5348128 0.5350012 0.5351890 0.5353762 0.5355628 0.5357489 [211] 0.5359344 0.5361193 0.5363036 0.5364874 0.5366706 0.5368532 0.5370352 [218] 0.5372167 0.5373975 0.5375778 0.5377575 0.5379367 0.5381152 0.5382931 [225] 0.5384705 0.5386473 0.5388235 0.5389991 0.5391741 0.5393486 0.5395224 [232] 0.5396957 0.5398683 0.5400404 0.5402119 0.5403828 0.5405531 0.5407228 [239] 0.5408919 0.5410605 0.5412284 0.5413957 0.5415625 0.5417286 0.5418941 [246] 0.5420591 0.5422234 0.5423872 0.5425503 0.5427129 0.5428748 0.5430362 [253] 0.5431969 0.5433571 0.5435166 0.5436756 0.5438339 0.5439916 0.5441488 [260] 0.5443053 0.5444612 0.5446165 0.5447712 0.5449254 0.5450788 0.5452317 [267] 0.5453840 0.5455357 0.5456867 0.5458372 0.5459870 0.5461363 0.5462849 [274] 0.5464329 0.5465803 0.5467271 0.5468733 0.5470188 0.5471638 0.5473081 [281] 0.5474518 0.5475949 0.5477374 0.5478793 0.5480206 0.5481612 0.5483012 [288] 0.5484407 0.5485794 0.5487176 0.5488552 0.5489921 0.5491284 0.5492641 [295] 0.5493992 0.5495337 0.5496675 0.5498008 0.5499334 0.5500654 0.5501967 [302] 0.5503275 0.5504576 0.5505871 0.5507160 0.5508442 0.5509718 0.5510988 [309] 0.5512252 0.5513510 0.5514761 0.5516006 0.5517245 0.5518478 0.5519704 [316] 0.5520924 0.5522138 0.5523346 0.5524547 0.5525742 0.5526931 0.5528114 [323] 0.5529290 0.5530460 0.5531624 0.5532781 0.5533933 0.5535077 0.5536216 [330] 0.5537349 0.5538475 0.5539594 0.5540708 0.5541815 0.5542916 0.5544011 [337] 0.5545099 0.5546181 0.5547257 0.5548326 0.5549390 0.5550446 0.5551497 [344] 0.5552541 0.5553579 0.5554611 0.5555636 0.5556655 0.5557668 0.5558675 [351] 0.5559675 0.5560668 0.5561656 0.5562637 0.5563612 0.5564581 0.5565543 [358] 0.5566499 0.5567448 0.5568392 0.5569329 0.5570259 0.5571184 0.5572102 [365] 0.5573013 0.5573919 0.5574818 0.5575710 0.5576597 0.5577477 0.5578351 [372] 0.5579218 0.5580079 0.5580934 0.5581783 0.5582625 0.5583461 0.5584290 [379] 0.5585113 0.5585930 0.5586741 0.5587545 0.5588343 0.5589134 0.5589920 [386] 0.5590699 0.5591471 0.5592238 0.5592998 0.5593751 0.5594499 0.5595240 [393] 0.5595974 0.5596703 0.5597425 0.5598141 0.5598850 0.5599553 0.5600250 [400] 0.5600941 0.5601625 > mx [1] 0.5601625 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1aa141227561370.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/2qxcy1227561370.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/37mhx1227561370.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/44yox1227561370.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/556y01227561370.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/6gcfi1227561370.tab") > > system("convert tmp/1aa141227561370.ps tmp/1aa141227561370.png") > system("convert tmp/2qxcy1227561370.ps tmp/2qxcy1227561370.png") > system("convert tmp/37mhx1227561370.ps tmp/37mhx1227561370.png") > system("convert tmp/44yox1227561370.ps tmp/44yox1227561370.png") > system("convert tmp/556y01227561370.ps tmp/556y01227561370.png") > > > proc.time() user system elapsed 1.115 0.796 1.390