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(6.5,6.4,6.2,6.2,6.3,7.5,7.4,7.4,7.4,7.4,7.4,7.2,7.2,7.2,7.5,7.4,7.4,8,8.1,8.1,8.1,8.1,8.1,7.9,7.9,8,8.1,8.1,8.1,8.5,8.5,8.6,8.4,8.4,8.4,7.7,7.8,7.9,8.7,8.8,8.8,8.5,8.5,8.5,8.4,8.5,8.5,8.3,8.4,8.4,8.4,8.4,8.4,8.5,8.5,8.5,8.5,8.5,8.5,8.3,8.3,8.4,8.2,8.2,8.1,8.1,8,7.8,7.9,7.8,7.7,7.9,7.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.6314453 0.6314278 0.6314101 0.6313921 0.6313739 0.6313554 0.6313367 [8] 0.6313177 0.6312985 0.6312790 0.6312592 0.6312392 0.6312189 0.6311984 [15] 0.6311776 0.6311566 0.6311353 0.6311138 0.6310920 0.6310699 0.6310476 [22] 0.6310250 0.6310022 0.6309791 0.6309557 0.6309321 0.6309083 0.6308842 [29] 0.6308598 0.6308352 0.6308103 0.6307852 0.6307598 0.6307341 0.6307082 [36] 0.6306821 0.6306556 0.6306290 0.6306020 0.6305748 0.6305474 0.6305197 [43] 0.6304917 0.6304635 0.6304350 0.6304063 0.6303773 0.6303481 0.6303186 [50] 0.6302888 0.6302588 0.6302286 0.6301980 0.6301672 0.6301362 0.6301049 [57] 0.6300734 0.6300416 0.6300095 0.6299772 0.6299446 0.6299118 0.6298787 [64] 0.6298453 0.6298117 0.6297779 0.6297438 0.6297094 0.6296748 0.6296399 [71] 0.6296048 0.6295694 0.6295337 0.6294978 0.6294616 0.6294252 0.6293886 [78] 0.6293516 0.6293144 0.6292770 0.6292393 0.6292014 0.6291632 0.6291247 [85] 0.6290860 0.6290470 0.6290078 0.6289683 0.6289286 0.6288886 0.6288483 [92] 0.6288078 0.6287671 0.6287260 0.6286848 0.6286433 0.6286015 0.6285595 [99] 0.6285172 0.6284746 0.6284318 0.6283888 0.6283455 0.6283019 0.6282581 [106] 0.6282141 0.6281697 0.6281252 0.6280803 0.6280353 0.6279899 0.6279443 [113] 0.6278985 0.6278524 0.6278061 0.6277595 0.6277126 0.6276655 0.6276182 [120] 0.6275705 0.6275227 0.6274746 0.6274262 0.6273776 0.6273287 0.6272796 [127] 0.6272302 0.6271806 0.6271307 0.6270806 0.6270302 0.6269796 0.6269287 [134] 0.6268775 0.6268262 0.6267745 0.6267226 0.6266705 0.6266181 0.6265655 [141] 0.6265126 0.6264594 0.6264061 0.6263524 0.6262985 0.6262444 0.6261900 [148] 0.6261354 0.6260805 0.6260253 0.6259699 0.6259143 0.6258584 0.6258023 [155] 0.6257459 0.6256893 0.6256324 0.6255753 0.6255179 0.6254603 0.6254024 [162] 0.6253443 0.6252859 0.6252273 0.6251685 0.6251094 0.6250500 0.6249904 [169] 0.6249306 0.6248705 0.6248102 0.6247496 0.6246888 0.6246277 0.6245664 [176] 0.6245048 0.6244430 0.6243809 0.6243186 0.6242561 0.6241933 0.6241303 [183] 0.6240670 0.6240035 0.6239397 0.6238757 0.6238115 0.6237470 0.6236822 [190] 0.6236173 0.6235520 0.6234866 0.6234209 0.6233549 0.6232887 0.6232223 [197] 0.6231556 0.6230887 0.6230216 0.6229542 0.6228865 0.6228187 0.6227505 [204] 0.6226822 0.6226136 0.6225447 0.6224757 0.6224064 0.6223368 0.6222670 [211] 0.6221970 0.6221267 0.6220562 0.6219854 0.6219144 0.6218432 0.6217718 [218] 0.6217001 0.6216281 0.6215559 0.6214835 0.6214109 0.6213380 0.6212649 [225] 0.6211915 0.6211179 0.6210441 0.6209701 0.6208958 0.6208212 0.6207465 [232] 0.6206715 0.6205962 0.6205208 0.6204451 0.6203691 0.6202930 0.6202165 [239] 0.6201399 0.6200630 0.6199859 0.6199086 0.6198311 0.6197533 0.6196752 [246] 0.6195970 0.6195185 0.6194398 0.6193608 0.6192816 0.6192022 0.6191226 [253] 0.6190427 0.6189626 0.6188823 0.6188017 0.6187210 0.6186399 0.6185587 [260] 0.6184772 0.6183955 0.6183136 0.6182315 0.6181491 0.6180665 0.6179837 [267] 0.6179006 0.6178173 0.6177338 0.6176501 0.6175661 0.6174820 0.6173975 [274] 0.6173129 0.6172281 0.6171430 0.6170577 0.6169722 0.6168864 0.6168004 [281] 0.6167143 0.6166278 0.6165412 0.6164543 0.6163673 0.6162800 0.6161924 [288] 0.6161047 0.6160167 0.6159286 0.6158402 0.6157515 0.6156627 0.6155737 [295] 0.6154844 0.6153949 0.6153052 0.6152152 0.6151251 0.6150347 0.6149441 [302] 0.6148533 0.6147623 0.6146711 0.6145797 0.6144880 0.6143961 0.6143040 [309] 0.6142117 0.6141192 0.6140265 0.6139335 0.6138404 0.6137470 0.6136534 [316] 0.6135596 0.6134656 0.6133714 0.6132769 0.6131823 0.6130874 0.6129923 [323] 0.6128971 0.6128016 0.6127059 0.6126100 0.6125139 0.6124175 0.6123210 [330] 0.6122242 0.6121273 0.6120301 0.6119328 0.6118352 0.6117374 0.6116394 [337] 0.6115412 0.6114428 0.6113442 0.6112454 0.6111464 0.6110472 0.6109477 [344] 0.6108481 0.6107483 0.6106482 0.6105480 0.6104475 0.6103469 0.6102461 [351] 0.6101450 0.6100437 0.6099423 0.6098406 0.6097388 0.6096367 0.6095345 [358] 0.6094320 0.6093294 0.6092265 0.6091235 0.6090202 0.6089168 0.6088131 [365] 0.6087093 0.6086052 0.6085010 0.6083966 0.6082919 0.6081871 0.6080821 [372] 0.6079769 0.6078714 0.6077658 0.6076600 0.6075540 0.6074478 0.6073415 [379] 0.6072349 0.6071281 0.6070212 0.6069140 0.6068067 0.6066991 0.6065914 [386] 0.6064835 0.6063754 0.6062671 0.6061586 0.6060499 0.6059411 0.6058320 [393] 0.6057228 0.6056133 0.6055037 0.6053939 0.6052839 0.6051737 0.6050634 [400] 0.6049528 0.6048421 > mx [1] 0.6314453 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1entm1194288584.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/2nfk01194288584.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/3756r1194288584.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/4bh0g1194288585.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/5i5td1194288585.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/65x0m1194288585.tab") > > system("convert tmp/1entm1194288584.ps tmp/1entm1194288584.png") > system("convert tmp/2nfk01194288584.ps tmp/2nfk01194288584.png") > system("convert tmp/3756r1194288584.ps tmp/3756r1194288584.png") > system("convert tmp/4bh0g1194288585.ps tmp/4bh0g1194288585.png") > system("convert tmp/5i5td1194288585.ps tmp/5i5td1194288585.png") > > > proc.time() user system elapsed 1.359 0.830 1.605