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(8.7,8.5,8.2,8.3,8,8.1,8.7,9.3,8.9,8.8,8.4,8.4,7.3,7.2,7,7,6.9,6.9,7.1,7.5,7.4,8.9,8.3,8.3,9,8.9,8.8,7.8,7.8,7.8,9.2,9.3,9.2,8.6,8.5,8.5,9,9,8.8,8,7.9,8.1,9.3,9.4,9.4,9.3,9,9.1,9.7,9.7,9.6,8.3,8.2,8.4,10.6,10.9,10.9,9.6,9.3,9.3,9.6,9.5,9.5,9,8.9,9,10.1,10.2,10.2,9.5,9.3,9.3,9.4,9.3,9.1,9,8.9,9,9.8,10,9.8,9.4,9,8.9,9.3,9.1,8.8,8.9,8.7,8.6,9.1,9.3,8.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.4812592 0.4812971 0.4813346 0.4813719 0.4814088 0.4814455 0.4814818 [8] 0.4815179 0.4815536 0.4815891 0.4816242 0.4816590 0.4816936 0.4817278 [15] 0.4817617 0.4817953 0.4818287 0.4818617 0.4818944 0.4819267 0.4819588 [22] 0.4819906 0.4820221 0.4820532 0.4820841 0.4821146 0.4821448 0.4821747 [29] 0.4822043 0.4822336 0.4822626 0.4822913 0.4823196 0.4823477 0.4823754 [36] 0.4824028 0.4824299 0.4824567 0.4824831 0.4825093 0.4825351 0.4825606 [43] 0.4825858 0.4826107 0.4826353 0.4826595 0.4826835 0.4827071 0.4827303 [50] 0.4827533 0.4827760 0.4827983 0.4828203 0.4828420 0.4828633 0.4828844 [57] 0.4829051 0.4829255 0.4829455 0.4829653 0.4829847 0.4830038 0.4830226 [64] 0.4830410 0.4830591 0.4830769 0.4830944 0.4831115 0.4831283 0.4831448 [71] 0.4831610 0.4831768 0.4831923 0.4832074 0.4832223 0.4832368 0.4832510 [78] 0.4832648 0.4832783 0.4832915 0.4833043 0.4833169 0.4833290 0.4833409 [85] 0.4833524 0.4833636 0.4833744 0.4833849 0.4833951 0.4834050 0.4834145 [92] 0.4834236 0.4834325 0.4834410 0.4834491 0.4834570 0.4834644 0.4834716 [99] 0.4834784 0.4834849 0.4834910 0.4834968 0.4835022 0.4835074 0.4835121 [106] 0.4835166 0.4835206 0.4835244 0.4835278 0.4835309 0.4835336 0.4835360 [113] 0.4835380 0.4835397 0.4835410 0.4835420 0.4835427 0.4835430 0.4835430 [120] 0.4835426 0.4835419 0.4835408 0.4835394 0.4835376 0.4835355 0.4835331 [127] 0.4835303 0.4835271 0.4835236 0.4835198 0.4835156 0.4835110 0.4835061 [134] 0.4835009 0.4834953 0.4834894 0.4834831 0.4834764 0.4834694 0.4834621 [141] 0.4834544 0.4834463 0.4834379 0.4834292 0.4834201 0.4834106 0.4834008 [148] 0.4833906 0.4833801 0.4833692 0.4833580 0.4833464 0.4833345 0.4833222 [155] 0.4833095 0.4832965 0.4832832 0.4832694 0.4832554 0.4832409 0.4832262 [162] 0.4832110 0.4831955 0.4831796 0.4831634 0.4831469 0.4831299 0.4831126 [169] 0.4830950 0.4830770 0.4830586 0.4830399 0.4830208 0.4830013 0.4829815 [176] 0.4829614 0.4829408 0.4829200 0.4828987 0.4828771 0.4828551 0.4828328 [183] 0.4828101 0.4827870 0.4827636 0.4827398 0.4827157 0.4826912 0.4826663 [190] 0.4826411 0.4826155 0.4825895 0.4825632 0.4825365 0.4825094 0.4824820 [197] 0.4824542 0.4824261 0.4823976 0.4823687 0.4823395 0.4823098 0.4822799 [204] 0.4822495 0.4822188 0.4821878 0.4821563 0.4821245 0.4820923 0.4820598 [211] 0.4820269 0.4819936 0.4819600 0.4819260 0.4818916 0.4818569 0.4818217 [218] 0.4817863 0.4817504 0.4817142 0.4816776 0.4816407 0.4816033 0.4815657 [225] 0.4815276 0.4814892 0.4814504 0.4814112 0.4813717 0.4813318 0.4812915 [232] 0.4812508 0.4812098 0.4811684 0.4811267 0.4810846 0.4810421 0.4809992 [239] 0.4809560 0.4809124 0.4808684 0.4808240 0.4807793 0.4807342 0.4806888 [246] 0.4806429 0.4805967 0.4805501 0.4805032 0.4804559 0.4804082 0.4803601 [253] 0.4803117 0.4802629 0.4802137 0.4801641 0.4801142 0.4800639 0.4800132 [260] 0.4799622 0.4799108 0.4798590 0.4798068 0.4797543 0.4797014 0.4796481 [267] 0.4795945 0.4795404 0.4794860 0.4794313 0.4793761 0.4793206 0.4792647 [274] 0.4792085 0.4791518 0.4790948 0.4790374 0.4789797 0.4789216 0.4788631 [281] 0.4788042 0.4787449 0.4786853 0.4786253 0.4785650 0.4785042 0.4784431 [288] 0.4783816 0.4783198 0.4782575 0.4781949 0.4781319 0.4780686 0.4780048 [295] 0.4779407 0.4778763 0.4778114 0.4777462 0.4776806 0.4776146 0.4775483 [302] 0.4774816 0.4774145 0.4773470 0.4772792 0.4772110 0.4771424 0.4770734 [309] 0.4770041 0.4769344 0.4768643 0.4767939 0.4767231 0.4766519 0.4765803 [316] 0.4765084 0.4764361 0.4763634 0.4762903 0.4762169 0.4761431 0.4760689 [323] 0.4759944 0.4759194 0.4758441 0.4757685 0.4756924 0.4756160 0.4755393 [330] 0.4754621 0.4753846 0.4753067 0.4752284 0.4751498 0.4750708 0.4749914 [337] 0.4749116 0.4748315 0.4747510 0.4746701 0.4745889 0.4745073 0.4744253 [344] 0.4743429 0.4742602 0.4741771 0.4740937 0.4740098 0.4739256 0.4738411 [351] 0.4737561 0.4736708 0.4735851 0.4734991 0.4734127 0.4733259 0.4732387 [358] 0.4731512 0.4730633 0.4729750 0.4728864 0.4727974 0.4727080 0.4726183 [365] 0.4725282 0.4724377 0.4723468 0.4722556 0.4721641 0.4720721 0.4719798 [372] 0.4718871 0.4717941 0.4717007 0.4716069 0.4715127 0.4714182 0.4713233 [379] 0.4712281 0.4711325 0.4710365 0.4709402 0.4708435 0.4707464 0.4706490 [386] 0.4705512 0.4704530 0.4703545 0.4702556 0.4701564 0.4700567 0.4699568 [393] 0.4698564 0.4697557 0.4696546 0.4695532 0.4694514 0.4693493 0.4692468 [400] 0.4691439 0.4690406 > mx [1] 0.483543 > mxli [1] -0.83 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1nfge1194263013.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/2tkk51194263013.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/3to7z1194263013.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/4uz1l1194263014.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/5ev5p1194263014.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/6qmsg1194263014.tab") > > system("convert tmp/1nfge1194263013.ps tmp/1nfge1194263013.png") > system("convert tmp/2tkk51194263013.ps tmp/2tkk51194263013.png") > system("convert tmp/3to7z1194263013.ps tmp/3to7z1194263013.png") > system("convert tmp/4uz1l1194263014.ps tmp/4uz1l1194263014.png") > system("convert tmp/5ev5p1194263014.ps tmp/5ev5p1194263014.png") > > > proc.time() user system elapsed 1.312 0.786 1.536