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(10070,10137,9984,9732,9103,9155,9308,9394,9948,10177,10002,9728,10002,10063,10018,9960,10236,10893,10756,10940,10997,10827,10166,10186,10457,10368,10244,10511,10812,10738,10171,9721,9897,9828,9924,10371,10846,10413,10709,10662,10570,10297,10635,10872,10296,10383,10431,10574,10653,10805,10872,10625,10407,10463,10556,10646,10702,11353,11346,11451,11964,12574,13031,13812,14544,14931,14886,16005,17064,15168,16050,15839,15137,14954,15648,15305,15579,16348,15928,16171,15937,15713,15594,15683,16438,17032,17696,17745,19394,20148,20108,18584,18441,18391,19178,18079,18483,19644,19195) > #'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.8866162 0.8866172 0.8866179 0.8866184 0.8866186 0.8866185 0.8866181 [8] 0.8866174 0.8866165 0.8866153 0.8866139 0.8866121 0.8866101 0.8866078 [15] 0.8866052 0.8866024 0.8865993 0.8865959 0.8865922 0.8865883 0.8865841 [22] 0.8865796 0.8865748 0.8865698 0.8865645 0.8865589 0.8865530 0.8865469 [29] 0.8865404 0.8865337 0.8865268 0.8865195 0.8865120 0.8865042 0.8864961 [36] 0.8864877 0.8864791 0.8864701 0.8864609 0.8864514 0.8864417 0.8864316 [43] 0.8864213 0.8864107 0.8863998 0.8863887 0.8863772 0.8863655 0.8863535 [50] 0.8863412 0.8863287 0.8863158 0.8863027 0.8862893 0.8862756 0.8862616 [57] 0.8862473 0.8862328 0.8862180 0.8862029 0.8861875 0.8861718 0.8861558 [64] 0.8861396 0.8861230 0.8861062 0.8860891 0.8860717 0.8860540 0.8860360 [71] 0.8860178 0.8859992 0.8859804 0.8859613 0.8859418 0.8859221 0.8859022 [78] 0.8858819 0.8858613 0.8858404 0.8858193 0.8857978 0.8857761 0.8857541 [85] 0.8857318 0.8857091 0.8856862 0.8856630 0.8856395 0.8856158 0.8855917 [92] 0.8855673 0.8855426 0.8855177 0.8854924 0.8854668 0.8854410 0.8854148 [99] 0.8853884 0.8853616 0.8853346 0.8853072 0.8852796 0.8852516 0.8852234 [106] 0.8851948 0.8851659 0.8851368 0.8851073 0.8850776 0.8850475 0.8850172 [113] 0.8849865 0.8849555 0.8849242 0.8848926 0.8848608 0.8848286 0.8847961 [120] 0.8847632 0.8847301 0.8846967 0.8846630 0.8846289 0.8845946 0.8845599 [127] 0.8845249 0.8844897 0.8844541 0.8844182 0.8843819 0.8843454 0.8843085 [134] 0.8842714 0.8842339 0.8841961 0.8841580 0.8841196 0.8840808 0.8840418 [141] 0.8840024 0.8839627 0.8839227 0.8838824 0.8838417 0.8838008 0.8837595 [148] 0.8837178 0.8836759 0.8836336 0.8835911 0.8835482 0.8835049 0.8834614 [155] 0.8834175 0.8833733 0.8833287 0.8832839 0.8832387 0.8831932 0.8831473 [162] 0.8831012 0.8830547 0.8830078 0.8829607 0.8829132 0.8828653 0.8828172 [169] 0.8827687 0.8827198 0.8826707 0.8826212 0.8825713 0.8825211 0.8824706 [176] 0.8824198 0.8823686 0.8823171 0.8822652 0.8822130 0.8821604 0.8821075 [183] 0.8820543 0.8820007 0.8819468 0.8818926 0.8818380 0.8817830 0.8817277 [190] 0.8816721 0.8816161 0.8815597 0.8815030 0.8814460 0.8813886 0.8813309 [197] 0.8812728 0.8812144 0.8811556 0.8810964 0.8810369 0.8809771 0.8809169 [204] 0.8808563 0.8807954 0.8807341 0.8806725 0.8806105 0.8805481 0.8804854 [211] 0.8804224 0.8803589 0.8802952 0.8802310 0.8801665 0.8801016 0.8800364 [218] 0.8799708 0.8799048 0.8798385 0.8797718 0.8797047 0.8796372 0.8795694 [225] 0.8795013 0.8794327 0.8793638 0.8792945 0.8792249 0.8791548 0.8790844 [232] 0.8790136 0.8789425 0.8788710 0.8787991 0.8787268 0.8786541 0.8785811 [239] 0.8785077 0.8784339 0.8783597 0.8782851 0.8782102 0.8781349 0.8780592 [246] 0.8779831 0.8779067 0.8778298 0.8777526 0.8776750 0.8775969 0.8775186 [253] 0.8774398 0.8773606 0.8772810 0.8772011 0.8771208 0.8770400 0.8769589 [260] 0.8768774 0.8767955 0.8767132 0.8766305 0.8765474 0.8764639 0.8763801 [267] 0.8762958 0.8762111 0.8761260 0.8760406 0.8759547 0.8758684 0.8757818 [274] 0.8756947 0.8756072 0.8755193 0.8754311 0.8753424 0.8752533 0.8751638 [281] 0.8750739 0.8749836 0.8748929 0.8748018 0.8747102 0.8746183 0.8745260 [288] 0.8744332 0.8743400 0.8742465 0.8741525 0.8740581 0.8739633 0.8738680 [295] 0.8737724 0.8736764 0.8735799 0.8734830 0.8733857 0.8732880 0.8731898 [302] 0.8730913 0.8729923 0.8728929 0.8727931 0.8726929 0.8725922 0.8724911 [309] 0.8723896 0.8722877 0.8721854 0.8720826 0.8719794 0.8718758 0.8717718 [316] 0.8716673 0.8715624 0.8714571 0.8713513 0.8712451 0.8711385 0.8710315 [323] 0.8709240 0.8708161 0.8707078 0.8705991 0.8704899 0.8703802 0.8702702 [330] 0.8701597 0.8700488 0.8699374 0.8698256 0.8697134 0.8696008 0.8694877 [337] 0.8693741 0.8692602 0.8691457 0.8690309 0.8689156 0.8687999 0.8686837 [344] 0.8685671 0.8684501 0.8683326 0.8682147 0.8680963 0.8679775 0.8678583 [351] 0.8677386 0.8676184 0.8674979 0.8673768 0.8672554 0.8671335 0.8670111 [358] 0.8668883 0.8667651 0.8666414 0.8665172 0.8663926 0.8662676 0.8661421 [365] 0.8660162 0.8658898 0.8657630 0.8656357 0.8655080 0.8653798 0.8652512 [372] 0.8651221 0.8649926 0.8648626 0.8647322 0.8646013 0.8644700 0.8643382 [379] 0.8642060 0.8640733 0.8639401 0.8638065 0.8636725 0.8635380 0.8634030 [386] 0.8632676 0.8631318 0.8629955 0.8628587 0.8627215 0.8625838 0.8624456 [393] 0.8623070 0.8621680 0.8620285 0.8618885 0.8617481 0.8616072 0.8614659 [400] 0.8613241 0.8611819 > mx [1] 0.8866186 > mxli [1] -1.96 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1i9c01229169766.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/2qle41229169766.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/3sh0k1229169766.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/4orqj1229169766.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/50bde1229169766.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/6646d1229169766.tab") > > system("convert tmp/1i9c01229169766.ps tmp/1i9c01229169766.png") > system("convert tmp/2qle41229169766.ps tmp/2qle41229169766.png") > system("convert tmp/3sh0k1229169766.ps tmp/3sh0k1229169766.png") > system("convert tmp/4orqj1229169766.ps tmp/4orqj1229169766.png") > system("convert tmp/50bde1229169766.ps tmp/50bde1229169766.png") > > > proc.time() user system elapsed 1.073 0.792 1.305