R version 2.6.0 (2007-10-03) Copyright (C) 2007 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(99,115.4,106.9,107.1,99.3,99.2,108.3,105.6,99.5,107.4,93.1,88.1,110.7,113.1,99.6,93.6,98.6,99.6,114.3,107.8,101.2,112.5,100.5,93.9,116.2,112,106.4,95.7,96,95.8,103,102.2,98.4,111.4,86.6,91.3,107.9,101.8,104.4,93.4,100.1,98.5,112.9,101.4,107.1,110.8,90.3,95.5,111.4,113,107.5,95.9,106.3,105.2,117.2,106.9,108.2,110,96.1,100.6) > #'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.03044216 0.03044697 0.03045177 0.03045657 0.03046135 0.03046612 [7] 0.03047088 0.03047563 0.03048037 0.03048510 0.03048982 0.03049453 [13] 0.03049923 0.03050391 0.03050859 0.03051326 0.03051792 0.03052257 [19] 0.03052720 0.03053183 0.03053645 0.03054105 0.03054565 0.03055024 [25] 0.03055481 0.03055937 0.03056393 0.03056847 0.03057301 0.03057753 [31] 0.03058204 0.03058654 0.03059104 0.03059552 0.03059999 0.03060445 [37] 0.03060890 0.03061334 0.03061777 0.03062219 0.03062659 0.03063099 [43] 0.03063538 0.03063975 0.03064412 0.03064847 0.03065282 0.03065715 [49] 0.03066148 0.03066579 0.03067009 0.03067438 0.03067866 0.03068293 [55] 0.03068719 0.03069144 0.03069568 0.03069991 0.03070413 0.03070833 [61] 0.03071253 0.03071671 0.03072089 0.03072505 0.03072921 0.03073335 [67] 0.03073748 0.03074160 0.03074571 0.03074981 0.03075390 0.03075798 [73] 0.03076204 0.03076610 0.03077014 0.03077418 0.03077820 0.03078221 [79] 0.03078622 0.03079021 0.03079419 0.03079816 0.03080212 0.03080606 [85] 0.03081000 0.03081393 0.03081784 0.03082175 0.03082564 0.03082952 [91] 0.03083340 0.03083726 0.03084111 0.03084494 0.03084877 0.03085259 [97] 0.03085640 0.03086019 0.03086397 0.03086775 0.03087151 0.03087526 [103] 0.03087900 0.03088273 0.03088645 0.03089016 0.03089385 0.03089754 [109] 0.03090121 0.03090487 0.03090852 0.03091217 0.03091580 0.03091941 [115] 0.03092302 0.03092662 0.03093020 0.03093378 0.03093734 0.03094089 [121] 0.03094443 0.03094796 0.03095148 0.03095499 0.03095849 0.03096197 [127] 0.03096545 0.03096891 0.03097236 0.03097580 0.03097923 0.03098265 [133] 0.03098606 0.03098945 0.03099284 0.03099621 0.03099957 0.03100292 [139] 0.03100626 0.03100959 0.03101291 0.03101621 0.03101951 0.03102279 [145] 0.03102607 0.03102933 0.03103258 0.03103581 0.03103904 0.03104226 [151] 0.03104546 0.03104865 0.03105184 0.03105501 0.03105817 0.03106131 [157] 0.03106445 0.03106758 0.03107069 0.03107379 0.03107688 0.03107996 [163] 0.03108303 0.03108609 0.03108914 0.03109217 0.03109519 0.03109820 [169] 0.03110120 0.03110419 0.03110717 0.03111014 0.03111309 0.03111603 [175] 0.03111897 0.03112189 0.03112479 0.03112769 0.03113058 0.03113345 [181] 0.03113632 0.03113917 0.03114201 0.03114484 0.03114765 0.03115046 [187] 0.03115325 0.03115604 0.03115881 0.03116157 0.03116432 0.03116705 [193] 0.03116978 0.03117249 0.03117519 0.03117788 0.03118056 0.03118323 [199] 0.03118589 0.03118853 0.03119116 0.03119378 0.03119639 0.03119899 [205] 0.03120158 0.03120415 0.03120672 0.03120927 0.03121181 0.03121434 [211] 0.03121686 0.03121936 0.03122186 0.03122434 0.03122681 0.03122927 [217] 0.03123172 0.03123415 0.03123658 0.03123899 0.03124139 0.03124378 [223] 0.03124616 0.03124853 0.03125088 0.03125322 0.03125555 0.03125787 [229] 0.03126018 0.03126248 0.03126476 0.03126704 0.03126930 0.03127155 [235] 0.03127378 0.03127601 0.03127823 0.03128043 0.03128262 0.03128480 [241] 0.03128697 0.03128912 0.03129127 0.03129340 0.03129552 0.03129763 [247] 0.03129973 0.03130182 0.03130389 0.03130595 0.03130800 0.03131004 [253] 0.03131207 0.03131409 0.03131609 0.03131808 0.03132006 0.03132203 [259] 0.03132399 0.03132593 0.03132787 0.03132979 0.03133170 0.03133360 [265] 0.03133548 0.03133736 0.03133922 0.03134107 0.03134291 0.03134474 [271] 0.03134655 0.03134836 0.03135015 0.03135193 0.03135370 0.03135546 [277] 0.03135720 0.03135893 0.03136066 0.03136237 0.03136406 0.03136575 [283] 0.03136742 0.03136909 0.03137074 0.03137238 0.03137400 0.03137562 [289] 0.03137722 0.03137881 0.03138039 0.03138196 0.03138352 0.03138506 [295] 0.03138660 0.03138812 0.03138963 0.03139112 0.03139261 0.03139408 [301] 0.03139554 0.03139699 0.03139843 0.03139986 0.03140127 0.03140267 [307] 0.03140406 0.03140544 0.03140681 0.03140817 0.03140951 0.03141084 [313] 0.03141216 0.03141347 0.03141476 0.03141605 0.03141732 0.03141858 [319] 0.03141983 0.03142107 0.03142229 0.03142350 0.03142470 0.03142589 [325] 0.03142707 0.03142824 0.03142939 0.03143053 0.03143166 0.03143278 [331] 0.03143389 0.03143498 0.03143606 0.03143713 0.03143819 0.03143924 [337] 0.03144027 0.03144130 0.03144231 0.03144331 0.03144430 0.03144527 [343] 0.03144624 0.03144719 0.03144813 0.03144906 0.03144997 0.03145088 [349] 0.03145177 0.03145265 0.03145352 0.03145438 0.03145522 0.03145606 [355] 0.03145688 0.03145769 0.03145848 0.03145927 0.03146004 0.03146081 [361] 0.03146156 0.03146229 0.03146302 0.03146374 0.03146444 0.03146513 [367] 0.03146581 0.03146648 0.03146713 0.03146777 0.03146841 0.03146903 [373] 0.03146963 0.03147023 0.03147081 0.03147139 0.03147195 0.03147250 [379] 0.03147303 0.03147356 0.03147407 0.03147457 0.03147506 0.03147554 [385] 0.03147600 0.03147646 0.03147690 0.03147733 0.03147775 0.03147815 [391] 0.03147855 0.03147893 0.03147930 0.03147966 0.03148001 0.03148034 [397] 0.03148067 0.03148098 0.03148128 0.03148157 0.03148184 > mx [1] 0.03148184 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/13g0o1198011513.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/2s1ju1198011513.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/3sq7s1198011513.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/4vf2t1198011513.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/5cykp1198011513.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x1) > grid() > mtext('Transformed Data') > dev.off() null device 1 > 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/6wzpp1198011513.tab") > > system("convert tmp/13g0o1198011513.ps tmp/13g0o1198011513.png") > system("convert tmp/2s1ju1198011513.ps tmp/2s1ju1198011513.png") > system("convert tmp/3sq7s1198011513.ps tmp/3sq7s1198011513.png") > system("convert tmp/4vf2t1198011513.ps tmp/4vf2t1198011513.png") > system("convert tmp/5cykp1198011513.ps tmp/5cykp1198011513.png") > > > proc.time() user system elapsed 1.325 0.776 1.497