R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-bit) 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.8,96.8,87.0,96.3,107.1,115.2,106.1,89.5,91.3,97.6,100.7,104.6,94.7,101.8,102.5,105.3,110.3,109.8,117.3,118.8,131.3,125.9,133.1,147.0,145.8,164.4,149.8,137.7,151.7,156.8,180.0,180.4,170.4,191.6,199.5,218.2,217.5,205.0,194.0,199.3,219.3,211.1,215.2,240.2,242.2,240.7,255.4,253.0,218.2,203.7,205.6,215.6,188.5,202.9,214.0,230.3,230.0,241.0,259.6,247.8,270.3) > par3 = '2' > par2 = '-2' > par1 = 'Full Box-Cox transform' > 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.8724247 0.8726760 0.8729266 0.8731766 0.8734259 0.8736745 0.8739224 [8] 0.8741697 0.8744163 0.8746622 0.8749073 0.8751518 0.8753956 0.8756387 [15] 0.8758811 0.8761228 0.8763637 0.8766040 0.8768435 0.8770823 0.8773204 [22] 0.8775578 0.8777944 0.8780303 0.8782654 0.8784998 0.8787335 0.8789664 [29] 0.8791986 0.8794300 0.8796607 0.8798906 0.8801197 0.8803481 0.8805757 [36] 0.8808025 0.8810286 0.8812538 0.8814783 0.8817020 0.8819249 0.8821471 [43] 0.8823684 0.8825889 0.8828087 0.8830276 0.8832457 0.8834631 0.8836796 [50] 0.8838952 0.8841101 0.8843241 0.8845374 0.8847497 0.8849613 0.8851720 [57] 0.8853819 0.8855909 0.8857991 0.8860065 0.8862130 0.8864186 0.8866234 [64] 0.8868273 0.8870304 0.8872326 0.8874339 0.8876343 0.8878339 0.8880326 [71] 0.8882304 0.8884273 0.8886234 0.8888185 0.8890128 0.8892062 0.8893986 [78] 0.8895902 0.8897808 0.8899706 0.8901594 0.8903473 0.8905343 0.8907204 [85] 0.8909055 0.8910897 0.8912730 0.8914554 0.8916368 0.8918173 0.8919968 [92] 0.8921754 0.8923531 0.8925298 0.8927055 0.8928803 0.8930542 0.8932270 [99] 0.8933989 0.8935699 0.8937398 0.8939088 0.8940768 0.8942439 0.8944099 [106] 0.8945750 0.8947391 0.8949022 0.8950643 0.8952254 0.8953855 0.8955446 [113] 0.8957027 0.8958598 0.8960159 0.8961710 0.8963250 0.8964781 0.8966301 [120] 0.8967811 0.8969311 0.8970800 0.8972280 0.8973749 0.8975207 0.8976655 [127] 0.8978093 0.8979520 0.8980937 0.8982343 0.8983739 0.8985125 0.8986500 [134] 0.8987864 0.8989217 0.8990560 0.8991893 0.8993214 0.8994525 0.8995826 [141] 0.8997115 0.8998394 0.8999662 0.9000919 0.9002165 0.9003401 0.9004625 [148] 0.9005839 0.9007042 0.9008234 0.9009414 0.9010584 0.9011743 0.9012891 [155] 0.9014028 0.9015153 0.9016268 0.9017371 0.9018464 0.9019545 0.9020615 [162] 0.9021674 0.9022721 0.9023758 0.9024783 0.9025797 0.9026799 0.9027790 [169] 0.9028770 0.9029739 0.9030696 0.9031642 0.9032576 0.9033499 0.9034411 [176] 0.9035311 0.9036200 0.9037077 0.9037942 0.9038797 0.9039639 0.9040470 [183] 0.9041290 0.9042097 0.9042894 0.9043678 0.9044451 0.9045213 0.9045962 [190] 0.9046701 0.9047427 0.9048142 0.9048844 0.9049536 0.9050215 0.9050883 [197] 0.9051539 0.9052183 0.9052815 0.9053436 0.9054045 0.9054641 0.9055227 [204] 0.9055800 0.9056361 0.9056911 0.9057448 0.9057974 0.9058488 0.9058989 [211] 0.9059479 0.9059957 0.9060423 0.9060877 0.9061320 0.9061750 0.9062168 [218] 0.9062574 0.9062968 0.9063350 0.9063721 0.9064079 0.9064425 0.9064759 [225] 0.9065081 0.9065391 0.9065689 0.9065975 0.9066249 0.9066510 0.9066760 [232] 0.9066997 0.9067223 0.9067436 0.9067638 0.9067827 0.9068004 0.9068169 [239] 0.9068322 0.9068463 0.9068591 0.9068708 0.9068812 0.9068904 0.9068984 [246] 0.9069052 0.9069108 0.9069152 0.9069184 0.9069203 0.9069211 0.9069206 [253] 0.9069189 0.9069160 0.9069119 0.9069065 0.9069000 0.9068922 0.9068832 [260] 0.9068731 0.9068617 0.9068491 0.9068352 0.9068202 0.9068040 0.9067865 [267] 0.9067678 0.9067479 0.9067269 0.9067046 0.9066810 0.9066563 0.9066304 [274] 0.9066033 0.9065749 0.9065454 0.9065146 0.9064827 0.9064495 0.9064151 [281] 0.9063795 0.9063428 0.9063048 0.9062656 0.9062252 0.9061836 0.9061408 [288] 0.9060968 0.9060517 0.9060053 0.9059577 0.9059089 0.9058590 0.9058078 [295] 0.9057554 0.9057019 0.9056472 0.9055912 0.9055341 0.9054758 0.9054163 [302] 0.9053557 0.9052938 0.9052308 0.9051666 0.9051012 0.9050346 0.9049668 [309] 0.9048979 0.9048278 0.9047565 0.9046840 0.9046104 0.9045356 0.9044596 [316] 0.9043825 0.9043042 0.9042248 0.9041441 0.9040623 0.9039794 0.9038953 [323] 0.9038100 0.9037236 0.9036361 0.9035473 0.9034575 0.9033665 0.9032743 [330] 0.9031810 0.9030865 0.9029909 0.9028942 0.9027964 0.9026973 0.9025972 [337] 0.9024959 0.9023935 0.9022900 0.9021854 0.9020796 0.9019727 0.9018647 [344] 0.9017555 0.9016453 0.9015339 0.9014214 0.9013078 0.9011931 0.9010773 [351] 0.9009604 0.9008424 0.9007233 0.9006031 0.9004818 0.9003594 0.9002359 [358] 0.9001113 0.8999856 0.8998589 0.8997311 0.8996022 0.8994722 0.8993411 [365] 0.8992090 0.8990758 0.8989415 0.8988062 0.8986698 0.8985323 0.8983938 [372] 0.8982542 0.8981136 0.8979719 0.8978292 0.8976854 0.8975406 0.8973948 [379] 0.8972479 0.8971000 0.8969510 0.8968010 0.8966500 0.8964980 0.8963449 [386] 0.8961908 0.8960358 0.8958796 0.8957225 0.8955644 0.8954053 0.8952451 [393] 0.8950840 0.8949219 0.8947587 0.8945946 0.8944295 0.8942634 0.8940964 [400] 0.8939283 0.8937593 > mx [1] 0.9069211 > mxli [1] 0.5 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/fisher/rcomp/tmp/18gis1356005631.ps",horizontal=F,onefile=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/fisher/rcomp/tmp/25kp11356005631.ps",horizontal=F,onefile=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/fisher/rcomp/tmp/3ch351356005631.ps",horizontal=F,onefile=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/fisher/rcomp/tmp/4k4k31356005631.ps",horizontal=F,onefile=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/fisher/rcomp/tmp/5bnei1356005631.ps",horizontal=F,onefile=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/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/6ohy11356005631.tab") > > try(system("convert tmp/18gis1356005631.ps tmp/18gis1356005631.png",intern=TRUE)) character(0) > try(system("convert tmp/25kp11356005631.ps tmp/25kp11356005631.png",intern=TRUE)) character(0) > try(system("convert tmp/3ch351356005631.ps tmp/3ch351356005631.png",intern=TRUE)) character(0) > try(system("convert tmp/4k4k31356005631.ps tmp/4k4k31356005631.png",intern=TRUE)) character(0) > try(system("convert tmp/5bnei1356005631.ps tmp/5bnei1356005631.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.843 0.841 3.690