R version 2.8.1 (2008-12-22) 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(80.9,113.8,71.2,55.8,61,60.8,74.3,66.5,71,61.6,66.4,74.7,72.4,76.4,86.4,73.9,133.1,83.3,85.8,76.8,92.7,68.8,69.4,97,84.6,84.2,201.8,83.1,69.4,78.8,77.1,90.7,107.5,81.4,83.3,105.7,85.8,87.2,87.5,77.5,78.5,89.7,94.3,104.4,115.9,90,91.1,119.8,101.9,99.2,115.7,94.9,99.8,109.6,109,119.6,119.2,94.6,102.5,105.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.6254249 0.6253129 0.6251987 0.6250823 0.6249637 0.6248429 0.6247198 [8] 0.6245945 0.6244669 0.6243370 0.6242049 0.6240705 0.6239338 0.6237949 [15] 0.6236536 0.6235100 0.6233640 0.6232158 0.6230652 0.6229122 0.6227569 [22] 0.6225992 0.6224392 0.6222767 0.6221119 0.6219446 0.6217749 0.6216029 [29] 0.6214283 0.6212514 0.6210720 0.6208901 0.6207057 0.6205189 0.6203296 [36] 0.6201378 0.6199435 0.6197467 0.6195473 0.6193454 0.6191410 0.6189340 [43] 0.6187245 0.6185124 0.6182977 0.6180804 0.6178605 0.6176380 0.6174129 [50] 0.6171851 0.6169547 0.6167217 0.6164860 0.6162476 0.6160066 0.6157629 [57] 0.6155164 0.6152673 0.6150154 0.6147609 0.6145036 0.6142435 0.6139807 [64] 0.6137151 0.6134467 0.6131756 0.6129016 0.6126249 0.6123453 0.6120629 [71] 0.6117777 0.6114896 0.6111987 0.6109049 0.6106082 0.6103087 0.6100062 [78] 0.6097009 0.6093926 0.6090814 0.6087672 0.6084502 0.6081301 0.6078071 [85] 0.6074811 0.6071521 0.6068202 0.6064852 0.6061472 0.6058061 0.6054621 [92] 0.6051150 0.6047648 0.6044115 0.6040552 0.6036958 0.6033333 0.6029676 [99] 0.6025989 0.6022270 0.6018520 0.6014738 0.6010925 0.6007080 0.6003203 [106] 0.5999294 0.5995353 0.5991380 0.5987375 0.5983337 0.5979267 0.5975165 [113] 0.5971030 0.5966862 0.5962661 0.5958427 0.5954160 0.5949860 0.5945527 [120] 0.5941161 0.5936761 0.5932327 0.5927860 0.5923359 0.5918825 0.5914256 [127] 0.5909653 0.5905016 0.5900345 0.5895639 0.5890900 0.5886125 0.5881316 [134] 0.5876472 0.5871593 0.5866680 0.5861731 0.5856747 0.5851728 0.5846674 [141] 0.5841584 0.5836459 0.5831298 0.5826102 0.5820870 0.5815601 0.5810297 [148] 0.5804957 0.5799581 0.5794168 0.5788720 0.5783234 0.5777713 0.5772154 [155] 0.5766559 0.5760927 0.5755259 0.5749553 0.5743811 0.5738031 0.5732214 [162] 0.5726360 0.5720469 0.5714540 0.5708574 0.5702570 0.5696528 0.5690449 [169] 0.5684332 0.5678177 0.5671984 0.5665753 0.5659484 0.5653176 0.5646831 [176] 0.5640447 0.5634025 0.5627564 0.5621065 0.5614527 0.5607951 0.5601336 [183] 0.5594682 0.5587990 0.5581258 0.5574488 0.5567678 0.5560830 0.5553942 [190] 0.5547015 0.5540049 0.5533044 0.5526000 0.5518916 0.5511793 0.5504630 [197] 0.5497428 0.5490186 0.5482905 0.5475584 0.5468224 0.5460823 0.5453384 [204] 0.5445904 0.5438385 0.5430826 0.5423227 0.5415588 0.5407909 0.5400191 [211] 0.5392433 0.5384634 0.5376796 0.5368918 0.5361000 0.5353042 0.5345044 [218] 0.5337006 0.5328928 0.5320810 0.5312652 0.5304454 0.5296216 0.5287939 [225] 0.5279621 0.5271263 0.5262866 0.5254428 0.5245951 0.5237434 0.5228877 [232] 0.5220280 0.5211643 0.5202966 0.5194250 0.5185494 0.5176699 0.5167864 [239] 0.5158989 0.5150075 0.5141121 0.5132128 0.5123095 0.5114023 0.5104912 [246] 0.5095762 0.5086572 0.5077344 0.5068076 0.5058770 0.5049424 0.5040040 [253] 0.5030617 0.5021156 0.5011656 0.5002117 0.4992541 0.4982925 0.4973272 [260] 0.4963581 0.4953851 0.4944084 0.4934279 0.4924436 0.4914556 0.4904638 [267] 0.4894684 0.4884691 0.4874662 0.4864596 0.4854493 0.4844354 0.4834177 [274] 0.4823965 0.4813716 0.4803431 0.4793110 0.4782754 0.4772362 0.4761934 [281] 0.4751471 0.4740973 0.4730439 0.4719871 0.4709269 0.4698631 0.4687960 [288] 0.4677254 0.4666515 0.4655742 0.4644935 0.4634095 0.4623222 0.4612315 [295] 0.4601376 0.4590405 0.4579401 0.4568365 0.4557298 0.4546198 0.4535067 [302] 0.4523905 0.4512712 0.4501488 0.4490234 0.4478949 0.4467634 0.4456290 [309] 0.4444915 0.4433512 0.4422079 0.4410618 0.4399128 0.4387610 0.4376064 [316] 0.4364490 0.4352889 0.4341260 0.4329605 0.4317923 0.4306214 0.4294480 [323] 0.4282719 0.4270933 0.4259122 0.4247286 0.4235425 0.4223540 0.4211631 [330] 0.4199699 0.4187742 0.4175763 0.4163761 0.4151736 0.4139690 0.4127621 [337] 0.4115531 0.4103420 0.4091287 0.4079135 0.4066962 0.4054769 0.4042556 [344] 0.4030325 0.4018074 0.4005805 0.3993518 0.3981213 0.3968890 0.3956551 [351] 0.3944194 0.3931821 0.3919432 0.3907027 0.3894607 0.3882172 0.3869722 [358] 0.3857257 0.3844779 0.3832287 0.3819782 0.3807264 0.3794734 0.3782191 [365] 0.3769637 0.3757071 0.3744495 0.3731907 0.3719310 0.3706702 0.3694085 [372] 0.3681459 0.3668824 0.3656181 0.3643529 0.3630871 0.3618204 0.3605531 [379] 0.3592852 0.3580166 0.3567475 0.3554778 0.3542077 0.3529370 0.3516660 [386] 0.3503946 0.3491228 0.3478507 0.3465784 0.3453059 0.3440331 0.3427602 [393] 0.3414872 0.3402141 0.3389410 0.3376679 0.3363948 0.3351218 0.3338489 [400] 0.3325761 0.3313036 > mx [1] 0.6254249 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/rcomp/tmp/18c641257972050.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/rcomp/tmp/2xlaz1257972050.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/rcomp/tmp/3w5lh1257972050.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/rcomp/tmp/4qdzj1257972050.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/rcomp/tmp/5cheq1257972050.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/6hp5c1257972050.tab") > > system("convert tmp/18c641257972050.ps tmp/18c641257972050.png") > system("convert tmp/2xlaz1257972050.ps tmp/2xlaz1257972050.png") > system("convert tmp/3w5lh1257972050.ps tmp/3w5lh1257972050.png") > system("convert tmp/4qdzj1257972050.ps tmp/4qdzj1257972050.png") > system("convert tmp/5cheq1257972050.ps tmp/5cheq1257972050.png") > > > proc.time() user system elapsed 1.330 1.280 2.256