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(7.5,7.6,7.9,7.9,8.1,8.2,8,7.5,6.8,6.5,6.6,7.6,8,8,7.7,7.5,7.6,7.7,7.9,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.1,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.7,6.4,6.3,6.2,6.5,6.8,6.8,6.5,6.3,5.9,5.9,6.4) > #'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.7068824 -0.7068543 -0.7068259 -0.7067974 -0.7067687 -0.7067399 [7] -0.7067109 -0.7066817 -0.7066523 -0.7066228 -0.7065931 -0.7065633 [13] -0.7065332 -0.7065030 -0.7064727 -0.7064422 -0.7064115 -0.7063806 [19] -0.7063496 -0.7063184 -0.7062870 -0.7062555 -0.7062238 -0.7061919 [25] -0.7061599 -0.7061277 -0.7060953 -0.7060628 -0.7060301 -0.7059972 [31] -0.7059642 -0.7059310 -0.7058976 -0.7058641 -0.7058304 -0.7057965 [37] -0.7057625 -0.7057283 -0.7056940 -0.7056595 -0.7056248 -0.7055899 [43] -0.7055549 -0.7055197 -0.7054844 -0.7054489 -0.7054132 -0.7053774 [49] -0.7053414 -0.7053052 -0.7052689 -0.7052324 -0.7051958 -0.7051589 [55] -0.7051220 -0.7050848 -0.7050475 -0.7050101 -0.7049724 -0.7049346 [61] -0.7048967 -0.7048586 -0.7048203 -0.7047818 -0.7047432 -0.7047045 [67] -0.7046655 -0.7046264 -0.7045872 -0.7045478 -0.7045082 -0.7044685 [73] -0.7044286 -0.7043885 -0.7043483 -0.7043079 -0.7042674 -0.7042267 [79] -0.7041858 -0.7041448 -0.7041036 -0.7040623 -0.7040208 -0.7039791 [85] -0.7039373 -0.7038953 -0.7038532 -0.7038109 -0.7037684 -0.7037258 [91] -0.7036830 -0.7036401 -0.7035970 -0.7035537 -0.7035103 -0.7034668 [97] -0.7034230 -0.7033791 -0.7033351 -0.7032909 -0.7032465 -0.7032020 [103] -0.7031574 -0.7031125 -0.7030675 -0.7030224 -0.7029771 -0.7029316 [109] -0.7028860 -0.7028403 -0.7027943 -0.7027483 -0.7027020 -0.7026556 [115] -0.7026091 -0.7025624 -0.7025155 -0.7024685 -0.7024213 -0.7023740 [121] -0.7023265 -0.7022789 -0.7022311 -0.7021831 -0.7021350 -0.7020868 [127] -0.7020384 -0.7019898 -0.7019411 -0.7018922 -0.7018432 -0.7017940 [133] -0.7017447 -0.7016952 -0.7016456 -0.7015958 -0.7015458 -0.7014957 [139] -0.7014455 -0.7013951 -0.7013445 -0.7012938 -0.7012429 -0.7011919 [145] -0.7011408 -0.7010895 -0.7010380 -0.7009864 -0.7009346 -0.7008827 [151] -0.7008306 -0.7007784 -0.7007260 -0.7006735 -0.7006208 -0.7005680 [157] -0.7005150 -0.7004619 -0.7004086 -0.7003552 -0.7003016 -0.7002479 [163] -0.7001940 -0.7001400 -0.7000859 -0.7000315 -0.6999771 -0.6999224 [169] -0.6998677 -0.6998128 -0.6997577 -0.6997025 -0.6996471 -0.6995916 [175] -0.6995360 -0.6994802 -0.6994242 -0.6993681 -0.6993119 -0.6992555 [181] -0.6991990 -0.6991423 -0.6990855 -0.6990285 -0.6989714 -0.6989141 [187] -0.6988567 -0.6987991 -0.6987414 -0.6986836 -0.6986256 -0.6985674 [193] -0.6985091 -0.6984507 -0.6983921 -0.6983334 -0.6982745 -0.6982155 [199] -0.6981564 -0.6980971 -0.6980376 -0.6979781 -0.6979183 -0.6978584 [205] -0.6977984 -0.6977383 -0.6976780 -0.6976175 -0.6975569 -0.6974962 [211] -0.6974353 -0.6973743 -0.6973132 -0.6972519 -0.6971904 -0.6971288 [217] -0.6970671 -0.6970052 -0.6969432 -0.6968811 -0.6968188 -0.6967563 [223] -0.6966938 -0.6966311 -0.6965682 -0.6965052 -0.6964421 -0.6963788 [229] -0.6963154 -0.6962518 -0.6961881 -0.6961243 -0.6960603 -0.6959962 [235] -0.6959320 -0.6958676 -0.6958031 -0.6957384 -0.6956736 -0.6956086 [241] -0.6955436 -0.6954783 -0.6954130 -0.6953475 -0.6952818 -0.6952161 [247] -0.6951502 -0.6950841 -0.6950179 -0.6949516 -0.6948852 -0.6948186 [253] -0.6947519 -0.6946850 -0.6946180 -0.6945509 -0.6944836 -0.6944162 [259] -0.6943486 -0.6942810 -0.6942131 -0.6941452 -0.6940771 -0.6940089 [265] -0.6939405 -0.6938721 -0.6938034 -0.6937347 -0.6936658 -0.6935968 [271] -0.6935276 -0.6934583 -0.6933889 -0.6933193 -0.6932497 -0.6931798 [277] -0.6931099 -0.6930398 -0.6929696 -0.6928992 -0.6928287 -0.6927581 [283] -0.6926874 -0.6926165 -0.6925455 -0.6924743 -0.6924031 -0.6923317 [289] -0.6922601 -0.6921885 -0.6921167 -0.6920447 -0.6919727 -0.6919005 [295] -0.6918282 -0.6917557 -0.6916832 -0.6916105 -0.6915376 -0.6914647 [301] -0.6913916 -0.6913183 -0.6912450 -0.6911715 -0.6910979 -0.6910242 [307] -0.6909503 -0.6908763 -0.6908022 -0.6907279 -0.6906536 -0.6905790 [313] -0.6905044 -0.6904297 -0.6903548 -0.6902798 -0.6902046 -0.6901294 [319] -0.6900540 -0.6899785 -0.6899028 -0.6898270 -0.6897511 -0.6896751 [325] -0.6895990 -0.6895227 -0.6894463 -0.6893698 -0.6892931 -0.6892164 [331] -0.6891395 -0.6890625 -0.6889853 -0.6889081 -0.6888307 -0.6887532 [337] -0.6886755 -0.6885978 -0.6885199 -0.6884419 -0.6883637 -0.6882855 [343] -0.6882071 -0.6881286 -0.6880500 -0.6879712 -0.6878924 -0.6878134 [349] -0.6877343 -0.6876550 -0.6875757 -0.6874962 -0.6874166 -0.6873369 [355] -0.6872571 -0.6871771 -0.6870971 -0.6870169 -0.6869365 -0.6868561 [361] -0.6867755 -0.6866949 -0.6866141 -0.6865332 -0.6864521 -0.6863710 [367] -0.6862897 -0.6862083 -0.6861268 -0.6860452 -0.6859634 -0.6858816 [373] -0.6857996 -0.6857175 -0.6856353 -0.6855529 -0.6854705 -0.6853879 [379] -0.6853052 -0.6852224 -0.6851395 -0.6850565 -0.6849733 -0.6848900 [385] -0.6848067 -0.6847232 -0.6846395 -0.6845558 -0.6844720 -0.6843880 [391] -0.6843039 -0.6842197 -0.6841354 -0.6840510 -0.6839665 -0.6838818 [397] -0.6837970 -0.6837122 -0.6836272 -0.6835421 -0.6834568 > mx [1] 0 > mxli [1] -999 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1hx2y1229445607.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/2h9a31229445607.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/3wtpd1229445607.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/44uah1229445607.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/56ksc1229445607.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/6ju1q1229445607.tab") > > system("convert tmp/1hx2y1229445607.ps tmp/1hx2y1229445607.png") > system("convert tmp/2h9a31229445607.ps tmp/2h9a31229445607.png") > system("convert tmp/3wtpd1229445607.ps tmp/3wtpd1229445607.png") > system("convert tmp/44uah1229445607.ps tmp/44uah1229445607.png") > system("convert tmp/56ksc1229445607.ps tmp/56ksc1229445607.png") > > > proc.time() user system elapsed 1.090 0.787 1.824