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(98.6,98,106.8,96.6,100.1,107.7,91.5,97.8,107.4,117.5,105.6,97.4,99.5,98,104.3,100.6,101.1,103.9,96.9,95.5,108.4,117,103.8,100.8,110.6,104,112.6,107.3,98.9,109.8,104.9,102.2,123.9,124.9,112.7,121.9,100.6,104.3,120.4,107.5,102.9,125.6,107.5,108.8,128.4,121.1,119.5,128.7,108.7,105.5,119.8,111.3,110.6,120.1,97.5,107.7,127.3,117.2,119.8,116.2,111,112.4,130.6,109.1,118.8,123.9,101.6,112.8,128,129.6,125.8,119.5,115.7,113.6,129.7,112,116.8,126.3,112.9,115.9) > #'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.6215111 0.6214692 0.6214271 0.6213848 0.6213424 0.6212999 0.6212572 [8] 0.6212143 0.6211712 0.6211281 0.6210847 0.6210412 0.6209976 0.6209537 [15] 0.6209098 0.6208657 0.6208214 0.6207769 0.6207323 0.6206876 0.6206427 [22] 0.6205976 0.6205524 0.6205070 0.6204615 0.6204158 0.6203700 0.6203240 [29] 0.6202778 0.6202315 0.6201851 0.6201385 0.6200917 0.6200448 0.6199977 [36] 0.6199505 0.6199031 0.6198555 0.6198078 0.6197600 0.6197120 0.6196638 [43] 0.6196155 0.6195671 0.6195184 0.6194697 0.6194207 0.6193717 0.6193224 [50] 0.6192730 0.6192235 0.6191738 0.6191239 0.6190739 0.6190238 0.6189735 [57] 0.6189230 0.6188724 0.6188216 0.6187707 0.6187196 0.6186684 0.6186170 [64] 0.6185655 0.6185138 0.6184620 0.6184100 0.6183579 0.6183056 0.6182532 [71] 0.6182006 0.6181478 0.6180949 0.6180419 0.6179887 0.6179353 0.6178818 [78] 0.6178282 0.6177744 0.6177204 0.6176663 0.6176121 0.6175577 0.6175031 [85] 0.6174484 0.6173936 0.6173386 0.6172834 0.6172281 0.6171726 0.6171170 [92] 0.6170613 0.6170054 0.6169493 0.6168931 0.6168368 0.6167803 0.6167236 [99] 0.6166668 0.6166099 0.6165528 0.6164955 0.6164381 0.6163806 0.6163229 [106] 0.6162651 0.6162071 0.6161489 0.6160907 0.6160322 0.6159737 0.6159149 [113] 0.6158561 0.6157970 0.6157379 0.6156786 0.6156191 0.6155595 0.6154997 [120] 0.6154398 0.6153798 0.6153196 0.6152592 0.6151987 0.6151381 0.6150773 [127] 0.6150164 0.6149553 0.6148941 0.6148327 0.6147712 0.6147096 0.6146478 [134] 0.6145858 0.6145237 0.6144615 0.6143991 0.6143366 0.6142739 0.6142111 [141] 0.6141481 0.6140850 0.6140218 0.6139584 0.6138949 0.6138312 0.6137674 [148] 0.6137034 0.6136393 0.6135750 0.6135106 0.6134461 0.6133814 0.6133166 [155] 0.6132516 0.6131865 0.6131212 0.6130558 0.6129903 0.6129246 0.6128588 [162] 0.6127928 0.6127267 0.6126605 0.6125941 0.6125275 0.6124609 0.6123940 [169] 0.6123271 0.6122600 0.6121927 0.6121254 0.6120578 0.6119902 0.6119224 [176] 0.6118544 0.6117864 0.6117181 0.6116498 0.6115813 0.6115126 0.6114438 [183] 0.6113749 0.6113059 0.6112367 0.6111673 0.6110979 0.6110282 0.6109585 [190] 0.6108886 0.6108186 0.6107484 0.6106781 0.6106076 0.6105371 0.6104663 [197] 0.6103955 0.6103245 0.6102533 0.6101821 0.6101107 0.6100391 0.6099674 [204] 0.6098956 0.6098237 0.6097516 0.6096794 0.6096070 0.6095345 0.6094619 [211] 0.6093891 0.6093162 0.6092431 0.6091700 0.6090966 0.6090232 0.6089496 [218] 0.6088759 0.6088020 0.6087281 0.6086539 0.6085797 0.6085053 0.6084308 [225] 0.6083561 0.6082813 0.6082064 0.6081313 0.6080561 0.6079808 0.6079054 [232] 0.6078298 0.6077541 0.6076782 0.6076022 0.6075261 0.6074498 0.6073735 [239] 0.6072969 0.6072203 0.6071435 0.6070666 0.6069896 0.6069124 0.6068351 [246] 0.6067576 0.6066801 0.6066024 0.6065246 0.6064466 0.6063685 0.6062903 [253] 0.6062119 0.6061335 0.6060549 0.6059761 0.6058973 0.6058183 0.6057391 [260] 0.6056599 0.6055805 0.6055010 0.6054214 0.6053416 0.6052617 0.6051817 [267] 0.6051015 0.6050213 0.6049408 0.6048603 0.6047797 0.6046989 0.6046180 [274] 0.6045369 0.6044557 0.6043745 0.6042930 0.6042115 0.6041298 0.6040480 [281] 0.6039661 0.6038841 0.6038019 0.6037196 0.6036372 0.6035546 0.6034719 [288] 0.6033891 0.6033062 0.6032232 0.6031400 0.6030567 0.6029733 0.6028897 [295] 0.6028061 0.6027223 0.6026384 0.6025543 0.6024702 0.6023859 0.6023015 [302] 0.6022170 0.6021323 0.6020475 0.6019626 0.6018776 0.6017925 0.6017072 [309] 0.6016219 0.6015364 0.6014507 0.6013650 0.6012791 0.6011932 0.6011070 [316] 0.6010208 0.6009345 0.6008480 0.6007614 0.6006747 0.6005879 0.6005010 [323] 0.6004139 0.6003267 0.6002394 0.6001520 0.6000645 0.5999768 0.5998891 [330] 0.5998012 0.5997132 0.5996250 0.5995368 0.5994484 0.5993600 0.5992714 [337] 0.5991827 0.5990938 0.5990049 0.5989158 0.5988267 0.5987374 0.5986480 [344] 0.5985584 0.5984688 0.5983790 0.5982892 0.5981992 0.5981091 0.5980189 [351] 0.5979286 0.5978381 0.5977476 0.5976569 0.5975661 0.5974752 0.5973842 [358] 0.5972931 0.5972018 0.5971105 0.5970190 0.5969275 0.5968358 0.5967440 [365] 0.5966521 0.5965600 0.5964679 0.5963757 0.5962833 0.5961908 0.5960982 [372] 0.5960056 0.5959128 0.5958198 0.5957268 0.5956337 0.5955404 0.5954471 [379] 0.5953536 0.5952601 0.5951664 0.5950726 0.5949787 0.5948847 0.5947906 [386] 0.5946963 0.5946020 0.5945076 0.5944130 0.5943184 0.5942236 0.5941287 [393] 0.5940337 0.5939387 0.5938435 0.5937482 0.5936528 0.5935573 0.5934616 [400] 0.5933659 0.5932701 > mx [1] 0.6215111 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1x1521194696216.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/29dkv1194696216.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/3coxm1194696216.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/4pole1194696216.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/5aig71194696216.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/6pptp1194696216.tab") > > system("convert tmp/1x1521194696216.ps tmp/1x1521194696216.png") > system("convert tmp/29dkv1194696216.ps tmp/29dkv1194696216.png") > system("convert tmp/3coxm1194696216.ps tmp/3coxm1194696216.png") > system("convert tmp/4pole1194696216.ps tmp/4pole1194696216.png") > system("convert tmp/5aig71194696216.ps tmp/5aig71194696216.png") > > > proc.time() user system elapsed 2.406 1.335 2.576