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(7.4,7.2,7,6.6,6.4,6.4,6.8,7.3,7,7,6.7,6.7,6.3,6.2,6,6.3,6.2,6.1,6.2,6.6,6.6,7.8,7.4,7.4,7.5,7.4,7.4,7,6.9,6.9,7.6,7.7,7.6,8.2,8,8.1,8.3,8.2,8.1,7.7,7.6,7.7,8.2,8.4,8.4,8.6,8.4,8.5,8.7,8.7,8.6,7.4,7.3,7.4,9,9.2,9.2,8.5,8.3,8.3,8.6,8.6,8.5,8.1,8.1,8,8.6,8.7,8.7,8.6,8.4,8.4,8.7,8.7,8.5,8.3,8.3,8.3,8.1,8.2,8.1,8.1,7.9,7.7,8.1,8,7.7,7.8,7.6,7.4,7.7,7.9,7.6) > #'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.5942843 0.5942765 0.5942684 0.5942600 0.5942514 0.5942424 0.5942332 [8] 0.5942237 0.5942138 0.5942037 0.5941933 0.5941826 0.5941716 0.5941603 [15] 0.5941487 0.5941368 0.5941246 0.5941121 0.5940993 0.5940863 0.5940729 [22] 0.5940592 0.5940453 0.5940310 0.5940165 0.5940016 0.5939865 0.5939711 [29] 0.5939553 0.5939393 0.5939230 0.5939064 0.5938895 0.5938723 0.5938547 [36] 0.5938369 0.5938189 0.5938005 0.5937818 0.5937628 0.5937435 0.5937239 [43] 0.5937041 0.5936839 0.5936634 0.5936427 0.5936216 0.5936002 0.5935786 [50] 0.5935566 0.5935344 0.5935118 0.5934890 0.5934659 0.5934424 0.5934187 [57] 0.5933947 0.5933703 0.5933457 0.5933208 0.5932956 0.5932700 0.5932442 [64] 0.5932181 0.5931917 0.5931650 0.5931380 0.5931107 0.5930831 0.5930552 [71] 0.5930270 0.5929985 0.5929697 0.5929406 0.5929112 0.5928816 0.5928516 [78] 0.5928213 0.5927907 0.5927599 0.5927287 0.5926972 0.5926654 0.5926334 [85] 0.5926010 0.5925684 0.5925354 0.5925021 0.5924686 0.5924347 0.5924006 [92] 0.5923661 0.5923314 0.5922963 0.5922610 0.5922253 0.5921894 0.5921532 [99] 0.5921166 0.5920798 0.5920427 0.5920052 0.5919675 0.5919295 0.5918912 [106] 0.5918526 0.5918136 0.5917744 0.5917349 0.5916951 0.5916550 0.5916146 [113] 0.5915739 0.5915329 0.5914916 0.5914500 0.5914081 0.5913659 0.5913234 [120] 0.5912806 0.5912375 0.5911942 0.5911505 0.5911065 0.5910622 0.5910177 [127] 0.5909728 0.5909276 0.5908822 0.5908364 0.5907904 0.5907440 0.5906974 [134] 0.5906504 0.5906032 0.5905556 0.5905078 0.5904597 0.5904112 0.5903625 [141] 0.5903135 0.5902641 0.5902145 0.5901646 0.5901144 0.5900639 0.5900131 [148] 0.5899620 0.5899106 0.5898589 0.5898069 0.5897546 0.5897021 0.5896492 [155] 0.5895960 0.5895426 0.5894888 0.5894347 0.5893804 0.5893257 0.5892708 [162] 0.5892156 0.5891600 0.5891042 0.5890481 0.5889917 0.5889349 0.5888779 [169] 0.5888206 0.5887630 0.5887052 0.5886470 0.5885885 0.5885297 0.5884707 [176] 0.5884113 0.5883516 0.5882917 0.5882314 0.5881709 0.5881101 0.5880490 [183] 0.5879875 0.5879258 0.5878638 0.5878015 0.5877389 0.5876761 0.5876129 [190] 0.5875494 0.5874857 0.5874216 0.5873573 0.5872926 0.5872277 0.5871625 [197] 0.5870970 0.5870312 0.5869651 0.5868987 0.5868320 0.5867651 0.5866978 [204] 0.5866302 0.5865624 0.5864943 0.5864259 0.5863571 0.5862881 0.5862189 [211] 0.5861493 0.5860794 0.5860092 0.5859388 0.5858680 0.5857970 0.5857257 [218] 0.5856541 0.5855822 0.5855100 0.5854375 0.5853648 0.5852917 0.5852184 [225] 0.5851447 0.5850708 0.5849966 0.5849221 0.5848474 0.5847723 0.5846969 [232] 0.5846213 0.5845454 0.5844692 0.5843927 0.5843159 0.5842388 0.5841614 [239] 0.5840838 0.5840059 0.5839277 0.5838492 0.5837704 0.5836913 0.5836119 [246] 0.5835323 0.5834524 0.5833722 0.5832917 0.5832109 0.5831298 0.5830485 [253] 0.5829669 0.5828849 0.5828028 0.5827203 0.5826375 0.5825545 0.5824711 [260] 0.5823875 0.5823036 0.5822195 0.5821350 0.5820503 0.5819653 0.5818800 [267] 0.5817944 0.5817085 0.5816224 0.5815360 0.5814493 0.5813623 0.5812750 [274] 0.5811875 0.5810997 0.5810116 0.5809232 0.5808345 0.5807456 0.5806564 [281] 0.5805669 0.5804771 0.5803871 0.5802967 0.5802061 0.5801153 0.5800241 [288] 0.5799327 0.5798410 0.5797490 0.5796567 0.5795642 0.5794713 0.5793783 [295] 0.5792849 0.5791912 0.5790973 0.5790031 0.5789087 0.5788139 0.5787189 [302] 0.5786236 0.5785281 0.5784322 0.5783361 0.5782398 0.5781431 0.5780462 [309] 0.5779490 0.5778515 0.5777538 0.5776558 0.5775575 0.5774589 0.5773601 [316] 0.5772610 0.5771616 0.5770620 0.5769621 0.5768619 0.5767615 0.5766608 [323] 0.5765598 0.5764585 0.5763570 0.5762552 0.5761532 0.5760508 0.5759482 [330] 0.5758454 0.5757423 0.5756389 0.5755352 0.5754313 0.5753271 0.5752226 [337] 0.5751179 0.5750129 0.5749077 0.5748022 0.5746964 0.5745903 0.5744840 [344] 0.5743774 0.5742706 0.5741635 0.5740561 0.5739485 0.5738406 0.5737325 [351] 0.5736241 0.5735154 0.5734065 0.5732973 0.5731878 0.5730781 0.5729681 [358] 0.5728579 0.5727474 0.5726366 0.5725256 0.5724143 0.5723028 0.5721910 [365] 0.5720790 0.5719667 0.5718541 0.5717413 0.5716282 0.5715149 0.5714013 [372] 0.5712874 0.5711733 0.5710590 0.5709443 0.5708295 0.5707143 0.5705990 [379] 0.5704833 0.5703674 0.5702513 0.5701349 0.5700183 0.5699014 0.5697842 [386] 0.5696668 0.5695491 0.5694312 0.5693131 0.5691947 0.5690760 0.5689571 [393] 0.5688379 0.5687185 0.5685989 0.5684790 0.5683588 0.5682384 0.5681177 [400] 0.5679968 0.5678757 > mx [1] 0.5942843 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1bagw1194256846.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/231dw1194256846.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/3c7781194256846.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/4q8dl1194256846.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/5txrp1194256846.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/6kqye1194256847.tab") > > system("convert tmp/1bagw1194256846.ps tmp/1bagw1194256846.png") > system("convert tmp/231dw1194256846.ps tmp/231dw1194256846.png") > system("convert tmp/3c7781194256846.ps tmp/3c7781194256846.png") > system("convert tmp/4q8dl1194256846.ps tmp/4q8dl1194256846.png") > system("convert tmp/5txrp1194256846.ps tmp/5txrp1194256846.png") > > > proc.time() user system elapsed 1.347 0.830 1.686