R version 2.8.0 (2008-10-20) Copyright (C) 2008 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(95.4,101.2,101.5,101.9,101.7,100.1,97.4,96.5,99.2,102.2,105.3,111.1,114.9,124.5,142.2,159.7,165.2,198.6,207.8,219.6,239.6,235.3,218.5,213.8,205.5,198.4,198.5,190.2,180.7,193.6,192.8,195.5,197.2,196.9,178.9,172.4,156.4,143.7,153.6,168.8,185.8,199.9,205.4,197.5,199.6,200.5,193.7,179.6,169.1,169.8,195.5,194.8,204.5,203.8,204.8,204.9,240,248.3,258.4,254.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.7715992 0.7716624 0.7717253 0.7717880 0.7718504 0.7719125 0.7719743 [8] 0.7720359 0.7720971 0.7721581 0.7722188 0.7722792 0.7723393 0.7723991 [15] 0.7724586 0.7725178 0.7725767 0.7726353 0.7726936 0.7727516 0.7728092 [22] 0.7728666 0.7729236 0.7729803 0.7730367 0.7730927 0.7731485 0.7732039 [29] 0.7732589 0.7733137 0.7733680 0.7734221 0.7734758 0.7735292 0.7735822 [36] 0.7736348 0.7736871 0.7737391 0.7737906 0.7738419 0.7738927 0.7739432 [43] 0.7739933 0.7740431 0.7740925 0.7741415 0.7741901 0.7742383 0.7742861 [50] 0.7743336 0.7743806 0.7744273 0.7744736 0.7745195 0.7745649 0.7746100 [57] 0.7746546 0.7746989 0.7747427 0.7747861 0.7748291 0.7748716 0.7749138 [64] 0.7749555 0.7749968 0.7750376 0.7750780 0.7751180 0.7751575 0.7751966 [71] 0.7752352 0.7752734 0.7753111 0.7753484 0.7753852 0.7754215 0.7754574 [78] 0.7754928 0.7755277 0.7755622 0.7755961 0.7756296 0.7756626 0.7756952 [85] 0.7757272 0.7757587 0.7757898 0.7758203 0.7758503 0.7758799 0.7759089 [92] 0.7759374 0.7759654 0.7759928 0.7760198 0.7760462 0.7760721 0.7760975 [99] 0.7761223 0.7761466 0.7761704 0.7761936 0.7762163 0.7762384 0.7762599 [106] 0.7762809 0.7763014 0.7763213 0.7763406 0.7763593 0.7763775 0.7763951 [113] 0.7764122 0.7764286 0.7764445 0.7764597 0.7764744 0.7764885 0.7765020 [120] 0.7765149 0.7765272 0.7765388 0.7765499 0.7765604 0.7765702 0.7765794 [127] 0.7765880 0.7765960 0.7766033 0.7766100 0.7766161 0.7766215 0.7766263 [134] 0.7766305 0.7766340 0.7766368 0.7766390 0.7766405 0.7766414 0.7766416 [141] 0.7766412 0.7766400 0.7766382 0.7766357 0.7766326 0.7766287 0.7766242 [148] 0.7766189 0.7766130 0.7766064 0.7765991 0.7765910 0.7765823 0.7765729 [155] 0.7765627 0.7765519 0.7765403 0.7765280 0.7765149 0.7765012 0.7764867 [162] 0.7764714 0.7764555 0.7764387 0.7764213 0.7764031 0.7763841 0.7763644 [169] 0.7763440 0.7763227 0.7763007 0.7762780 0.7762545 0.7762302 0.7762051 [176] 0.7761792 0.7761526 0.7761252 0.7760970 0.7760680 0.7760382 0.7760076 [183] 0.7759762 0.7759440 0.7759110 0.7758772 0.7758426 0.7758072 0.7757709 [190] 0.7757339 0.7756960 0.7756572 0.7756177 0.7755773 0.7755361 0.7754940 [197] 0.7754511 0.7754074 0.7753628 0.7753174 0.7752711 0.7752239 0.7751759 [204] 0.7751271 0.7750774 0.7750268 0.7749753 0.7749230 0.7748698 0.7748157 [211] 0.7747607 0.7747049 0.7746481 0.7745905 0.7745320 0.7744726 0.7744123 [218] 0.7743511 0.7742890 0.7742260 0.7741621 0.7740973 0.7740315 0.7739649 [225] 0.7738974 0.7738289 0.7737595 0.7736892 0.7736179 0.7735458 0.7734727 [232] 0.7733986 0.7733237 0.7732478 0.7731709 0.7730931 0.7730144 0.7729347 [239] 0.7728541 0.7727726 0.7726900 0.7726066 0.7725221 0.7724367 0.7723504 [246] 0.7722631 0.7721748 0.7720855 0.7719953 0.7719042 0.7718120 0.7717189 [253] 0.7716248 0.7715297 0.7714336 0.7713366 0.7712385 0.7711395 0.7710395 [260] 0.7709385 0.7708366 0.7707336 0.7706296 0.7705247 0.7704187 0.7703118 [267] 0.7702038 0.7700949 0.7699849 0.7698740 0.7697620 0.7696490 0.7695351 [274] 0.7694201 0.7693041 0.7691871 0.7690690 0.7689500 0.7688300 0.7687089 [281] 0.7685868 0.7684637 0.7683396 0.7682144 0.7680883 0.7679611 0.7678329 [288] 0.7677036 0.7675734 0.7674421 0.7673098 0.7671764 0.7670420 0.7669066 [295] 0.7667702 0.7666327 0.7664942 0.7663547 0.7662141 0.7660725 0.7659299 [302] 0.7657862 0.7656415 0.7654958 0.7653490 0.7652012 0.7650524 0.7649025 [309] 0.7647516 0.7645996 0.7644466 0.7642926 0.7641376 0.7639814 0.7638243 [316] 0.7636661 0.7635069 0.7633466 0.7631853 0.7630230 0.7628596 0.7626952 [323] 0.7625298 0.7623633 0.7621958 0.7620272 0.7618576 0.7616870 0.7615153 [330] 0.7613426 0.7611689 0.7609941 0.7608183 0.7606415 0.7604636 0.7602847 [337] 0.7601048 0.7599238 0.7597418 0.7595588 0.7593747 0.7591896 0.7590035 [344] 0.7588164 0.7586282 0.7584390 0.7582488 0.7580576 0.7578654 0.7576721 [351] 0.7574778 0.7572825 0.7570862 0.7568888 0.7566905 0.7564911 0.7562907 [358] 0.7560893 0.7558869 0.7556835 0.7554791 0.7552737 0.7550673 0.7548599 [365] 0.7546514 0.7544420 0.7542316 0.7540202 0.7538078 0.7535944 0.7533800 [372] 0.7531646 0.7529483 0.7527309 0.7525126 0.7522933 0.7520730 0.7518518 [379] 0.7516295 0.7514063 0.7511821 0.7509570 0.7507309 0.7505038 0.7502758 [386] 0.7500468 0.7498168 0.7495859 0.7493540 0.7491212 0.7488875 0.7486528 [393] 0.7484171 0.7481805 0.7479430 0.7477045 0.7474651 0.7472248 0.7469836 [400] 0.7467414 0.7464983 > mx [1] 0.7766416 > mxli [1] -0.61 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1fa5r1227956315.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/2m28f1227956315.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/31n971227956315.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/4nvyw1227956315.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/53dnt1227956315.ps",horizontal=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/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > 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/6dorj1227956316.tab") > > system("convert tmp/1fa5r1227956315.ps tmp/1fa5r1227956315.png") > system("convert tmp/2m28f1227956315.ps tmp/2m28f1227956315.png") > system("convert tmp/31n971227956315.ps tmp/31n971227956315.png") > system("convert tmp/4nvyw1227956315.ps tmp/4nvyw1227956315.png") > system("convert tmp/53dnt1227956315.ps tmp/53dnt1227956315.png") > > > proc.time() user system elapsed 1.063 0.753 1.375