R version 2.7.2 (2008-08-25) 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(17471,14968,15449,17582,18501,17291,16465,17109,18438,16944,16362,16965,18937,17842,16187,17655,19194,18400,17436,19526,21304,18947,18786,24304,23724,23823,21433,23900,25432,23619,23761,23844,26374,24406,24752,26005,27758,25534,26415,28217,29101,27715,27622,29065,31450,29571,30996,30937,34106,32851,36114,34383,38077,35638,35254,36683,38977,34951,34177,35299,36419) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2007), Box-Cox Normality Plot (v1.0.4) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxnorm.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description > 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.9093136 0.9095286 0.9097429 0.9099565 0.9101694 0.9103817 0.9105933 [8] 0.9108042 0.9110144 0.9112239 0.9114328 0.9116409 0.9118483 0.9120550 [15] 0.9122610 0.9124663 0.9126709 0.9128748 0.9130779 0.9132803 0.9134820 [22] 0.9136830 0.9138832 0.9140827 0.9142815 0.9144795 0.9146767 0.9148732 [29] 0.9150690 0.9152640 0.9154582 0.9156517 0.9158444 0.9160363 0.9162275 [36] 0.9164179 0.9166075 0.9167963 0.9169843 0.9171716 0.9173580 0.9175437 [43] 0.9177285 0.9179126 0.9180958 0.9182783 0.9184599 0.9186407 0.9188207 [50] 0.9189998 0.9191782 0.9193557 0.9195324 0.9197082 0.9198832 0.9200573 [57] 0.9202307 0.9204031 0.9205747 0.9207455 0.9209154 0.9210844 0.9212526 [64] 0.9214199 0.9215863 0.9217519 0.9219166 0.9220803 0.9222433 0.9224053 [71] 0.9225664 0.9227267 0.9228860 0.9230444 0.9232020 0.9233586 0.9235143 [78] 0.9236691 0.9238230 0.9239760 0.9241280 0.9242792 0.9244294 0.9245786 [85] 0.9247270 0.9248743 0.9250208 0.9251663 0.9253109 0.9254545 0.9255971 [92] 0.9257388 0.9258796 0.9260193 0.9261581 0.9262960 0.9264329 0.9265688 [99] 0.9267037 0.9268376 0.9269706 0.9271025 0.9272335 0.9273635 0.9274925 [106] 0.9276205 0.9277475 0.9278735 0.9279984 0.9281224 0.9282454 0.9283673 [113] 0.9284882 0.9286081 0.9287270 0.9288449 0.9289617 0.9290775 0.9291922 [120] 0.9293060 0.9294186 0.9295303 0.9296409 0.9297504 0.9298589 0.9299663 [127] 0.9300727 0.9301780 0.9302823 0.9303855 0.9304876 0.9305887 0.9306887 [134] 0.9307876 0.9308854 0.9309822 0.9310778 0.9311724 0.9312659 0.9313583 [141] 0.9314497 0.9315399 0.9316290 0.9317170 0.9318040 0.9318898 0.9319745 [148] 0.9320581 0.9321406 0.9322220 0.9323023 0.9323814 0.9324595 0.9325364 [155] 0.9326122 0.9326869 0.9327604 0.9328328 0.9329041 0.9329742 0.9330432 [162] 0.9331111 0.9331778 0.9332434 0.9333078 0.9333711 0.9334333 0.9334943 [169] 0.9335541 0.9336128 0.9336703 0.9337267 0.9337819 0.9338360 0.9338889 [176] 0.9339406 0.9339912 0.9340406 0.9340888 0.9341358 0.9341817 0.9342264 [183] 0.9342700 0.9343123 0.9343535 0.9343935 0.9344323 0.9344699 0.9345064 [190] 0.9345416 0.9345757 0.9346086 0.9346403 0.9346708 0.9347001 0.9347282 [197] 0.9347551 0.9347808 0.9348053 0.9348287 0.9348508 0.9348717 0.9348914 [204] 0.9349099 0.9349273 0.9349434 0.9349583 0.9349720 0.9349844 0.9349957 [211] 0.9350058 0.9350146 0.9350223 0.9350287 0.9350339 0.9350379 0.9350407 [218] 0.9350423 0.9350427 0.9350418 0.9350397 0.9350364 0.9350319 0.9350262 [225] 0.9350192 0.9350111 0.9350017 0.9349911 0.9349792 0.9349662 0.9349519 [232] 0.9349364 0.9349197 0.9349018 0.9348826 0.9348622 0.9348406 0.9348177 [239] 0.9347937 0.9347684 0.9347419 0.9347142 0.9346852 0.9346550 0.9346236 [246] 0.9345910 0.9345571 0.9345221 0.9344858 0.9344482 0.9344095 0.9343695 [253] 0.9343283 0.9342859 0.9342423 0.9341974 0.9341514 0.9341041 0.9340555 [260] 0.9340058 0.9339548 0.9339027 0.9338493 0.9337947 0.9337388 0.9336818 [267] 0.9336235 0.9335640 0.9335033 0.9334414 0.9333783 0.9333140 0.9332484 [274] 0.9331817 0.9331137 0.9330445 0.9329742 0.9329026 0.9328298 0.9327558 [281] 0.9326806 0.9326042 0.9325265 0.9324477 0.9323677 0.9322865 0.9322041 [288] 0.9321205 0.9320357 0.9319497 0.9318625 0.9317741 0.9316846 0.9315938 [295] 0.9315019 0.9314088 0.9313144 0.9312189 0.9311223 0.9310244 0.9309254 [302] 0.9308252 0.9307238 0.9306212 0.9305175 0.9304126 0.9303065 0.9301993 [309] 0.9300909 0.9299813 0.9298706 0.9297587 0.9296457 0.9295315 0.9294161 [316] 0.9292996 0.9291820 0.9290632 0.9289432 0.9288221 0.9286999 0.9285765 [323] 0.9284520 0.9283264 0.9281996 0.9280717 0.9279427 0.9278125 0.9276812 [330] 0.9275488 0.9274152 0.9272806 0.9271448 0.9270079 0.9268700 0.9267309 [337] 0.9265906 0.9264493 0.9263069 0.9261634 0.9260188 0.9258731 0.9257263 [344] 0.9255784 0.9254295 0.9252794 0.9251283 0.9249761 0.9248228 0.9246684 [351] 0.9245130 0.9243565 0.9241989 0.9240403 0.9238806 0.9237198 0.9235581 [358] 0.9233952 0.9232313 0.9230664 0.9229004 0.9227333 0.9225653 0.9223962 [365] 0.9222261 0.9220549 0.9218827 0.9217095 0.9215353 0.9213601 0.9211838 [372] 0.9210065 0.9208283 0.9206490 0.9204687 0.9202875 0.9201052 0.9199219 [379] 0.9197377 0.9195525 0.9193662 0.9191790 0.9189909 0.9188017 0.9186116 [386] 0.9184206 0.9182285 0.9180355 0.9178416 0.9176467 0.9174508 0.9172540 [393] 0.9170563 0.9168576 0.9166580 0.9164574 0.9162559 0.9160535 0.9158502 [400] 0.9156459 0.9154408 > mx [1] 0.9350427 > mxli [1] 0.18 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/10xwg1226422527.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/2r1cs1226422527.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/3f9491226422527.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/4f8a21226422527.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x) > grid() > mtext('Original Data') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/5xo1c1226422527.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(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/6a64b1226422527.tab") > > system("convert tmp/10xwg1226422527.ps tmp/10xwg1226422527.png") > system("convert tmp/2r1cs1226422527.ps tmp/2r1cs1226422527.png") > system("convert tmp/3f9491226422527.ps tmp/3f9491226422527.png") > system("convert tmp/4f8a21226422527.ps tmp/4f8a21226422527.png") > system("convert tmp/5xo1c1226422527.ps tmp/5xo1c1226422527.png") > > > proc.time() user system elapsed 1.341 0.812 1.585