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(0.96,1,1.05,1.03,1.07,1.12,1.1,1.06,1.11,1.08,1.07,1.02,1,1.04,1.02,1.07,1.12,1.08,1.02,1.01,1.04,0.98,0.95,0.94,0.94,0.96,0.97,1.03,1.01,0.99,1,1,1.02,1.01,0.99,0.98,1.01,1.03,1.03,1,0.96,0.97,0.98,1.02,1.04,1.01,1.01,1,1.01,1.02,1.03,1.06,1.12,1.12,1.13,1.13,1.13,1.17,1.14,1.08,1.07,1.12,1.14,1.21,1.2,1.23,1.29,1.31,1.37,1.35,1.26,1.26) > #'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.5870452 0.5871826 0.5873199 0.5874571 0.5875941 0.5877309 0.5878676 [8] 0.5880041 0.5881405 0.5882768 0.5884129 0.5885488 0.5886846 0.5888203 [15] 0.5889558 0.5890911 0.5892263 0.5893613 0.5894962 0.5896309 0.5897655 [22] 0.5898999 0.5900342 0.5901683 0.5903022 0.5904360 0.5905697 0.5907031 [29] 0.5908365 0.5909696 0.5911026 0.5912355 0.5913682 0.5915007 0.5916331 [36] 0.5917653 0.5918974 0.5920293 0.5921610 0.5922926 0.5924240 0.5925552 [43] 0.5926863 0.5928172 0.5929480 0.5930786 0.5932091 0.5933393 0.5934694 [50] 0.5935994 0.5937292 0.5938588 0.5939883 0.5941175 0.5942467 0.5943756 [57] 0.5945044 0.5946330 0.5947615 0.5948898 0.5950179 0.5951459 0.5952736 [64] 0.5954013 0.5955287 0.5956560 0.5957831 0.5959100 0.5960368 0.5961634 [71] 0.5962898 0.5964161 0.5965422 0.5966681 0.5967938 0.5969194 0.5970448 [78] 0.5971700 0.5972950 0.5974199 0.5975446 0.5976691 0.5977935 0.5979176 [85] 0.5980416 0.5981655 0.5982891 0.5984126 0.5985359 0.5986590 0.5987819 [92] 0.5989047 0.5990272 0.5991496 0.5992719 0.5993939 0.5995158 0.5996375 [99] 0.5997590 0.5998803 0.6000014 0.6001224 0.6002432 0.6003638 0.6004842 [106] 0.6006044 0.6007245 0.6008443 0.6009640 0.6010835 0.6012028 0.6013220 [113] 0.6014409 0.6015597 0.6016782 0.6017966 0.6019148 0.6020329 0.6021507 [120] 0.6022683 0.6023858 0.6025031 0.6026201 0.6027370 0.6028537 0.6029703 [127] 0.6030866 0.6032027 0.6033187 0.6034344 0.6035500 0.6036654 0.6037806 [134] 0.6038956 0.6040104 0.6041250 0.6042394 0.6043536 0.6044677 0.6045815 [141] 0.6046952 0.6048086 0.6049219 0.6050350 0.6051478 0.6052605 0.6053730 [148] 0.6054853 0.6055974 0.6057093 0.6058210 0.6059325 0.6060438 0.6061549 [155] 0.6062658 0.6063765 0.6064870 0.6065974 0.6067075 0.6068174 0.6069271 [162] 0.6070366 0.6071460 0.6072551 0.6073640 0.6074727 0.6075812 0.6076895 [169] 0.6077977 0.6079056 0.6080133 0.6081208 0.6082281 0.6083352 0.6084421 [176] 0.6085488 0.6086553 0.6087616 0.6088677 0.6089735 0.6090792 0.6091847 [183] 0.6092899 0.6093950 0.6094999 0.6096045 0.6097089 0.6098132 0.6099172 [190] 0.6100210 0.6101246 0.6102280 0.6103312 0.6104342 0.6105370 0.6106395 [197] 0.6107419 0.6108440 0.6109460 0.6110477 0.6111492 0.6112505 0.6113516 [204] 0.6114525 0.6115531 0.6116536 0.6117538 0.6118539 0.6119537 0.6120533 [211] 0.6121527 0.6122519 0.6123508 0.6124496 0.6125481 0.6126464 0.6127445 [218] 0.6128424 0.6129401 0.6130376 0.6131348 0.6132319 0.6133287 0.6134253 [225] 0.6135216 0.6136178 0.6137138 0.6138095 0.6139050 0.6140003 0.6140953 [232] 0.6141902 0.6142848 0.6143793 0.6144734 0.6145674 0.6146612 0.6147547 [239] 0.6148480 0.6149411 0.6150340 0.6151267 0.6152191 0.6153113 0.6154033 [246] 0.6154951 0.6155866 0.6156779 0.6157690 0.6158599 0.6159505 0.6160410 [253] 0.6161312 0.6162212 0.6163109 0.6164004 0.6164897 0.6165788 0.6166677 [260] 0.6167563 0.6168447 0.6169329 0.6170209 0.6171086 0.6171961 0.6172834 [267] 0.6173704 0.6174572 0.6175438 0.6176302 0.6177163 0.6178022 0.6178879 [274] 0.6179733 0.6180586 0.6181436 0.6182283 0.6183129 0.6183972 0.6184812 [281] 0.6185651 0.6186487 0.6187321 0.6188152 0.6188982 0.6189808 0.6190633 [288] 0.6191455 0.6192275 0.6193093 0.6193908 0.6194721 0.6195532 0.6196340 [295] 0.6197146 0.6197950 0.6198751 0.6199550 0.6200347 0.6201141 0.6201933 [302] 0.6202723 0.6203510 0.6204295 0.6205078 0.6205858 0.6206636 0.6207411 [309] 0.6208184 0.6208955 0.6209724 0.6210490 0.6211253 0.6212015 0.6212774 [316] 0.6213530 0.6214285 0.6215036 0.6215786 0.6216533 0.6217278 0.6218020 [323] 0.6218760 0.6219498 0.6220233 0.6220966 0.6221696 0.6222424 0.6223150 [330] 0.6223873 0.6224594 0.6225312 0.6226028 0.6226742 0.6227453 0.6228162 [337] 0.6228868 0.6229572 0.6230274 0.6230973 0.6231669 0.6232364 0.6233056 [344] 0.6233745 0.6234432 0.6235117 0.6235799 0.6236479 0.6237156 0.6237831 [351] 0.6238504 0.6239174 0.6239841 0.6240507 0.6241169 0.6241830 0.6242487 [358] 0.6243143 0.6243796 0.6244446 0.6245095 0.6245740 0.6246383 0.6247024 [365] 0.6247662 0.6248298 0.6248932 0.6249563 0.6250191 0.6250817 0.6251441 [372] 0.6252062 0.6252680 0.6253297 0.6253910 0.6254521 0.6255130 0.6255737 [379] 0.6256340 0.6256942 0.6257541 0.6258137 0.6258731 0.6259322 0.6259911 [386] 0.6260498 0.6261082 0.6261663 0.6262242 0.6262819 0.6263393 0.6263965 [393] 0.6264534 0.6265100 0.6265664 0.6266226 0.6266785 0.6267342 0.6267896 [400] 0.6268448 0.6268997 > mx [1] 0.6268997 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1o3611197885582.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/2bi0k1197885582.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/3xc471197885582.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/45bnn1197885582.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/5y8461197885582.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/6t27i1197885582.tab") > > system("convert tmp/1o3611197885582.ps tmp/1o3611197885582.png") > system("convert tmp/2bi0k1197885582.ps tmp/2bi0k1197885582.png") > system("convert tmp/3xc471197885582.ps tmp/3xc471197885582.png") > system("convert tmp/45bnn1197885582.ps tmp/45bnn1197885582.png") > system("convert tmp/5y8461197885582.ps tmp/5y8461197885582.png") > > > proc.time() user system elapsed 1.286 0.762 1.507