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.9383,0.9217,0.9095,0.892,0.8742,0.8532,0.8607,0.9005,0.9111,0.9059,0.8883,0.8924,0.8833,0.87,0.8758,0.8858,0.917,0.9554,0.9922,0.9778,0.9808,0.9811,1.0014,1.0183,1.0622,1.0773,1.0807,1.0848,1.1582,1.1663,1.1372,1.1139,1.1222,1.1692,1.1702,1.2286,1.2613,1.2646,1.2262,1.1985,1.2007,1.2138,1.2266,1.2176,1.2218,1.249,1.2991,1.3408,1.3119,1.3014,1.3201,1.2938,1.2694,1.2165,1.2037,1.2292,1.2256,1.2015,1.1786,1.1856,1.2103,1.1938,1.202,1.2271,1.277,1.265,1.2684,1.2811,1.2727,1.2611,1.2881,1.3213) > #'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.8416552 0.8417310 0.8418067 0.8418821 0.8419574 0.8420325 0.8421075 [8] 0.8421822 0.8422568 0.8423312 0.8424055 0.8424795 0.8425534 0.8426271 [15] 0.8427006 0.8427740 0.8428472 0.8429202 0.8429930 0.8430656 0.8431381 [22] 0.8432104 0.8432825 0.8433545 0.8434262 0.8434978 0.8435692 0.8436404 [29] 0.8437114 0.8437823 0.8438530 0.8439235 0.8439938 0.8440639 0.8441339 [36] 0.8442036 0.8442732 0.8443426 0.8444118 0.8444809 0.8445497 0.8446184 [43] 0.8446869 0.8447552 0.8448233 0.8448912 0.8449590 0.8450266 0.8450940 [50] 0.8451611 0.8452282 0.8452950 0.8453616 0.8454281 0.8454943 0.8455604 [57] 0.8456263 0.8456920 0.8457575 0.8458229 0.8458880 0.8459530 0.8460177 [64] 0.8460823 0.8461467 0.8462109 0.8462749 0.8463387 0.8464023 0.8464658 [71] 0.8465290 0.8465921 0.8466549 0.8467176 0.8467801 0.8468424 0.8469045 [78] 0.8469664 0.8470281 0.8470896 0.8471510 0.8472121 0.8472730 0.8473338 [85] 0.8473943 0.8474547 0.8475149 0.8475748 0.8476346 0.8476942 0.8477536 [92] 0.8478128 0.8478718 0.8479306 0.8479892 0.8480476 0.8481058 0.8481638 [99] 0.8482216 0.8482793 0.8483367 0.8483939 0.8484509 0.8485078 0.8485644 [106] 0.8486208 0.8486771 0.8487331 0.8487889 0.8488446 0.8489000 0.8489552 [113] 0.8490103 0.8490651 0.8491197 0.8491742 0.8492284 0.8492824 0.8493362 [120] 0.8493899 0.8494433 0.8494965 0.8495495 0.8496024 0.8496550 0.8497074 [127] 0.8497596 0.8498116 0.8498634 0.8499150 0.8499664 0.8500176 0.8500686 [134] 0.8501193 0.8501699 0.8502203 0.8502704 0.8503204 0.8503701 0.8504197 [141] 0.8504690 0.8505182 0.8505671 0.8506158 0.8506643 0.8507126 0.8507607 [148] 0.8508086 0.8508563 0.8509038 0.8509510 0.8509981 0.8510449 0.8510916 [155] 0.8511380 0.8511842 0.8512302 0.8512760 0.8513216 0.8513670 0.8514122 [162] 0.8514572 0.8515019 0.8515464 0.8515908 0.8516349 0.8516788 0.8517225 [169] 0.8517660 0.8518092 0.8518523 0.8518951 0.8519378 0.8519802 0.8520224 [176] 0.8520644 0.8521062 0.8521478 0.8521891 0.8522302 0.8522712 0.8523119 [183] 0.8523524 0.8523927 0.8524327 0.8524726 0.8525122 0.8525516 0.8525909 [190] 0.8526298 0.8526686 0.8527072 0.8527455 0.8527836 0.8528216 0.8528593 [197] 0.8528967 0.8529340 0.8529710 0.8530079 0.8530445 0.8530808 0.8531170 [204] 0.8531530 0.8531887 0.8532242 0.8532595 0.8532946 0.8533295 0.8533641 [211] 0.8533985 0.8534327 0.8534667 0.8535005 0.8535340 0.8535673 0.8536004 [218] 0.8536333 0.8536660 0.8536984 0.8537306 0.8537626 0.8537944 0.8538260 [225] 0.8538573 0.8538884 0.8539193 0.8539500 0.8539804 0.8540106 0.8540407 [232] 0.8540704 0.8541000 0.8541293 0.8541584 0.8541873 0.8542160 0.8542444 [239] 0.8542726 0.8543006 0.8543284 0.8543559 0.8543833 0.8544104 0.8544372 [246] 0.8544639 0.8544903 0.8545165 0.8545425 0.8545682 0.8545938 0.8546190 [253] 0.8546441 0.8546690 0.8546936 0.8547180 0.8547421 0.8547661 0.8547898 [260] 0.8548133 0.8548366 0.8548596 0.8548824 0.8549050 0.8549273 0.8549495 [267] 0.8549714 0.8549930 0.8550145 0.8550357 0.8550567 0.8550774 0.8550980 [274] 0.8551183 0.8551384 0.8551582 0.8551778 0.8551972 0.8552164 0.8552353 [281] 0.8552540 0.8552725 0.8552907 0.8553087 0.8553265 0.8553441 0.8553614 [288] 0.8553785 0.8553954 0.8554120 0.8554284 0.8554446 0.8554605 0.8554762 [295] 0.8554917 0.8555070 0.8555220 0.8555368 0.8555514 0.8555657 0.8555798 [302] 0.8555936 0.8556073 0.8556207 0.8556339 0.8556468 0.8556595 0.8556720 [309] 0.8556842 0.8556962 0.8557080 0.8557196 0.8557309 0.8557420 0.8557528 [316] 0.8557634 0.8557738 0.8557840 0.8557939 0.8558036 0.8558130 0.8558223 [323] 0.8558313 0.8558400 0.8558485 0.8558568 0.8558649 0.8558727 0.8558803 [330] 0.8558876 0.8558948 0.8559016 0.8559083 0.8559147 0.8559209 0.8559268 [337] 0.8559326 0.8559380 0.8559433 0.8559483 0.8559531 0.8559576 0.8559619 [344] 0.8559660 0.8559698 0.8559734 0.8559768 0.8559799 0.8559828 0.8559855 [351] 0.8559879 0.8559901 0.8559921 0.8559938 0.8559953 0.8559965 0.8559975 [358] 0.8559983 0.8559989 0.8559992 0.8559993 0.8559991 0.8559987 0.8559981 [365] 0.8559972 0.8559961 0.8559947 0.8559932 0.8559913 0.8559893 0.8559870 [372] 0.8559845 0.8559817 0.8559787 0.8559755 0.8559720 0.8559683 0.8559644 [379] 0.8559602 0.8559558 0.8559511 0.8559463 0.8559411 0.8559358 0.8559302 [386] 0.8559243 0.8559183 0.8559120 0.8559054 0.8558986 0.8558916 0.8558844 [393] 0.8558769 0.8558691 0.8558612 0.8558530 0.8558445 0.8558358 0.8558269 [400] 0.8558178 0.8558084 > mx [1] 0.8559993 > mxli [1] 1.6 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/12y4k1197398842.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/2d3eq1197398842.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/3qjiw1197398842.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/46pd61197398842.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/5nuyu1197398842.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/6ppf11197398842.tab") > > system("convert tmp/12y4k1197398842.ps tmp/12y4k1197398842.png") > system("convert tmp/2d3eq1197398842.ps tmp/2d3eq1197398842.png") > system("convert tmp/3qjiw1197398842.ps tmp/3qjiw1197398842.png") > system("convert tmp/46pd61197398842.ps tmp/46pd61197398842.png") > system("convert tmp/5nuyu1197398842.ps tmp/5nuyu1197398842.png") > > > proc.time() user system elapsed 1.335 0.786 1.577