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(112.7,118.4,108.1,105.4,114.6,106.9,115.9,109.8,101.8,114.2,110.8,108.4,127.5,128.6,116.6,127.4,105,108.3,125,111.6,106.5,130.3,115,116.1,134,126.5,125.8,136.4,114.9,110.9,125.5,116.8,116.8,125.5,104.2,115.1,132.8,123.3,124.8,122,117.4,117.9,137.4,114.6,124.7,129.6,109.4,120.9,134.9,136.3,133.2,127.2,122.7,120.5,137.8,119.1,124.3,134.3,121.7,125) > #'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.5103275 0.5103161 0.5103047 0.5102931 0.5102814 0.5102696 0.5102577 [8] 0.5102457 0.5102336 0.5102214 0.5102090 0.5101966 0.5101840 0.5101714 [15] 0.5101586 0.5101457 0.5101327 0.5101195 0.5101063 0.5100930 0.5100795 [22] 0.5100660 0.5100523 0.5100385 0.5100246 0.5100106 0.5099965 0.5099823 [29] 0.5099679 0.5099535 0.5099389 0.5099242 0.5099095 0.5098946 0.5098796 [36] 0.5098645 0.5098492 0.5098339 0.5098184 0.5098029 0.5097872 0.5097714 [43] 0.5097556 0.5097396 0.5097235 0.5097072 0.5096909 0.5096745 0.5096579 [50] 0.5096413 0.5096245 0.5096076 0.5095906 0.5095735 0.5095563 0.5095390 [57] 0.5095216 0.5095040 0.5094864 0.5094686 0.5094507 0.5094328 0.5094147 [64] 0.5093965 0.5093782 0.5093597 0.5093412 0.5093226 0.5093038 0.5092850 [71] 0.5092660 0.5092469 0.5092277 0.5092084 0.5091890 0.5091695 0.5091499 [78] 0.5091302 0.5091103 0.5090904 0.5090703 0.5090501 0.5090298 0.5090095 [85] 0.5089890 0.5089683 0.5089476 0.5089268 0.5089059 0.5088848 0.5088637 [92] 0.5088424 0.5088210 0.5087995 0.5087780 0.5087563 0.5087345 0.5087125 [99] 0.5086905 0.5086684 0.5086461 0.5086238 0.5086013 0.5085788 0.5085561 [106] 0.5085333 0.5085104 0.5084874 0.5084643 0.5084411 0.5084178 0.5083943 [113] 0.5083708 0.5083471 0.5083234 0.5082995 0.5082755 0.5082514 0.5082273 [120] 0.5082030 0.5081786 0.5081540 0.5081294 0.5081047 0.5080799 0.5080549 [127] 0.5080299 0.5080047 0.5079794 0.5079541 0.5079286 0.5079030 0.5078773 [134] 0.5078515 0.5078256 0.5077996 0.5077734 0.5077472 0.5077209 0.5076944 [141] 0.5076679 0.5076412 0.5076145 0.5075876 0.5075606 0.5075335 0.5075063 [148] 0.5074790 0.5074516 0.5074241 0.5073965 0.5073688 0.5073409 0.5073130 [155] 0.5072850 0.5072568 0.5072285 0.5072002 0.5071717 0.5071431 0.5071145 [162] 0.5070857 0.5070568 0.5070278 0.5069987 0.5069695 0.5069402 0.5069108 [169] 0.5068812 0.5068516 0.5068219 0.5067920 0.5067621 0.5067320 0.5067019 [176] 0.5066716 0.5066412 0.5066108 0.5065802 0.5065495 0.5065187 0.5064878 [183] 0.5064568 0.5064257 0.5063945 0.5063632 0.5063318 0.5063003 0.5062687 [190] 0.5062369 0.5062051 0.5061732 0.5061411 0.5061090 0.5060768 0.5060444 [197] 0.5060119 0.5059794 0.5059467 0.5059140 0.5058811 0.5058481 0.5058150 [204] 0.5057819 0.5057486 0.5057152 0.5056817 0.5056481 0.5056144 0.5055806 [211] 0.5055467 0.5055127 0.5054786 0.5054444 0.5054101 0.5053756 0.5053411 [218] 0.5053065 0.5052718 0.5052370 0.5052020 0.5051670 0.5051319 0.5050966 [225] 0.5050613 0.5050258 0.5049903 0.5049547 0.5049189 0.5048831 0.5048471 [232] 0.5048111 0.5047749 0.5047386 0.5047023 0.5046658 0.5046293 0.5045926 [239] 0.5045559 0.5045190 0.5044820 0.5044450 0.5044078 0.5043705 0.5043332 [246] 0.5042957 0.5042581 0.5042205 0.5041827 0.5041448 0.5041068 0.5040688 [253] 0.5040306 0.5039923 0.5039540 0.5039155 0.5038769 0.5038383 0.5037995 [260] 0.5037606 0.5037216 0.5036826 0.5036434 0.5036041 0.5035648 0.5035253 [267] 0.5034857 0.5034461 0.5034063 0.5033664 0.5033265 0.5032864 0.5032463 [274] 0.5032060 0.5031656 0.5031252 0.5030846 0.5030440 0.5030032 0.5029624 [281] 0.5029214 0.5028804 0.5028392 0.5027980 0.5027567 0.5027152 0.5026737 [288] 0.5026321 0.5025903 0.5025485 0.5025066 0.5024645 0.5024224 0.5023802 [295] 0.5023379 0.5022955 0.5022530 0.5022104 0.5021677 0.5021249 0.5020820 [302] 0.5020390 0.5019959 0.5019527 0.5019094 0.5018661 0.5018226 0.5017790 [309] 0.5017354 0.5016916 0.5016478 0.5016038 0.5015598 0.5015156 0.5014714 [316] 0.5014270 0.5013826 0.5013381 0.5012935 0.5012488 0.5012039 0.5011590 [323] 0.5011140 0.5010690 0.5010238 0.5009785 0.5009331 0.5008876 0.5008421 [330] 0.5007964 0.5007507 0.5007048 0.5006589 0.5006128 0.5005667 0.5005205 [337] 0.5004742 0.5004278 0.5003813 0.5003347 0.5002880 0.5002412 0.5001943 [344] 0.5001473 0.5001003 0.5000531 0.5000059 0.4999585 0.4999111 0.4998636 [351] 0.4998160 0.4997682 0.4997204 0.4996726 0.4996246 0.4995765 0.4995283 [358] 0.4994801 0.4994317 0.4993833 0.4993347 0.4992861 0.4992374 0.4991886 [365] 0.4991397 0.4990907 0.4990416 0.4989924 0.4989432 0.4988938 0.4988444 [372] 0.4987948 0.4987452 0.4986955 0.4986457 0.4985958 0.4985458 0.4984957 [379] 0.4984455 0.4983953 0.4983449 0.4982945 0.4982440 0.4981934 0.4981427 [386] 0.4980919 0.4980410 0.4979900 0.4979390 0.4978878 0.4978366 0.4977853 [393] 0.4977338 0.4976823 0.4976308 0.4975791 0.4975273 0.4974755 0.4974235 [400] 0.4973715 0.4973194 > mx [1] 0.5103275 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1mquw1193928051.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/2owty1193928051.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/3ybqi1193928051.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/4d7f01193928051.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/5kma31193928051.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/6o0801193928051.tab") > > system("convert tmp/1mquw1193928051.ps tmp/1mquw1193928051.png") > system("convert tmp/2owty1193928051.ps tmp/2owty1193928051.png") > system("convert tmp/3ybqi1193928051.ps tmp/3ybqi1193928051.png") > system("convert tmp/4d7f01193928051.ps tmp/4d7f01193928051.png") > system("convert tmp/5kma31193928051.ps tmp/5kma31193928051.png") > > > proc.time() user system elapsed 1.339 0.811 1.515