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(106.7,100.6,101.2,93.1,84.2,85.8,91.8,92.4,80.3,79.7,62.5,57.1,100.8,100.7,86.2,83.2,71.7,77.5,89.8,80.3,78.7,93.8,57.6,60.6,91.0,85.3,77.4,77.3,68.3,69.9,81.7,75.1,69.9,84.0,54.3,60.0,89.9,77.0,85.3,77.6,69.2,75.5,85.7,72.2,79.9,85.3,52.2,61.2,82.4,85.4,78.2,70.2,70.2,69.3,77.5,66.1,69.0,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.4522824 -0.4526721 -0.4530617 -0.4534513 -0.4538407 -0.4542302 [7] -0.4546195 -0.4550088 -0.4553981 -0.4557872 -0.4561763 -0.4565653 [13] -0.4569543 -0.4573432 -0.4577319 -0.4581206 -0.4585093 -0.4588978 [19] -0.4592863 -0.4596746 -0.4600629 -0.4604511 -0.4608392 -0.4612272 [25] -0.4616150 -0.4620028 -0.4623905 -0.4627781 -0.4631656 -0.4635529 [31] -0.4639402 -0.4643273 -0.4647143 -0.4651013 -0.4654880 -0.4658747 [37] -0.4662612 -0.4666477 -0.4670340 -0.4674201 -0.4678061 -0.4681920 [43] -0.4685778 -0.4689634 -0.4693489 -0.4697342 -0.4701194 -0.4705045 [49] -0.4708894 -0.4712742 -0.4716588 -0.4720432 -0.4724275 -0.4728116 [55] -0.4731956 -0.4735794 -0.4739631 -0.4743465 -0.4747299 -0.4751130 [61] -0.4754960 -0.4758788 -0.4762614 -0.4766438 -0.4770261 -0.4774082 [67] -0.4777900 -0.4781717 -0.4785533 -0.4789346 -0.4793157 -0.4796966 [73] -0.4800774 -0.4804579 -0.4808383 -0.4812184 -0.4815983 -0.4819780 [79] -0.4823575 -0.4827368 -0.4831159 -0.4834948 -0.4838734 -0.4842518 [85] -0.4846300 -0.4850080 -0.4853858 -0.4857633 -0.4861406 -0.4865177 [91] -0.4868945 -0.4872711 -0.4876474 -0.4880235 -0.4883994 -0.4887750 [97] -0.4891504 -0.4895255 -0.4899004 -0.4902750 -0.4906494 -0.4910235 [103] -0.4913973 -0.4917709 -0.4921442 -0.4925173 -0.4928900 -0.4932625 [109] -0.4936348 -0.4940068 -0.4943784 -0.4947499 -0.4951210 -0.4954918 [115] -0.4958624 -0.4962327 -0.4966027 -0.4969724 -0.4973418 -0.4977109 [121] -0.4980797 -0.4984482 -0.4988164 -0.4991843 -0.4995519 -0.4999192 [127] -0.5002862 -0.5006529 -0.5010192 -0.5013853 -0.5017510 -0.5021164 [133] -0.5024815 -0.5028463 -0.5032107 -0.5035748 -0.5039386 -0.5043021 [139] -0.5046652 -0.5050280 -0.5053904 -0.5057525 -0.5061143 -0.5064757 [145] -0.5068368 -0.5071975 -0.5075579 -0.5079179 -0.5082775 -0.5086369 [151] -0.5089958 -0.5093544 -0.5097126 -0.5100705 -0.5104280 -0.5107852 [157] -0.5111419 -0.5114983 -0.5118543 -0.5122100 -0.5125652 -0.5129201 [163] -0.5132746 -0.5136288 -0.5139825 -0.5143359 -0.5146888 -0.5150414 [169] -0.5153936 -0.5157454 -0.5160967 -0.5164477 -0.5167983 -0.5171485 [175] -0.5174983 -0.5178477 -0.5181966 -0.5185452 -0.5188933 -0.5192410 [181] -0.5195884 -0.5199353 -0.5202817 -0.5206278 -0.5209734 -0.5213186 [187] -0.5216634 -0.5220077 -0.5223517 -0.5226951 -0.5230382 -0.5233808 [193] -0.5237230 -0.5240647 -0.5244060 -0.5247469 -0.5250873 -0.5254272 [199] -0.5257667 -0.5261058 -0.5264444 -0.5267825 -0.5271202 -0.5274575 [205] -0.5277942 -0.5281305 -0.5284664 -0.5288018 -0.5291367 -0.5294711 [211] -0.5298051 -0.5301386 -0.5304717 -0.5308042 -0.5311363 -0.5314679 [217] -0.5317990 -0.5321296 -0.5324598 -0.5327895 -0.5331186 -0.5334473 [223] -0.5337755 -0.5341032 -0.5344304 -0.5347571 -0.5350834 -0.5354091 [229] -0.5357343 -0.5360590 -0.5363832 -0.5367069 -0.5370301 -0.5373528 [235] -0.5376750 -0.5379966 -0.5383178 -0.5386384 -0.5389585 -0.5392781 [241] -0.5395972 -0.5399157 -0.5402338 -0.5405513 -0.5408682 -0.5411847 [247] -0.5415006 -0.5418160 -0.5421308 -0.5424452 -0.5427590 -0.5430722 [253] -0.5433849 -0.5436971 -0.5440087 -0.5443198 -0.5446303 -0.5449403 [259] -0.5452498 -0.5455587 -0.5458670 -0.5461748 -0.5464820 -0.5467887 [265] -0.5470948 -0.5474004 -0.5477054 -0.5480099 -0.5483138 -0.5486171 [271] -0.5489198 -0.5492220 -0.5495237 -0.5498247 -0.5501252 -0.5504251 [277] -0.5507245 -0.5510232 -0.5513214 -0.5516190 -0.5519161 -0.5522125 [283] -0.5525084 -0.5528037 -0.5530984 -0.5533925 -0.5536861 -0.5539790 [289] -0.5542714 -0.5545632 -0.5548544 -0.5551449 -0.5554349 -0.5557244 [295] -0.5560132 -0.5563014 -0.5565890 -0.5568760 -0.5571624 -0.5574482 [301] -0.5577334 -0.5580181 -0.5583021 -0.5585854 -0.5588682 -0.5591504 [307] -0.5594320 -0.5597129 -0.5599933 -0.5602730 -0.5605521 -0.5608307 [313] -0.5611085 -0.5613858 -0.5616625 -0.5619385 -0.5622139 -0.5624887 [319] -0.5627629 -0.5630364 -0.5633094 -0.5635817 -0.5638533 -0.5641244 [325] -0.5643948 -0.5646646 -0.5649337 -0.5652023 -0.5654702 -0.5657374 [331] -0.5660040 -0.5662700 -0.5665354 -0.5668001 -0.5670642 -0.5673276 [337] -0.5675905 -0.5678526 -0.5681141 -0.5683750 -0.5686353 -0.5688949 [343] -0.5691538 -0.5694121 -0.5696698 -0.5699268 -0.5701832 -0.5704389 [349] -0.5706940 -0.5709484 -0.5712022 -0.5714553 -0.5717077 -0.5719596 [355] -0.5722107 -0.5724612 -0.5727111 -0.5729603 -0.5732088 -0.5734567 [361] -0.5737039 -0.5739505 -0.5741964 -0.5744416 -0.5746862 -0.5749302 [367] -0.5751734 -0.5754160 -0.5756580 -0.5758992 -0.5761399 -0.5763798 [373] -0.5766191 -0.5768577 -0.5770957 -0.5773330 -0.5775696 -0.5778055 [379] -0.5780408 -0.5782754 -0.5785094 -0.5787426 -0.5789752 -0.5792072 [385] -0.5794384 -0.5796690 -0.5798989 -0.5801282 -0.5803568 -0.5805847 [391] -0.5808119 -0.5810384 -0.5812643 -0.5814895 -0.5817140 -0.5819379 [397] -0.5821611 -0.5823835 -0.5826054 -0.5828265 -0.5830470 > 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/1unik1194256107.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/2go4a1194256107.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/3vz381194256107.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/4j2hg1194256107.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/5g2811194256108.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/6jt4n1194256108.tab") > > system("convert tmp/1unik1194256107.ps tmp/1unik1194256107.png") > system("convert tmp/2go4a1194256107.ps tmp/2go4a1194256107.png") > system("convert tmp/3vz381194256107.ps tmp/3vz381194256107.png") > system("convert tmp/4j2hg1194256107.ps tmp/4j2hg1194256107.png") > system("convert tmp/5g2811194256108.ps tmp/5g2811194256108.png") > > > proc.time() user system elapsed 1.382 0.825 1.818