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. > x <- c(1.4,1.6,1.7,2.0,2.0,2.1,2.5,2.5,2.6,2.7,3.7,4.0,5.0,5.1,5.1,5.0,5.1,4.7,4.5,4.5,4.6,4.6,4.6,4.6,5.3,5.4,5.3,5.2,5.0,4.2,4.3,4.3,4.3,4.0,4.0,4.1,4.4,3.6,3.7,3.8,3.3,3.3,3.3,3.5,3.3,3.3,3.4,3.4,5.2,5.3,4.8,5.0,4.6,4.6,3.5,3.5) > #'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.6070905 0.6069647 0.6068355 0.6067028 0.6065667 0.6064272 0.6062841 [8] 0.6061377 0.6059877 0.6058342 0.6056773 0.6055168 0.6053528 0.6051853 [15] 0.6050143 0.6048397 0.6046615 0.6044798 0.6042945 0.6041056 0.6039132 [22] 0.6037171 0.6035174 0.6033142 0.6031073 0.6028968 0.6026826 0.6024648 [29] 0.6022433 0.6020182 0.6017895 0.6015570 0.6013209 0.6010811 0.6008376 [36] 0.6005905 0.6003396 0.6000850 0.5998267 0.5995647 0.5992990 0.5990295 [43] 0.5987563 0.5984794 0.5981988 0.5979144 0.5976262 0.5973343 0.5970386 [50] 0.5967392 0.5964360 0.5961291 0.5958184 0.5955039 0.5951856 0.5948636 [57] 0.5945378 0.5942082 0.5938748 0.5935376 0.5931967 0.5928520 0.5925034 [64] 0.5921511 0.5917950 0.5914352 0.5910715 0.5907040 0.5903328 0.5899577 [71] 0.5895789 0.5891963 0.5888098 0.5884197 0.5880257 0.5876279 0.5872264 [78] 0.5868210 0.5864119 0.5859991 0.5855824 0.5851620 0.5847378 0.5843099 [85] 0.5838782 0.5834427 0.5830035 0.5825605 0.5821138 0.5816633 0.5812091 [92] 0.5807512 0.5802896 0.5798242 0.5793551 0.5788823 0.5784058 0.5779257 [99] 0.5774418 0.5769542 0.5764630 0.5759680 0.5754695 0.5749672 0.5744613 [106] 0.5739518 0.5734386 0.5729218 0.5724014 0.5718774 0.5713498 0.5708186 [113] 0.5702838 0.5697455 0.5692035 0.5686581 0.5681090 0.5675565 0.5670004 [120] 0.5664408 0.5658777 0.5653112 0.5647411 0.5641676 0.5635906 0.5630102 [127] 0.5624263 0.5618391 0.5612484 0.5606543 0.5600568 0.5594560 0.5588518 [134] 0.5582443 0.5576334 0.5570192 0.5564017 0.5557810 0.5551569 0.5545296 [141] 0.5538991 0.5532653 0.5526283 0.5519881 0.5513447 0.5506981 0.5500484 [148] 0.5493956 0.5487396 0.5480805 0.5474184 0.5467531 0.5460848 0.5454135 [155] 0.5447391 0.5440618 0.5433814 0.5426981 0.5420118 0.5413225 0.5406304 [162] 0.5399354 0.5392374 0.5385366 0.5378330 0.5371265 0.5364172 0.5357052 [169] 0.5349903 0.5342727 0.5335524 0.5328294 0.5321036 0.5313752 0.5306442 [176] 0.5299104 0.5291741 0.5284352 0.5276937 0.5269497 0.5262031 0.5254540 [183] 0.5247024 0.5239483 0.5231918 0.5224329 0.5216715 0.5209078 0.5201416 [190] 0.5193732 0.5186024 0.5178293 0.5170539 0.5162763 0.5154964 0.5147143 [197] 0.5139300 0.5131435 0.5123549 0.5115642 0.5107713 0.5099764 0.5091793 [204] 0.5083803 0.5075792 0.5067762 0.5059711 0.5051641 0.5043552 0.5035444 [211] 0.5027317 0.5019171 0.5011007 0.5002825 0.4994624 0.4986406 0.4978171 [218] 0.4969918 0.4961649 0.4953362 0.4945059 0.4936740 0.4928405 0.4920053 [225] 0.4911687 0.4903304 0.4894907 0.4886494 0.4878067 0.4869626 0.4861170 [232] 0.4852700 0.4844216 0.4835719 0.4827209 0.4818685 0.4810149 0.4801599 [239] 0.4793038 0.4784464 0.4775879 0.4767281 0.4758673 0.4750052 0.4741421 [246] 0.4732780 0.4724127 0.4715464 0.4706791 0.4698109 0.4689416 0.4680714 [253] 0.4672003 0.4663283 0.4654555 0.4645817 0.4637072 0.4628318 0.4619556 [260] 0.4610787 0.4602011 0.4593227 0.4584436 0.4575639 0.4566835 0.4558025 [267] 0.4549208 0.4540386 0.4531558 0.4522725 0.4513887 0.4505043 0.4496195 [274] 0.4487342 0.4478485 0.4469624 0.4460758 0.4451890 0.4443017 0.4434141 [281] 0.4425263 0.4416381 0.4407497 0.4398610 0.4389721 0.4380829 0.4371936 [288] 0.4363042 0.4354146 0.4345248 0.4336350 0.4327451 0.4318551 0.4309651 [295] 0.4300750 0.4291850 0.4282949 0.4274049 0.4265149 0.4256250 0.4247352 [302] 0.4238455 0.4229560 0.4220666 0.4211773 0.4202882 0.4193994 0.4185107 [309] 0.4176223 0.4167342 0.4158463 0.4149587 0.4140714 0.4131845 0.4122979 [316] 0.4114116 0.4105258 0.4096403 0.4087553 0.4078707 0.4069865 0.4061028 [323] 0.4052196 0.4043368 0.4034546 0.4025729 0.4016918 0.4008112 0.3999312 [330] 0.3990518 0.3981731 0.3972949 0.3964174 0.3955405 0.3946643 0.3937888 [337] 0.3929140 0.3920399 0.3911665 0.3902939 0.3894220 0.3885509 0.3876806 [344] 0.3868111 0.3859424 0.3850746 0.3842075 0.3833414 0.3824761 0.3816117 [351] 0.3807482 0.3798856 0.3790239 0.3781632 0.3773034 0.3764445 0.3755867 [358] 0.3747298 0.3738739 0.3730190 0.3721652 0.3713124 0.3704606 0.3696099 [365] 0.3687603 0.3679117 0.3670642 0.3662179 0.3653726 0.3645285 0.3636855 [372] 0.3628436 0.3620029 0.3611634 0.3603250 0.3594879 0.3586519 0.3578171 [379] 0.3569836 0.3561513 0.3553202 0.3544904 0.3536618 0.3528344 0.3520084 [386] 0.3511836 0.3503602 0.3495380 0.3487171 0.3478976 0.3470794 0.3462625 [393] 0.3454469 0.3446327 0.3438199 0.3430084 0.3421983 0.3413896 0.3405823 [400] 0.3397764 0.3389718 > mx [1] 0.6070905 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1ot8y1258121372.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/2jtdm1258121372.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/37c171258121372.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/4b5at1258121372.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/5kc3e1258121372.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/6kdlj1258121372.tab") > > system("convert tmp/1ot8y1258121372.ps tmp/1ot8y1258121372.png") > system("convert tmp/2jtdm1258121372.ps tmp/2jtdm1258121372.png") > system("convert tmp/37c171258121372.ps tmp/37c171258121372.png") > system("convert tmp/4b5at1258121372.ps tmp/4b5at1258121372.png") > system("convert tmp/5kc3e1258121372.ps tmp/5kc3e1258121372.png") > > > proc.time() user system elapsed 1.100 0.790 1.436