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(105.1,113.3,99.1,100.3,93.5,98.8,106.2,98.3,102.1,117.1,101.5,80.5,105.9,109.5,97.2,114.5,93.5,100.9,121.1,116.5,109.3,118.1,108.3,105.4,116.2,111.2,105.8,122.7,99.5,107.9,124.6,115,110.3,132.7,99.7,96.5,118.7,112.9,130.5,137.9,115,116.8,140.9,120.7,134.2,147.3,112.4,107.1,128.4,137.7,135,151,137.4,132.4,161.3,139.8,146,154.6,142.1,120.5) > #'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.6835708 0.6838226 0.6840736 0.6843236 0.6845728 0.6848212 0.6850686 [8] 0.6853152 0.6855610 0.6858058 0.6860498 0.6862930 0.6865353 0.6867767 [15] 0.6870172 0.6872569 0.6874957 0.6877336 0.6879707 0.6882069 0.6884423 [22] 0.6886767 0.6889104 0.6891431 0.6893750 0.6896060 0.6898362 0.6900654 [29] 0.6902939 0.6905214 0.6907481 0.6909739 0.6911989 0.6914230 0.6916462 [36] 0.6918686 0.6920901 0.6923107 0.6925305 0.6927494 0.6929675 0.6931847 [43] 0.6934010 0.6936164 0.6938310 0.6940448 0.6942576 0.6944696 0.6946808 [50] 0.6948911 0.6951005 0.6953090 0.6955167 0.6957236 0.6959295 0.6961347 [57] 0.6963389 0.6965423 0.6967448 0.6969465 0.6971473 0.6973473 0.6975464 [64] 0.6977446 0.6979420 0.6981385 0.6983342 0.6985290 0.6987229 0.6989160 [71] 0.6991083 0.6992997 0.6994902 0.6996799 0.6998687 0.7000566 0.7002438 [78] 0.7004300 0.7006154 0.7008000 0.7009837 0.7011665 0.7013485 0.7015296 [85] 0.7017099 0.7018894 0.7020680 0.7022457 0.7024226 0.7025986 0.7027738 [92] 0.7029482 0.7031217 0.7032943 0.7034661 0.7036371 0.7038072 0.7039765 [99] 0.7041449 0.7043125 0.7044792 0.7046451 0.7048101 0.7049743 0.7051377 [106] 0.7053002 0.7054619 0.7056228 0.7057828 0.7059419 0.7061003 0.7062577 [113] 0.7064144 0.7065702 0.7067252 0.7068793 0.7070326 0.7071851 0.7073367 [120] 0.7074875 0.7076375 0.7077866 0.7079350 0.7080824 0.7082291 0.7083749 [127] 0.7085199 0.7086640 0.7088073 0.7089498 0.7090915 0.7092324 0.7093724 [134] 0.7095116 0.7096499 0.7097875 0.7099242 0.7100601 0.7101952 0.7103294 [141] 0.7104629 0.7105955 0.7107273 0.7108582 0.7109884 0.7111177 0.7112463 [148] 0.7113740 0.7115009 0.7116269 0.7117522 0.7118766 0.7120003 0.7121231 [155] 0.7122451 0.7123663 0.7124867 0.7126063 0.7127250 0.7128430 0.7129602 [162] 0.7130765 0.7131921 0.7133068 0.7134207 0.7135339 0.7136462 0.7137577 [169] 0.7138684 0.7139784 0.7140875 0.7141958 0.7143033 0.7144101 0.7145160 [176] 0.7146211 0.7147255 0.7148290 0.7149318 0.7150337 0.7151349 0.7152353 [183] 0.7153348 0.7154336 0.7155316 0.7156289 0.7157253 0.7158209 0.7159158 [190] 0.7160098 0.7161031 0.7161956 0.7162873 0.7163783 0.7164684 0.7165578 [197] 0.7166464 0.7167342 0.7168212 0.7169075 0.7169930 0.7170777 0.7171616 [204] 0.7172448 0.7173271 0.7174088 0.7174896 0.7175697 0.7176490 0.7177275 [211] 0.7178053 0.7178822 0.7179585 0.7180339 0.7181086 0.7181826 0.7182557 [218] 0.7183281 0.7183998 0.7184707 0.7185408 0.7186102 0.7186788 0.7187466 [225] 0.7188137 0.7188800 0.7189456 0.7190104 0.7190745 0.7191378 0.7192004 [232] 0.7192622 0.7193233 0.7193836 0.7194432 0.7195020 0.7195601 0.7196175 [239] 0.7196741 0.7197299 0.7197850 0.7198394 0.7198930 0.7199459 0.7199981 [246] 0.7200495 0.7201001 0.7201501 0.7201993 0.7202478 0.7202955 0.7203425 [253] 0.7203888 0.7204343 0.7204791 0.7205232 0.7205666 0.7206092 0.7206511 [260] 0.7206923 0.7207327 0.7207724 0.7208114 0.7208497 0.7208873 0.7209241 [267] 0.7209603 0.7209957 0.7210304 0.7210643 0.7210976 0.7211301 0.7211620 [274] 0.7211931 0.7212235 0.7212532 0.7212822 0.7213105 0.7213380 0.7213649 [281] 0.7213911 0.7214165 0.7214413 0.7214653 0.7214887 0.7215113 0.7215332 [288] 0.7215545 0.7215750 0.7215949 0.7216140 0.7216325 0.7216503 0.7216673 [295] 0.7216837 0.7216994 0.7217144 0.7217287 0.7217423 0.7217553 0.7217675 [302] 0.7217791 0.7217899 0.7218001 0.7218096 0.7218185 0.7218266 0.7218341 [309] 0.7218409 0.7218470 0.7218524 0.7218571 0.7218612 0.7218646 0.7218674 [316] 0.7218694 0.7218708 0.7218715 0.7218716 0.7218709 0.7218697 0.7218677 [323] 0.7218651 0.7218618 0.7218578 0.7218532 0.7218480 0.7218420 0.7218354 [330] 0.7218282 0.7218203 0.7218117 0.7218025 0.7217926 0.7217821 0.7217709 [337] 0.7217590 0.7217466 0.7217334 0.7217196 0.7217052 0.7216901 0.7216744 [344] 0.7216580 0.7216410 0.7216233 0.7216050 0.7215861 0.7215665 0.7215463 [351] 0.7215254 0.7215039 0.7214818 0.7214590 0.7214356 0.7214116 0.7213869 [358] 0.7213616 0.7213357 0.7213091 0.7212819 0.7212541 0.7212257 0.7211966 [365] 0.7211669 0.7211366 0.7211057 0.7210741 0.7210419 0.7210091 0.7209757 [372] 0.7209417 0.7209070 0.7208718 0.7208359 0.7207994 0.7207623 0.7207245 [379] 0.7206862 0.7206473 0.7206077 0.7205676 0.7205268 0.7204854 0.7204435 [386] 0.7204009 0.7203577 0.7203139 0.7202695 0.7202246 0.7201790 0.7201328 [393] 0.7200860 0.7200386 0.7199907 0.7199421 0.7198930 0.7198432 0.7197929 [400] 0.7197420 0.7196904 > mx [1] 0.7218716 > mxli [1] 1.18 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1u6so1196102634.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/21aam1196102634.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/39c981196102634.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/40mih1196102634.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/5xe7c1196102634.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/6asfc1196102634.tab") > > system("convert tmp/1u6so1196102634.ps tmp/1u6so1196102634.png") > system("convert tmp/21aam1196102634.ps tmp/21aam1196102634.png") > system("convert tmp/39c981196102634.ps tmp/39c981196102634.png") > system("convert tmp/40mih1196102634.ps tmp/40mih1196102634.png") > system("convert tmp/5xe7c1196102634.ps tmp/5xe7c1196102634.png") > > > proc.time() user system elapsed 1.333 0.795 1.526