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(8.3,8.4,8.4,8.4,8.6,8.9,8.8,8.3,7.5,7.2,7.5,8.8,9.3,9.3,8.7,8.2,8.3,8.5,8.6,8.6,8.2,8.1,8,8.6,8.7,8.8,8.5,8.4,8.5,8.7,8.7,8.6,8.5,8.3,8.1,8.2,8.1,8.1,7.9,7.9,7.9,8,8,7.9,8,7.7,7.2,7.5,7.3,7,7,7,7.2,7.3,7.1,6.8,6.6,6.2,6.2,6.8) > #'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.7265796 -0.7265987 -0.7266175 -0.7266361 -0.7266544 -0.7266725 [7] -0.7266902 -0.7267077 -0.7267250 -0.7267420 -0.7267587 -0.7267751 [13] -0.7267913 -0.7268072 -0.7268229 -0.7268382 -0.7268534 -0.7268682 [19] -0.7268828 -0.7268971 -0.7269112 -0.7269249 -0.7269385 -0.7269517 [25] -0.7269647 -0.7269774 -0.7269899 -0.7270021 -0.7270140 -0.7270257 [31] -0.7270371 -0.7270482 -0.7270591 -0.7270697 -0.7270800 -0.7270901 [37] -0.7270999 -0.7271094 -0.7271187 -0.7271277 -0.7271365 -0.7271449 [43] -0.7271532 -0.7271611 -0.7271688 -0.7271762 -0.7271834 -0.7271903 [49] -0.7271969 -0.7272033 -0.7272094 -0.7272152 -0.7272208 -0.7272261 [55] -0.7272312 -0.7272359 -0.7272405 -0.7272447 -0.7272487 -0.7272524 [61] -0.7272559 -0.7272591 -0.7272620 -0.7272647 -0.7272671 -0.7272693 [67] -0.7272712 -0.7272728 -0.7272742 -0.7272752 -0.7272761 -0.7272767 [73] -0.7272770 -0.7272770 -0.7272768 -0.7272763 -0.7272756 -0.7272746 [79] -0.7272733 -0.7272718 -0.7272700 -0.7272680 -0.7272656 -0.7272631 [85] -0.7272602 -0.7272571 -0.7272538 -0.7272502 -0.7272463 -0.7272421 [91] -0.7272377 -0.7272331 -0.7272281 -0.7272230 -0.7272175 -0.7272118 [97] -0.7272058 -0.7271996 -0.7271931 -0.7271864 -0.7271794 -0.7271721 [103] -0.7271646 -0.7271568 -0.7271487 -0.7271404 -0.7271319 -0.7271230 [109] -0.7271140 -0.7271046 -0.7270950 -0.7270851 -0.7270750 -0.7270646 [115] -0.7270540 -0.7270431 -0.7270319 -0.7270205 -0.7270089 -0.7269969 [121] -0.7269847 -0.7269723 -0.7269596 -0.7269466 -0.7269334 -0.7269199 [127] -0.7269062 -0.7268922 -0.7268779 -0.7268634 -0.7268487 -0.7268336 [133] -0.7268184 -0.7268028 -0.7267870 -0.7267710 -0.7267547 -0.7267381 [139] -0.7267213 -0.7267042 -0.7266869 -0.7266693 -0.7266515 -0.7266334 [145] -0.7266150 -0.7265964 -0.7265776 -0.7265584 -0.7265391 -0.7265194 [151] -0.7264996 -0.7264794 -0.7264590 -0.7264384 -0.7264175 -0.7263963 [157] -0.7263749 -0.7263533 -0.7263313 -0.7263092 -0.7262868 -0.7262641 [163] -0.7262412 -0.7262180 -0.7261945 -0.7261709 -0.7261469 -0.7261227 [169] -0.7260983 -0.7260736 -0.7260486 -0.7260234 -0.7259980 -0.7259723 [175] -0.7259463 -0.7259201 -0.7258936 -0.7258669 -0.7258400 -0.7258128 [181] -0.7257853 -0.7257576 -0.7257296 -0.7257014 -0.7256729 -0.7256442 [187] -0.7256153 -0.7255860 -0.7255566 -0.7255269 -0.7254969 -0.7254667 [193] -0.7254362 -0.7254055 -0.7253745 -0.7253433 -0.7253119 -0.7252802 [199] -0.7252482 -0.7252160 -0.7251836 -0.7251509 -0.7251179 -0.7250847 [205] -0.7250513 -0.7250176 -0.7249837 -0.7249495 -0.7249150 -0.7248804 [211] -0.7248454 -0.7248103 -0.7247749 -0.7247392 -0.7247033 -0.7246671 [217] -0.7246307 -0.7245941 -0.7245572 -0.7245201 -0.7244827 -0.7244451 [223] -0.7244072 -0.7243691 -0.7243307 -0.7242921 -0.7242533 -0.7242142 [229] -0.7241748 -0.7241353 -0.7240954 -0.7240554 -0.7240151 -0.7239745 [235] -0.7239337 -0.7238927 -0.7238514 -0.7238099 -0.7237681 -0.7237261 [241] -0.7236839 -0.7236414 -0.7235986 -0.7235557 -0.7235124 -0.7234690 [247] -0.7234253 -0.7233814 -0.7233372 -0.7232928 -0.7232481 -0.7232032 [253] -0.7231581 -0.7231127 -0.7230671 -0.7230212 -0.7229751 -0.7229288 [259] -0.7228822 -0.7228354 -0.7227883 -0.7227410 -0.7226935 -0.7226457 [265] -0.7225977 -0.7225495 -0.7225010 -0.7224523 -0.7224033 -0.7223541 [271] -0.7223047 -0.7222550 -0.7222051 -0.7221550 -0.7221046 -0.7220540 [277] -0.7220031 -0.7219520 -0.7219007 -0.7218492 -0.7217974 -0.7217453 [283] -0.7216931 -0.7216406 -0.7215878 -0.7215349 -0.7214817 -0.7214282 [289] -0.7213746 -0.7213207 -0.7212665 -0.7212122 -0.7211576 -0.7211027 [295] -0.7210477 -0.7209923 -0.7209368 -0.7208810 -0.7208250 -0.7207688 [301] -0.7207124 -0.7206557 -0.7205987 -0.7205416 -0.7204842 -0.7204266 [307] -0.7203687 -0.7203106 -0.7202523 -0.7201938 -0.7201350 -0.7200760 [313] -0.7200168 -0.7199573 -0.7198976 -0.7198377 -0.7197776 -0.7197172 [319] -0.7196566 -0.7195957 -0.7195347 -0.7194734 -0.7194119 -0.7193501 [325] -0.7192882 -0.7192260 -0.7191635 -0.7191009 -0.7190380 -0.7189749 [331] -0.7189116 -0.7188480 -0.7187842 -0.7187202 -0.7186560 -0.7185915 [337] -0.7185268 -0.7184619 -0.7183967 -0.7183314 -0.7182658 -0.7182000 [343] -0.7181339 -0.7180677 -0.7180012 -0.7179345 -0.7178676 -0.7178004 [349] -0.7177330 -0.7176654 -0.7175976 -0.7175296 -0.7174613 -0.7173928 [355] -0.7173241 -0.7172551 -0.7171860 -0.7171166 -0.7170470 -0.7169772 [361] -0.7169072 -0.7168369 -0.7167664 -0.7166957 -0.7166248 -0.7165536 [367] -0.7164823 -0.7164107 -0.7163389 -0.7162669 -0.7161946 -0.7161222 [373] -0.7160495 -0.7159766 -0.7159035 -0.7158302 -0.7157566 -0.7156829 [379] -0.7156089 -0.7155347 -0.7154603 -0.7153856 -0.7153108 -0.7152357 [385] -0.7151604 -0.7150849 -0.7150092 -0.7149333 -0.7148571 -0.7147808 [391] -0.7147042 -0.7146274 -0.7145504 -0.7144732 -0.7143958 -0.7143181 [397] -0.7142403 -0.7141622 -0.7140839 -0.7140054 -0.7139267 > mx [1] 0 > mxli [1] -999 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/freestat/rcomp/tmp/1k5su1229445945.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/freestat/rcomp/tmp/24b4p1229445945.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/freestat/rcomp/tmp/3u0uy1229445945.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/freestat/rcomp/tmp/4355x1229445945.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/freestat/rcomp/tmp/5wj6o1229445945.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/6favk1229445945.tab") > > system("convert tmp/1k5su1229445945.ps tmp/1k5su1229445945.png") > system("convert tmp/24b4p1229445945.ps tmp/24b4p1229445945.png") > system("convert tmp/3u0uy1229445945.ps tmp/3u0uy1229445945.png") > system("convert tmp/4355x1229445945.ps tmp/4355x1229445945.png") > system("convert tmp/5wj6o1229445945.ps tmp/5wj6o1229445945.png") > > > proc.time() user system elapsed 1.829 1.389 2.244