R version 2.8.1 (2008-12-22) 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(22,22,20,21,20,21,21,21,19,21,21,22,19,24,22,22,22,24,22,23,24,21,20,22,23,23,22,20,21,21,20,20,17,18,19,19,20,21,20,21,19,22,20,18,16,17,18,19,18,20,21,18,19,19,19,21,19,19,17,16,16,17,16,15,16,16,16,18,19,16,16,16) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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.7221413 -0.7221469 -0.7221522 -0.7221572 -0.7221620 -0.7221664 [7] -0.7221705 -0.7221742 -0.7221777 -0.7221809 -0.7221837 -0.7221862 [13] -0.7221884 -0.7221904 -0.7221919 -0.7221932 -0.7221942 -0.7221948 [19] -0.7221952 -0.7221952 -0.7221949 -0.7221943 -0.7221933 -0.7221921 [25] -0.7221905 -0.7221887 -0.7221865 -0.7221839 -0.7221811 -0.7221780 [31] -0.7221745 -0.7221707 -0.7221666 -0.7221622 -0.7221574 -0.7221524 [37] -0.7221470 -0.7221413 -0.7221352 -0.7221289 -0.7221222 -0.7221152 [43] -0.7221079 -0.7221003 -0.7220923 -0.7220840 -0.7220754 -0.7220665 [49] -0.7220573 -0.7220477 -0.7220378 -0.7220276 -0.7220170 -0.7220061 [55] -0.7219949 -0.7219834 -0.7219715 -0.7219594 -0.7219469 -0.7219340 [61] -0.7219209 -0.7219074 -0.7218936 -0.7218794 -0.7218650 -0.7218502 [67] -0.7218350 -0.7218196 -0.7218038 -0.7217877 -0.7217712 -0.7217545 [73] -0.7217374 -0.7217199 -0.7217022 -0.7216841 -0.7216656 -0.7216469 [79] -0.7216278 -0.7216084 -0.7215886 -0.7215685 -0.7215481 -0.7215274 [85] -0.7215063 -0.7214849 -0.7214631 -0.7214410 -0.7214186 -0.7213959 [91] -0.7213728 -0.7213493 -0.7213256 -0.7213015 -0.7212771 -0.7212523 [97] -0.7212272 -0.7212018 -0.7211760 -0.7211499 -0.7211234 -0.7210967 [103] -0.7210695 -0.7210421 -0.7210143 -0.7209861 -0.7209577 -0.7209289 [109] -0.7208997 -0.7208702 -0.7208404 -0.7208102 -0.7207797 -0.7207489 [115] -0.7207177 -0.7206862 -0.7206543 -0.7206221 -0.7205896 -0.7205567 [121] -0.7205235 -0.7204899 -0.7204560 -0.7204217 -0.7203872 -0.7203522 [127] -0.7203169 -0.7202813 -0.7202454 -0.7202091 -0.7201724 -0.7201354 [133] -0.7200981 -0.7200604 -0.7200224 -0.7199841 -0.7199454 -0.7199063 [139] -0.7198669 -0.7198272 -0.7197871 -0.7197467 -0.7197059 -0.7196648 [145] -0.7196233 -0.7195815 -0.7195394 -0.7194969 -0.7194540 -0.7194108 [151] -0.7193673 -0.7193234 -0.7192792 -0.7192346 -0.7191897 -0.7191444 [157] -0.7190988 -0.7190529 -0.7190066 -0.7189599 -0.7189129 -0.7188656 [163] -0.7188179 -0.7187698 -0.7187214 -0.7186727 -0.7186236 -0.7185742 [169] -0.7185244 -0.7184742 -0.7184238 -0.7183729 -0.7183217 -0.7182702 [175] -0.7182183 -0.7181661 -0.7181135 -0.7180606 -0.7180073 -0.7179537 [181] -0.7178997 -0.7178454 -0.7177907 -0.7177357 -0.7176803 -0.7176246 [187] -0.7175685 -0.7175121 -0.7174553 -0.7173982 -0.7173407 -0.7172829 [193] -0.7172247 -0.7171662 -0.7171073 -0.7170481 -0.7169885 -0.7169285 [199] -0.7168682 -0.7168076 -0.7167466 -0.7166853 -0.7166236 -0.7165615 [205] -0.7164991 -0.7164364 -0.7163733 -0.7163098 -0.7162460 -0.7161819 [211] -0.7161174 -0.7160525 -0.7159873 -0.7159217 -0.7158558 -0.7157895 [217] -0.7157229 -0.7156559 -0.7155886 -0.7155209 -0.7154529 -0.7153845 [223] -0.7153158 -0.7152467 -0.7151772 -0.7151074 -0.7150373 -0.7149668 [229] -0.7148959 -0.7148247 -0.7147532 -0.7146813 -0.7146090 -0.7145364 [235] -0.7144634 -0.7143901 -0.7143164 -0.7142424 -0.7141680 -0.7140932 [241] -0.7140181 -0.7139427 -0.7138669 -0.7137908 -0.7137142 -0.7136374 [247] -0.7135602 -0.7134826 -0.7134047 -0.7133264 -0.7132478 -0.7131688 [253] -0.7130895 -0.7130098 -0.7129298 -0.7128494 -0.7127687 -0.7126876 [259] -0.7126061 -0.7125243 -0.7124422 -0.7123597 -0.7122768 -0.7121936 [265] -0.7121100 -0.7120261 -0.7119419 -0.7118572 -0.7117723 -0.7116869 [271] -0.7116013 -0.7115152 -0.7114288 -0.7113421 -0.7112550 -0.7111676 [277] -0.7110798 -0.7109916 -0.7109031 -0.7108143 -0.7107251 -0.7106355 [283] -0.7105456 -0.7104554 -0.7103648 -0.7102738 -0.7101825 -0.7100908 [289] -0.7099988 -0.7099065 -0.7098137 -0.7097207 -0.7096273 -0.7095335 [295] -0.7094394 -0.7093449 -0.7092501 -0.7091549 -0.7090594 -0.7089635 [301] -0.7088673 -0.7087707 -0.7086738 -0.7085765 -0.7084789 -0.7083809 [307] -0.7082826 -0.7081839 -0.7080849 -0.7079855 -0.7078858 -0.7077857 [313] -0.7076853 -0.7075845 -0.7074834 -0.7073819 -0.7072801 -0.7071779 [319] -0.7070754 -0.7069725 -0.7068693 -0.7067658 -0.7066619 -0.7065576 [325] -0.7064530 -0.7063480 -0.7062427 -0.7061371 -0.7060311 -0.7059248 [331] -0.7058181 -0.7057110 -0.7056037 -0.7054959 -0.7053879 -0.7052795 [337] -0.7051707 -0.7050616 -0.7049521 -0.7048423 -0.7047322 -0.7046217 [343] -0.7045108 -0.7043997 -0.7042881 -0.7041763 -0.7040641 -0.7039515 [349] -0.7038386 -0.7037253 -0.7036118 -0.7034978 -0.7033835 -0.7032689 [355] -0.7031540 -0.7030387 -0.7029230 -0.7028070 -0.7026907 -0.7025740 [361] -0.7024570 -0.7023396 -0.7022219 -0.7021039 -0.7019855 -0.7018668 [367] -0.7017477 -0.7016283 -0.7015086 -0.7013885 -0.7012681 -0.7011473 [373] -0.7010262 -0.7009048 -0.7007830 -0.7006609 -0.7005384 -0.7004156 [379] -0.7002925 -0.7001690 -0.7000452 -0.6999211 -0.6997966 -0.6996718 [385] -0.6995466 -0.6994211 -0.6992953 -0.6991692 -0.6990427 -0.6989158 [391] -0.6987887 -0.6986612 -0.6985333 -0.6984051 -0.6982766 -0.6981478 [397] -0.6980186 -0.6978891 -0.6977593 -0.6976291 -0.6974986 > mx [1] 0 > mxli [1] -999 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/rcomp/tmp/1rksq1257949678.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/rcomp/tmp/22sh61257949678.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/rcomp/tmp/3baei1257949678.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/rcomp/tmp/4nrk31257949678.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x) > qqline(x) > grid() > mtext('Original Data') > dev.off() null device 1 > postscript(file="/var/www/rcomp/tmp/5728s1257949678.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x1) > qqline(x1) > grid() > mtext('Transformed Data') > dev.off() null device 1 > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/6w3p81257949678.tab") > > system("convert tmp/1rksq1257949678.ps tmp/1rksq1257949678.png") > system("convert tmp/22sh61257949678.ps tmp/22sh61257949678.png") > system("convert tmp/3baei1257949678.ps tmp/3baei1257949678.png") > system("convert tmp/4nrk31257949678.ps tmp/4nrk31257949678.png") > system("convert tmp/5728s1257949678.ps tmp/5728s1257949678.png") > > > proc.time() user system elapsed 1.340 1.230 2.295