R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(101,101,98.7,96.4,95.6,95.4,98.7,98.7,98.7,99.3,99.5,99.6,100.8,100.8,100.8,101,101.6,102.3,102.3,102.3,102.3,102.4,102.4,102.4,102.4,102.4,102.4,102.4,101.6,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.1,102.1,102.1,102.1,100.7,100.7,100.7,100.7,100.7,100.7,100.7,100.7) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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.4431034 0.4430950 0.4430865 0.4430781 0.4430696 0.4430612 0.4430527 [8] 0.4430442 0.4430357 0.4430272 0.4430187 0.4430102 0.4430016 0.4429931 [15] 0.4429845 0.4429760 0.4429674 0.4429588 0.4429503 0.4429417 0.4429331 [22] 0.4429245 0.4429158 0.4429072 0.4428986 0.4428899 0.4428813 0.4428726 [29] 0.4428640 0.4428553 0.4428466 0.4428379 0.4428292 0.4428205 0.4428118 [36] 0.4428031 0.4427943 0.4427856 0.4427768 0.4427681 0.4427593 0.4427505 [43] 0.4427417 0.4427329 0.4427241 0.4427153 0.4427065 0.4426977 0.4426888 [50] 0.4426800 0.4426711 0.4426623 0.4426534 0.4426445 0.4426357 0.4426268 [57] 0.4426179 0.4426089 0.4426000 0.4425911 0.4425822 0.4425732 0.4425643 [64] 0.4425553 0.4425463 0.4425373 0.4425283 0.4425194 0.4425103 0.4425013 [71] 0.4424923 0.4424833 0.4424742 0.4424652 0.4424561 0.4424471 0.4424380 [78] 0.4424289 0.4424198 0.4424107 0.4424016 0.4423925 0.4423834 0.4423743 [85] 0.4423651 0.4423560 0.4423468 0.4423376 0.4423285 0.4423193 0.4423101 [92] 0.4423009 0.4422917 0.4422825 0.4422733 0.4422640 0.4422548 0.4422455 [99] 0.4422363 0.4422270 0.4422177 0.4422085 0.4421992 0.4421899 0.4421806 [106] 0.4421712 0.4421619 0.4421526 0.4421432 0.4421339 0.4421245 0.4421152 [113] 0.4421058 0.4420964 0.4420870 0.4420776 0.4420682 0.4420588 0.4420494 [120] 0.4420400 0.4420305 0.4420211 0.4420116 0.4420021 0.4419927 0.4419832 [127] 0.4419737 0.4419642 0.4419547 0.4419452 0.4419356 0.4419261 0.4419166 [134] 0.4419070 0.4418975 0.4418879 0.4418783 0.4418687 0.4418592 0.4418496 [141] 0.4418399 0.4418303 0.4418207 0.4418111 0.4418014 0.4417918 0.4417821 [148] 0.4417725 0.4417628 0.4417531 0.4417434 0.4417337 0.4417240 0.4417143 [155] 0.4417046 0.4416949 0.4416851 0.4416754 0.4416656 0.4416558 0.4416461 [162] 0.4416363 0.4416265 0.4416167 0.4416069 0.4415971 0.4415873 0.4415774 [169] 0.4415676 0.4415577 0.4415479 0.4415380 0.4415282 0.4415183 0.4415084 [176] 0.4414985 0.4414886 0.4414787 0.4414688 0.4414588 0.4414489 0.4414389 [183] 0.4414290 0.4414190 0.4414091 0.4413991 0.4413891 0.4413791 0.4413691 [190] 0.4413591 0.4413491 0.4413390 0.4413290 0.4413190 0.4413089 0.4412989 [197] 0.4412888 0.4412787 0.4412686 0.4412585 0.4412484 0.4412383 0.4412282 [204] 0.4412181 0.4412079 0.4411978 0.4411877 0.4411775 0.4411673 0.4411572 [211] 0.4411470 0.4411368 0.4411266 0.4411164 0.4411062 0.4410959 0.4410857 [218] 0.4410755 0.4410652 0.4410550 0.4410447 0.4410344 0.4410241 0.4410139 [225] 0.4410036 0.4409933 0.4409829 0.4409726 0.4409623 0.4409520 0.4409416 [232] 0.4409313 0.4409209 0.4409105 0.4409001 0.4408898 0.4408794 0.4408690 [239] 0.4408586 0.4408481 0.4408377 0.4408273 0.4408168 0.4408064 0.4407959 [246] 0.4407855 0.4407750 0.4407645 0.4407540 0.4407435 0.4407330 0.4407225 [253] 0.4407120 0.4407014 0.4406909 0.4406803 0.4406698 0.4406592 0.4406487 [260] 0.4406381 0.4406275 0.4406169 0.4406063 0.4405957 0.4405851 0.4405744 [267] 0.4405638 0.4405531 0.4405425 0.4405318 0.4405212 0.4405105 0.4404998 [274] 0.4404891 0.4404784 0.4404677 0.4404570 0.4404463 0.4404355 0.4404248 [281] 0.4404140 0.4404033 0.4403925 0.4403818 0.4403710 0.4403602 0.4403494 [288] 0.4403386 0.4403278 0.4403169 0.4403061 0.4402953 0.4402844 0.4402736 [295] 0.4402627 0.4402519 0.4402410 0.4402301 0.4402192 0.4402083 0.4401974 [302] 0.4401865 0.4401756 0.4401646 0.4401537 0.4401427 0.4401318 0.4401208 [309] 0.4401098 0.4400989 0.4400879 0.4400769 0.4400659 0.4400549 0.4400438 [316] 0.4400328 0.4400218 0.4400107 0.4399997 0.4399886 0.4399776 0.4399665 [323] 0.4399554 0.4399443 0.4399332 0.4399221 0.4399110 0.4398999 0.4398887 [330] 0.4398776 0.4398665 0.4398553 0.4398441 0.4398330 0.4398218 0.4398106 [337] 0.4397994 0.4397882 0.4397770 0.4397658 0.4397546 0.4397433 0.4397321 [344] 0.4397208 0.4397096 0.4396983 0.4396870 0.4396758 0.4396645 0.4396532 [351] 0.4396419 0.4396306 0.4396192 0.4396079 0.4395966 0.4395852 0.4395739 [358] 0.4395625 0.4395511 0.4395398 0.4395284 0.4395170 0.4395056 0.4394942 [365] 0.4394828 0.4394714 0.4394599 0.4394485 0.4394370 0.4394256 0.4394141 [372] 0.4394027 0.4393912 0.4393797 0.4393682 0.4393567 0.4393452 0.4393337 [379] 0.4393222 0.4393106 0.4392991 0.4392875 0.4392760 0.4392644 0.4392529 [386] 0.4392413 0.4392297 0.4392181 0.4392065 0.4391949 0.4391833 0.4391717 [393] 0.4391600 0.4391484 0.4391367 0.4391251 0.4391134 0.4391017 0.4390901 [400] 0.4390784 0.4390667 > mx [1] 0.4431034 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1kr881257940796.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/2bgi31257940796.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/36h3u1257940796.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/42syv1257940796.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x) > qqline(x) > grid() > mtext('Original Data') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/5zfzd1257940796.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x1) > qqline(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/6f3ef1257940796.tab") > > system("convert tmp/1kr881257940796.ps tmp/1kr881257940796.png") > system("convert tmp/2bgi31257940796.ps tmp/2bgi31257940796.png") > system("convert tmp/36h3u1257940796.ps tmp/36h3u1257940796.png") > system("convert tmp/42syv1257940796.ps tmp/42syv1257940796.png") > system("convert tmp/5zfzd1257940796.ps tmp/5zfzd1257940796.png") > > > proc.time() user system elapsed 1.064 0.783 1.332