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(9487,8700,9627,8947,9283,8829,9947,9628,9318,9605,8640,9214,9567,8547,9185,9470,9123,9278,10170,9434,9655,9429,8739,9552,9687,9019,9672,9206,9069,9788,10312,10105,9863,9656,9295,9946,9701,9049,10190,9706,9765,9893,9994,10433,10073,10112,9266,9820,10097,9115,10411,9678,10408,10153,10368,10581,10597,10680,9738,9556) > #'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.5689086 0.5689580 0.5690073 0.5690566 0.5691058 0.5691550 0.5692042 [8] 0.5692533 0.5693023 0.5693513 0.5694002 0.5694491 0.5694980 0.5695468 [15] 0.5695955 0.5696442 0.5696929 0.5697415 0.5697901 0.5698386 0.5698870 [22] 0.5699355 0.5699838 0.5700322 0.5700804 0.5701287 0.5701768 0.5702250 [29] 0.5702731 0.5703211 0.5703691 0.5704170 0.5704649 0.5705128 0.5705606 [36] 0.5706083 0.5706560 0.5707037 0.5707513 0.5707988 0.5708463 0.5708938 [43] 0.5709412 0.5709885 0.5710359 0.5710831 0.5711303 0.5711775 0.5712246 [50] 0.5712717 0.5713187 0.5713657 0.5714126 0.5714595 0.5715063 0.5715531 [57] 0.5715998 0.5716465 0.5716932 0.5717397 0.5717863 0.5718328 0.5718792 [64] 0.5719256 0.5719719 0.5720182 0.5720645 0.5721107 0.5721568 0.5722029 [71] 0.5722490 0.5722950 0.5723409 0.5723868 0.5724327 0.5724785 0.5725242 [78] 0.5725699 0.5726156 0.5726612 0.5727068 0.5727523 0.5727977 0.5728431 [85] 0.5728885 0.5729338 0.5729791 0.5730243 0.5730695 0.5731146 0.5731597 [92] 0.5732047 0.5732496 0.5732946 0.5733394 0.5733843 0.5734290 0.5734738 [99] 0.5735184 0.5735631 0.5736076 0.5736522 0.5736966 0.5737411 0.5737854 [106] 0.5738298 0.5738740 0.5739183 0.5739624 0.5740066 0.5740507 0.5740947 [113] 0.5741387 0.5741826 0.5742265 0.5742703 0.5743141 0.5743578 0.5744015 [120] 0.5744451 0.5744887 0.5745323 0.5745757 0.5746192 0.5746626 0.5747059 [127] 0.5747492 0.5747924 0.5748356 0.5748787 0.5749218 0.5749649 0.5750079 [134] 0.5750508 0.5750937 0.5751365 0.5751793 0.5752220 0.5752647 0.5753074 [141] 0.5753499 0.5753925 0.5754350 0.5754774 0.5755198 0.5755621 0.5756044 [148] 0.5756466 0.5756888 0.5757310 0.5757730 0.5758151 0.5758571 0.5758990 [155] 0.5759409 0.5759827 0.5760245 0.5760662 0.5761079 0.5761496 0.5761911 [162] 0.5762327 0.5762741 0.5763156 0.5763570 0.5763983 0.5764396 0.5764808 [169] 0.5765220 0.5765631 0.5766042 0.5766452 0.5766862 0.5767271 0.5767680 [176] 0.5768088 0.5768496 0.5768903 0.5769310 0.5769716 0.5770122 0.5770527 [183] 0.5770932 0.5771336 0.5771740 0.5772143 0.5772546 0.5772948 0.5773350 [190] 0.5773751 0.5774152 0.5774552 0.5774951 0.5775350 0.5775749 0.5776147 [197] 0.5776545 0.5776942 0.5777339 0.5777735 0.5778130 0.5778525 0.5778920 [204] 0.5779314 0.5779708 0.5780101 0.5780493 0.5780885 0.5781277 0.5781668 [211] 0.5782058 0.5782448 0.5782838 0.5783227 0.5783615 0.5784003 0.5784391 [218] 0.5784778 0.5785164 0.5785550 0.5785935 0.5786320 0.5786705 0.5787089 [225] 0.5787472 0.5787855 0.5788237 0.5788619 0.5789000 0.5789381 0.5789761 [232] 0.5790141 0.5790521 0.5790899 0.5791278 0.5791655 0.5792033 0.5792409 [239] 0.5792785 0.5793161 0.5793536 0.5793911 0.5794285 0.5794659 0.5795032 [246] 0.5795405 0.5795777 0.5796148 0.5796519 0.5796890 0.5797260 0.5797630 [253] 0.5797999 0.5798367 0.5798735 0.5799103 0.5799470 0.5799836 0.5800202 [260] 0.5800568 0.5800933 0.5801297 0.5801661 0.5802024 0.5802387 0.5802749 [267] 0.5803111 0.5803473 0.5803833 0.5804194 0.5804554 0.5804913 0.5805272 [274] 0.5805630 0.5805988 0.5806345 0.5806702 0.5807058 0.5807413 0.5807769 [281] 0.5808123 0.5808477 0.5808831 0.5809184 0.5809537 0.5809889 0.5810240 [288] 0.5810591 0.5810942 0.5811292 0.5811641 0.5811990 0.5812339 0.5812687 [295] 0.5813034 0.5813381 0.5813727 0.5814073 0.5814419 0.5814764 0.5815108 [302] 0.5815452 0.5815795 0.5816138 0.5816480 0.5816822 0.5817163 0.5817504 [309] 0.5817844 0.5818184 0.5818523 0.5818862 0.5819200 0.5819537 0.5819874 [316] 0.5820211 0.5820547 0.5820883 0.5821218 0.5821552 0.5821886 0.5822220 [323] 0.5822553 0.5822885 0.5823217 0.5823548 0.5823879 0.5824210 0.5824540 [330] 0.5824869 0.5825198 0.5825526 0.5825854 0.5826181 0.5826508 0.5826834 [337] 0.5827160 0.5827485 0.5827810 0.5828134 0.5828458 0.5828781 0.5829103 [344] 0.5829426 0.5829747 0.5830068 0.5830389 0.5830709 0.5831028 0.5831347 [351] 0.5831666 0.5831984 0.5832301 0.5832618 0.5832935 0.5833250 0.5833566 [358] 0.5833881 0.5834195 0.5834509 0.5834822 0.5835135 0.5835447 0.5835759 [365] 0.5836070 0.5836381 0.5836691 0.5837001 0.5837310 0.5837619 0.5837927 [372] 0.5838234 0.5838541 0.5838848 0.5839154 0.5839460 0.5839765 0.5840069 [379] 0.5840373 0.5840676 0.5840979 0.5841282 0.5841584 0.5841885 0.5842186 [386] 0.5842486 0.5842786 0.5843086 0.5843384 0.5843683 0.5843980 0.5844278 [393] 0.5844574 0.5844871 0.5845166 0.5845461 0.5845756 0.5846050 0.5846344 [400] 0.5846637 0.5846929 > mx [1] 0.584693 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/rcomp/tmp/115a21257954541.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/2fxm11257954541.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/337qf1257954541.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/4obkg1257954541.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/53fly1257954541.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/6cc5i1257954541.tab") > > system("convert tmp/115a21257954541.ps tmp/115a21257954541.png") > system("convert tmp/2fxm11257954541.ps tmp/2fxm11257954541.png") > system("convert tmp/337qf1257954541.ps tmp/337qf1257954541.png") > system("convert tmp/4obkg1257954541.ps tmp/4obkg1257954541.png") > system("convert tmp/53fly1257954541.ps tmp/53fly1257954541.png") > > > proc.time() user system elapsed 1.390 1.150 2.262