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(9.4,9.5,9.1,9,9.3,9.9,9.8,9.4,8.3,8,8.5,10.4,11.1,10.9,9.9,9.2,9.2,9.5,9.6,9.5,9.1,8.9,9,10.1,10.3,10.2,9.6,9.2,9.3,9.4,9.4,9.2,9,9,9,9.8,10,9.9,9.3,9,9,9.1,9.1,9.1,9.2,8.8,8.3,8.4,8.1,7.8,7.9,7.9,8,7.9,7.5,7.2,6.9,6.6,6.7,7.3) > #'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.6838636 -0.6838393 -0.6838146 -0.6837894 -0.6837637 -0.6837377 [7] -0.6837111 -0.6836841 -0.6836567 -0.6836288 -0.6836004 -0.6835716 [13] -0.6835423 -0.6835126 -0.6834824 -0.6834518 -0.6834207 -0.6833892 [19] -0.6833572 -0.6833247 -0.6832918 -0.6832585 -0.6832246 -0.6831904 [25] -0.6831556 -0.6831204 -0.6830848 -0.6830487 -0.6830121 -0.6829751 [31] -0.6829376 -0.6828996 -0.6828612 -0.6828224 -0.6827831 -0.6827433 [37] -0.6827030 -0.6826623 -0.6826212 -0.6825795 -0.6825375 -0.6824949 [43] -0.6824519 -0.6824084 -0.6823645 -0.6823201 -0.6822753 -0.6822300 [49] -0.6821842 -0.6821379 -0.6820912 -0.6820441 -0.6819965 -0.6819484 [55] -0.6818998 -0.6818508 -0.6818013 -0.6817514 -0.6817010 -0.6816501 [61] -0.6815988 -0.6815470 -0.6814947 -0.6814420 -0.6813888 -0.6813351 [67] -0.6812810 -0.6812264 -0.6811714 -0.6811159 -0.6810599 -0.6810034 [73] -0.6809465 -0.6808892 -0.6808313 -0.6807730 -0.6807142 -0.6806550 [79] -0.6805953 -0.6805351 -0.6804745 -0.6804134 -0.6803518 -0.6802898 [85] -0.6802273 -0.6801643 -0.6801009 -0.6800369 -0.6799726 -0.6799077 [91] -0.6798424 -0.6797767 -0.6797104 -0.6796437 -0.6795765 -0.6795089 [97] -0.6794408 -0.6793722 -0.6793032 -0.6792336 -0.6791637 -0.6790932 [103] -0.6790223 -0.6789509 -0.6788791 -0.6788067 -0.6787339 -0.6786607 [109] -0.6785870 -0.6785128 -0.6784381 -0.6783630 -0.6782874 -0.6782113 [115] -0.6781348 -0.6780578 -0.6779803 -0.6779024 -0.6778240 -0.6777451 [121] -0.6776658 -0.6775859 -0.6775057 -0.6774249 -0.6773437 -0.6772620 [127] -0.6771799 -0.6770973 -0.6770142 -0.6769306 -0.6768466 -0.6767621 [133] -0.6766771 -0.6765917 -0.6765058 -0.6764195 -0.6763326 -0.6762453 [139] -0.6761576 -0.6760693 -0.6759806 -0.6758915 -0.6758018 -0.6757117 [145] -0.6756212 -0.6755301 -0.6754386 -0.6753466 -0.6752542 -0.6751613 [151] -0.6750679 -0.6749741 -0.6748798 -0.6747850 -0.6746898 -0.6745941 [157] -0.6744979 -0.6744012 -0.6743041 -0.6742066 -0.6741085 -0.6740100 [163] -0.6739111 -0.6738116 -0.6737117 -0.6736113 -0.6735105 -0.6734092 [169] -0.6733075 -0.6732052 -0.6731025 -0.6729994 -0.6728958 -0.6727917 [175] -0.6726871 -0.6725821 -0.6724766 -0.6723707 -0.6722643 -0.6721574 [181] -0.6720501 -0.6719423 -0.6718340 -0.6717253 -0.6716161 -0.6715065 [187] -0.6713963 -0.6712858 -0.6711747 -0.6710632 -0.6709513 -0.6708389 [193] -0.6707260 -0.6706126 -0.6704988 -0.6703846 -0.6702698 -0.6701546 [199] -0.6700390 -0.6699229 -0.6698063 -0.6696893 -0.6695718 -0.6694539 [205] -0.6693354 -0.6692166 -0.6690973 -0.6689775 -0.6688572 -0.6687365 [211] -0.6686154 -0.6684938 -0.6683717 -0.6682492 -0.6681262 -0.6680027 [217] -0.6678788 -0.6677545 -0.6676297 -0.6675044 -0.6673787 -0.6672525 [223] -0.6671259 -0.6669988 -0.6668712 -0.6667433 -0.6666148 -0.6664859 [229] -0.6663565 -0.6662267 -0.6660965 -0.6659658 -0.6658346 -0.6657030 [235] -0.6655709 -0.6654384 -0.6653054 -0.6651720 -0.6650381 -0.6649038 [241] -0.6647690 -0.6646338 -0.6644981 -0.6643620 -0.6642254 -0.6640884 [247] -0.6639509 -0.6638130 -0.6636747 -0.6635358 -0.6633966 -0.6632569 [253] -0.6631167 -0.6629761 -0.6628351 -0.6626936 -0.6625517 -0.6624093 [259] -0.6622665 -0.6621232 -0.6619795 -0.6618354 -0.6616908 -0.6615457 [265] -0.6614003 -0.6612543 -0.6611080 -0.6609612 -0.6608139 -0.6606663 [271] -0.6605181 -0.6603696 -0.6602206 -0.6600711 -0.6599213 -0.6597709 [277] -0.6596202 -0.6594690 -0.6593174 -0.6591653 -0.6590128 -0.6588599 [283] -0.6587065 -0.6585527 -0.6583984 -0.6582438 -0.6580887 -0.6579331 [289] -0.6577771 -0.6576207 -0.6574639 -0.6573066 -0.6571489 -0.6569908 [295] -0.6568322 -0.6566732 -0.6565138 -0.6563540 -0.6561937 -0.6560330 [301] -0.6558718 -0.6557103 -0.6555483 -0.6553859 -0.6552230 -0.6550597 [307] -0.6548961 -0.6547319 -0.6545674 -0.6544024 -0.6542370 -0.6540712 [313] -0.6539050 -0.6537383 -0.6535713 -0.6534038 -0.6532358 -0.6530675 [319] -0.6528987 -0.6527296 -0.6525600 -0.6523899 -0.6522195 -0.6520487 [325] -0.6518774 -0.6517057 -0.6515336 -0.6513611 -0.6511882 -0.6510148 [331] -0.6508411 -0.6506669 -0.6504923 -0.6503173 -0.6501419 -0.6499661 [337] -0.6497899 -0.6496132 -0.6494362 -0.6492587 -0.6490809 -0.6489026 [343] -0.6487239 -0.6485448 -0.6483653 -0.6481854 -0.6480051 -0.6478244 [349] -0.6476433 -0.6474618 -0.6472799 -0.6470975 -0.6469148 -0.6467317 [355] -0.6465482 -0.6463642 -0.6461799 -0.6459952 -0.6458101 -0.6456245 [361] -0.6454386 -0.6452523 -0.6450656 -0.6448785 -0.6446910 -0.6445031 [367] -0.6443148 -0.6441261 -0.6439370 -0.6437475 -0.6435576 -0.6433674 [373] -0.6431767 -0.6429857 -0.6427943 -0.6426024 -0.6424102 -0.6422176 [379] -0.6420247 -0.6418313 -0.6416375 -0.6414434 -0.6412489 -0.6410540 [385] -0.6408587 -0.6406630 -0.6404669 -0.6402705 -0.6400737 -0.6398765 [391] -0.6396789 -0.6394809 -0.6392826 -0.6390839 -0.6388848 -0.6386853 [397] -0.6384854 -0.6382852 -0.6380846 -0.6378836 -0.6376823 > 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/19n081229445816.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/2o7xn1229445816.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/3d72z1229445816.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/4pjyf1229445816.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/5m4t91229445816.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/6k5e11229445816.tab") > > system("convert tmp/19n081229445816.ps tmp/19n081229445816.png") > system("convert tmp/2o7xn1229445816.ps tmp/2o7xn1229445816.png") > system("convert tmp/3d72z1229445816.ps tmp/3d72z1229445816.png") > system("convert tmp/4pjyf1229445816.ps tmp/4pjyf1229445816.png") > system("convert tmp/5m4t91229445816.ps tmp/5m4t91229445816.png") > > > proc.time() user system elapsed 1.078 0.774 1.275