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(61.2,82.4,85.4,78.2,70.2,70.2,69.3,77.5,66.1,69,75.3,58.2,59.7) > #'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.4476859 -0.4477200 -0.4477542 -0.4477883 -0.4478225 -0.4478566 [7] -0.4478908 -0.4479250 -0.4479591 -0.4479933 -0.4480274 -0.4480616 [13] -0.4480958 -0.4481299 -0.4481641 -0.4481983 -0.4482324 -0.4482666 [19] -0.4483008 -0.4483350 -0.4483691 -0.4484033 -0.4484375 -0.4484717 [25] -0.4485058 -0.4485400 -0.4485742 -0.4486083 -0.4486425 -0.4486767 [31] -0.4487108 -0.4487450 -0.4487792 -0.4488133 -0.4488475 -0.4488816 [37] -0.4489158 -0.4489499 -0.4489841 -0.4490182 -0.4490524 -0.4490865 [43] -0.4491206 -0.4491548 -0.4491889 -0.4492230 -0.4492571 -0.4492912 [49] -0.4493253 -0.4493594 -0.4493935 -0.4494276 -0.4494617 -0.4494958 [55] -0.4495299 -0.4495639 -0.4495980 -0.4496321 -0.4496661 -0.4497001 [61] -0.4497342 -0.4497682 -0.4498022 -0.4498362 -0.4498703 -0.4499043 [67] -0.4499382 -0.4499722 -0.4500062 -0.4500402 -0.4500741 -0.4501081 [73] -0.4501420 -0.4501759 -0.4502099 -0.4502438 -0.4502777 -0.4503116 [79] -0.4503455 -0.4503793 -0.4504132 -0.4504471 -0.4504809 -0.4505147 [85] -0.4505485 -0.4505824 -0.4506161 -0.4506499 -0.4506837 -0.4507175 [91] -0.4507512 -0.4507850 -0.4508187 -0.4508524 -0.4508861 -0.4509198 [97] -0.4509535 -0.4509871 -0.4510208 -0.4510544 -0.4510880 -0.4511216 [103] -0.4511552 -0.4511888 -0.4512224 -0.4512559 -0.4512894 -0.4513230 [109] -0.4513565 -0.4513900 -0.4514234 -0.4514569 -0.4514903 -0.4515238 [115] -0.4515572 -0.4515906 -0.4516239 -0.4516573 -0.4516906 -0.4517240 [121] -0.4517573 -0.4517906 -0.4518239 -0.4518571 -0.4518903 -0.4519236 [127] -0.4519568 -0.4519900 -0.4520231 -0.4520563 -0.4520894 -0.4521225 [133] -0.4521556 -0.4521887 -0.4522217 -0.4522548 -0.4522878 -0.4523208 [139] -0.4523537 -0.4523867 -0.4524196 -0.4524525 -0.4524854 -0.4525183 [145] -0.4525512 -0.4525840 -0.4526168 -0.4526496 -0.4526823 -0.4527151 [151] -0.4527478 -0.4527805 -0.4528132 -0.4528458 -0.4528784 -0.4529111 [157] -0.4529436 -0.4529762 -0.4530087 -0.4530412 -0.4530737 -0.4531062 [163] -0.4531386 -0.4531711 -0.4532035 -0.4532358 -0.4532682 -0.4533005 [169] -0.4533328 -0.4533650 -0.4533973 -0.4534295 -0.4534617 -0.4534939 [175] -0.4535260 -0.4535581 -0.4535902 -0.4536223 -0.4536543 -0.4536863 [181] -0.4537183 -0.4537503 -0.4537822 -0.4538141 -0.4538460 -0.4538778 [187] -0.4539096 -0.4539414 -0.4539732 -0.4540049 -0.4540366 -0.4540683 [193] -0.4540999 -0.4541316 -0.4541631 -0.4541947 -0.4542262 -0.4542577 [199] -0.4542892 -0.4543207 -0.4543521 -0.4543834 -0.4544148 -0.4544461 [205] -0.4544774 -0.4545087 -0.4545399 -0.4545711 -0.4546023 -0.4546334 [211] -0.4546645 -0.4546956 -0.4547266 -0.4547576 -0.4547886 -0.4548196 [217] -0.4548505 -0.4548814 -0.4549122 -0.4549430 -0.4549738 -0.4550046 [223] -0.4550353 -0.4550660 -0.4550966 -0.4551272 -0.4551578 -0.4551884 [229] -0.4552189 -0.4552493 -0.4552798 -0.4553102 -0.4553406 -0.4553709 [235] -0.4554012 -0.4554315 -0.4554617 -0.4554919 -0.4555221 -0.4555522 [241] -0.4555823 -0.4556124 -0.4556424 -0.4556724 -0.4557024 -0.4557323 [247] -0.4557622 -0.4557920 -0.4558218 -0.4558516 -0.4558813 -0.4559110 [253] -0.4559406 -0.4559703 -0.4559998 -0.4560294 -0.4560589 -0.4560884 [259] -0.4561178 -0.4561472 -0.4561765 -0.4562059 -0.4562351 -0.4562644 [265] -0.4562936 -0.4563227 -0.4563518 -0.4563809 -0.4564100 -0.4564390 [271] -0.4564679 -0.4564968 -0.4565257 -0.4565546 -0.4565834 -0.4566121 [277] -0.4566408 -0.4566695 -0.4566982 -0.4567268 -0.4567553 -0.4567838 [283] -0.4568123 -0.4568407 -0.4568691 -0.4568975 -0.4569258 -0.4569541 [289] -0.4569823 -0.4570105 -0.4570386 -0.4570667 -0.4570948 -0.4571228 [295] -0.4571507 -0.4571787 -0.4572066 -0.4572344 -0.4572622 -0.4572899 [301] -0.4573177 -0.4573453 -0.4573730 -0.4574005 -0.4574281 -0.4574556 [307] -0.4574830 -0.4575104 -0.4575378 -0.4575651 -0.4575924 -0.4576196 [313] -0.4576468 -0.4576739 -0.4577010 -0.4577280 -0.4577550 -0.4577820 [319] -0.4578089 -0.4578358 -0.4578626 -0.4578894 -0.4579161 -0.4579428 [325] -0.4579694 -0.4579960 -0.4580225 -0.4580490 -0.4580755 -0.4581019 [331] -0.4581282 -0.4581545 -0.4581808 -0.4582070 -0.4582332 -0.4582593 [337] -0.4582854 -0.4583114 -0.4583374 -0.4583633 -0.4583892 -0.4584150 [343] -0.4584408 -0.4584666 -0.4584922 -0.4585179 -0.4585435 -0.4585690 [349] -0.4585945 -0.4586200 -0.4586454 -0.4586707 -0.4586960 -0.4587213 [355] -0.4587465 -0.4587716 -0.4587967 -0.4588218 -0.4588468 -0.4588717 [361] -0.4588966 -0.4589215 -0.4589463 -0.4589710 -0.4589957 -0.4590204 [367] -0.4590450 -0.4590696 -0.4590941 -0.4591185 -0.4591429 -0.4591673 [373] -0.4591916 -0.4592158 -0.4592400 -0.4592642 -0.4592882 -0.4593123 [379] -0.4593363 -0.4593602 -0.4593841 -0.4594080 -0.4594317 -0.4594555 [385] -0.4594791 -0.4595028 -0.4595264 -0.4595499 -0.4595734 -0.4595968 [391] -0.4596201 -0.4596435 -0.4596667 -0.4596899 -0.4597131 -0.4597362 [397] -0.4597592 -0.4597822 -0.4598052 -0.4598281 -0.4598509 > mx [1] 0 > mxli [1] -999 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1djvj1194108816.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/2flp31194108816.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/3sj1v1194108816.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/4qafi1194108816.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/5ej3f1194108816.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/6rj7c1194108816.tab") > > system("convert tmp/1djvj1194108816.ps tmp/1djvj1194108816.png") > system("convert tmp/2flp31194108816.ps tmp/2flp31194108816.png") > system("convert tmp/3sj1v1194108816.ps tmp/3sj1v1194108816.png") > system("convert tmp/4qafi1194108816.ps tmp/4qafi1194108816.png") > system("convert tmp/5ej3f1194108816.ps tmp/5ej3f1194108816.png") > > > proc.time() user system elapsed 1.322 0.789 1.508