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(100.70,97.90,96.50,96.60,96.60,95.50,91.80,89.30,87.00,85.90,88.00,87.90,89.20,90.90,91.60,90.20,89.10,87.50,86.30,86.00,84.40,86.10,91.00,92.70,88.00,84.30,82.20,80.80,79.40,80.20,82.20,82.20,81.20,82.10,88.10,88.50,92.10,98.60,100.90,100.60,101.10,102.10,103.60,102.80,108.30,104.00,106.10,106.30,109.00,111.00,113.70,112.70,110.30,114.50,119.30,121.80,125.40,129.70,129.40,134.50,141.20,141.40,152.20,167.70,173.30,168.70,172.60,169.80,172.00,179.40,174.60,172.50,172.60,176.30,178.90,179.60,179.90,180.30,180.90,177.70) > #'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.7883969 0.7886878 0.7889777 0.7892668 0.7895550 0.7898422 0.7901286 [8] 0.7904140 0.7906985 0.7909821 0.7912648 0.7915465 0.7918273 0.7921072 [15] 0.7923861 0.7926641 0.7929412 0.7932173 0.7934925 0.7937667 0.7940400 [22] 0.7943124 0.7945837 0.7948542 0.7951236 0.7953921 0.7956597 0.7959263 [29] 0.7961919 0.7964565 0.7967202 0.7969829 0.7972446 0.7975054 0.7977652 [36] 0.7980240 0.7982818 0.7985386 0.7987944 0.7990493 0.7993031 0.7995560 [43] 0.7998078 0.8000587 0.8003085 0.8005574 0.8008053 0.8010521 0.8012980 [50] 0.8015428 0.8017866 0.8020294 0.8022712 0.8025120 0.8027518 0.8029905 [57] 0.8032282 0.8034649 0.8037006 0.8039352 0.8041688 0.8044014 0.8046330 [64] 0.8048635 0.8050930 0.8053214 0.8055488 0.8057752 0.8060005 0.8062248 [71] 0.8064480 0.8066702 0.8068914 0.8071115 0.8073305 0.8075485 0.8077655 [78] 0.8079814 0.8081962 0.8084100 0.8086227 0.8088344 0.8090450 0.8092545 [85] 0.8094630 0.8096704 0.8098768 0.8100821 0.8102863 0.8104894 0.8106915 [92] 0.8108925 0.8110925 0.8112913 0.8114891 0.8116858 0.8118815 0.8120761 [99] 0.8122696 0.8124620 0.8126533 0.8128436 0.8130328 0.8132209 0.8134079 [106] 0.8135938 0.8137787 0.8139624 0.8141451 0.8143267 0.8145073 0.8146867 [113] 0.8148650 0.8150423 0.8152185 0.8153936 0.8155676 0.8157405 0.8159123 [120] 0.8160830 0.8162527 0.8164212 0.8165887 0.8167550 0.8169203 0.8170845 [127] 0.8172476 0.8174096 0.8175705 0.8177303 0.8178890 0.8180467 0.8182032 [134] 0.8183587 0.8185130 0.8186663 0.8188185 0.8189696 0.8191195 0.8192684 [141] 0.8194162 0.8195629 0.8197086 0.8198531 0.8199965 0.8201389 0.8202801 [148] 0.8204203 0.8205594 0.8206973 0.8208342 0.8209700 0.8211047 0.8212384 [155] 0.8213709 0.8215023 0.8216327 0.8217620 0.8218902 0.8220173 0.8221433 [162] 0.8222682 0.8223920 0.8225148 0.8226365 0.8227571 0.8228766 0.8229950 [169] 0.8231124 0.8232286 0.8233438 0.8234580 0.8235710 0.8236830 0.8237938 [176] 0.8239037 0.8240124 0.8241201 0.8242267 0.8243322 0.8244366 0.8245400 [183] 0.8246423 0.8247436 0.8248438 0.8249429 0.8250410 0.8251380 0.8252339 [190] 0.8253288 0.8254226 0.8255154 0.8256071 0.8256977 0.8257873 0.8258759 [197] 0.8259634 0.8260498 0.8261352 0.8262195 0.8263029 0.8263851 0.8264663 [204] 0.8265465 0.8266257 0.8267038 0.8267808 0.8268569 0.8269319 0.8270058 [211] 0.8270788 0.8271507 0.8272216 0.8272914 0.8273603 0.8274281 0.8274949 [218] 0.8275607 0.8276254 0.8276892 0.8277519 0.8278136 0.8278744 0.8279341 [225] 0.8279928 0.8280505 0.8281072 0.8281629 0.8282176 0.8282713 0.8283240 [232] 0.8283757 0.8284265 0.8284762 0.8285250 0.8285728 0.8286196 0.8286654 [239] 0.8287103 0.8287542 0.8287971 0.8288390 0.8288800 0.8289200 0.8289590 [246] 0.8289971 0.8290342 0.8290704 0.8291056 0.8291398 0.8291731 0.8292055 [253] 0.8292369 0.8292674 0.8292969 0.8293255 0.8293532 0.8293799 0.8294057 [260] 0.8294306 0.8294545 0.8294776 0.8294997 0.8295209 0.8295411 0.8295605 [267] 0.8295789 0.8295965 0.8296131 0.8296289 0.8296437 0.8296576 0.8296707 [274] 0.8296828 0.8296941 0.8297045 0.8297140 0.8297226 0.8297303 0.8297372 [281] 0.8297432 0.8297483 0.8297526 0.8297560 0.8297585 0.8297602 0.8297610 [288] 0.8297609 0.8297601 0.8297583 0.8297557 0.8297523 0.8297481 0.8297430 [295] 0.8297370 0.8297303 0.8297227 0.8297143 0.8297051 0.8296950 0.8296841 [302] 0.8296725 0.8296600 0.8296467 0.8296326 0.8296177 0.8296020 0.8295855 [309] 0.8295682 0.8295502 0.8295313 0.8295117 0.8294913 0.8294701 0.8294481 [316] 0.8294254 0.8294019 0.8293776 0.8293526 0.8293268 0.8293003 0.8292730 [323] 0.8292449 0.8292162 0.8291866 0.8291564 0.8291254 0.8290936 0.8290612 [330] 0.8290280 0.8289941 0.8289595 0.8289241 0.8288880 0.8288513 0.8288138 [337] 0.8287756 0.8287367 0.8286971 0.8286569 0.8286159 0.8285742 0.8285319 [344] 0.8284889 0.8284452 0.8284008 0.8283557 0.8283100 0.8282636 0.8282166 [351] 0.8281689 0.8281205 0.8280715 0.8280218 0.8279715 0.8279206 0.8278690 [358] 0.8278167 0.8277639 0.8277104 0.8276562 0.8276015 0.8275461 0.8274901 [365] 0.8274335 0.8273763 0.8273185 0.8272601 0.8272011 0.8271415 0.8270812 [372] 0.8270204 0.8269590 0.8268971 0.8268345 0.8267714 0.8267076 0.8266434 [379] 0.8265785 0.8265131 0.8264471 0.8263806 0.8263135 0.8262458 0.8261776 [386] 0.8261089 0.8260396 0.8259698 0.8258994 0.8258285 0.8257571 0.8256851 [393] 0.8256126 0.8255396 0.8254661 0.8253921 0.8253176 0.8252425 0.8251670 [400] 0.8250909 0.8250144 > mx [1] 0.829761 > mxli [1] 0.86 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/19pc41194280657.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/2m7361194280657.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/394qr1194280657.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/4b3d01194280657.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/5ko491194280657.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/6eo631194280657.tab") > > system("convert tmp/19pc41194280657.ps tmp/19pc41194280657.png") > system("convert tmp/2m7361194280657.ps tmp/2m7361194280657.png") > system("convert tmp/394qr1194280657.ps tmp/394qr1194280657.png") > system("convert tmp/4b3d01194280657.ps tmp/4b3d01194280657.png") > system("convert tmp/5ko491194280657.ps tmp/5ko491194280657.png") > > > proc.time() user system elapsed 2.377 1.311 2.552