R version 2.6.1 (2007-11-26) 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(59.9,59.9,59.9,60.9,60.9,60.9,61.1,61.1,61.1,60.2,60.2,60.2,60.1,60.1,60.1,59.7,59.7,59.7,60.5,60.5,60.5,59.5,59.5,59.5,59.5,59.5,59.5,59.7,59.7,59.7,60.4,60.4,60.4,60,60,60,59,59,59,59.3,59.3,59.3,59.7,59.7,59.7,60.4,60.4,60.4,59.9,59.9,59.9,60.5,60.5,60.5,60.4,60.4,60.4,60.6,60.6,60.6,60.9,60.9,60.9,61,61,61,61.2,61.2,61.2,61.2,61.2,61.2,60.3,60.3,60.3,60.4,60.4,60.4,61.2,61.2,61.2,62.1,62.1,62.1,61.7,61.7,61.7,61.6,61.6,61.6) > #'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.5495428 0.5495629 0.5495830 0.5496032 0.5496233 0.5496434 0.5496635 [8] 0.5496836 0.5497037 0.5497239 0.5497440 0.5497641 0.5497842 0.5498042 [15] 0.5498243 0.5498444 0.5498645 0.5498846 0.5499047 0.5499247 0.5499448 [22] 0.5499649 0.5499849 0.5500050 0.5500251 0.5500451 0.5500652 0.5500852 [29] 0.5501053 0.5501253 0.5501453 0.5501654 0.5501854 0.5502054 0.5502255 [36] 0.5502455 0.5502655 0.5502855 0.5503055 0.5503256 0.5503456 0.5503656 [43] 0.5503856 0.5504056 0.5504256 0.5504456 0.5504655 0.5504855 0.5505055 [50] 0.5505255 0.5505455 0.5505654 0.5505854 0.5506054 0.5506253 0.5506453 [57] 0.5506652 0.5506852 0.5507052 0.5507251 0.5507450 0.5507650 0.5507849 [64] 0.5508049 0.5508248 0.5508447 0.5508646 0.5508846 0.5509045 0.5509244 [71] 0.5509443 0.5509642 0.5509841 0.5510040 0.5510239 0.5510438 0.5510637 [78] 0.5510836 0.5511035 0.5511234 0.5511432 0.5511631 0.5511830 0.5512029 [85] 0.5512227 0.5512426 0.5512624 0.5512823 0.5513022 0.5513220 0.5513418 [92] 0.5513617 0.5513815 0.5514014 0.5514212 0.5514410 0.5514609 0.5514807 [99] 0.5515005 0.5515203 0.5515401 0.5515600 0.5515798 0.5515996 0.5516194 [106] 0.5516392 0.5516590 0.5516788 0.5516985 0.5517183 0.5517381 0.5517579 [113] 0.5517777 0.5517974 0.5518172 0.5518370 0.5518567 0.5518765 0.5518963 [120] 0.5519160 0.5519358 0.5519555 0.5519752 0.5519950 0.5520147 0.5520345 [127] 0.5520542 0.5520739 0.5520936 0.5521134 0.5521331 0.5521528 0.5521725 [134] 0.5521922 0.5522119 0.5522316 0.5522513 0.5522710 0.5522907 0.5523104 [141] 0.5523301 0.5523498 0.5523694 0.5523891 0.5524088 0.5524285 0.5524481 [148] 0.5524678 0.5524874 0.5525071 0.5525267 0.5525464 0.5525660 0.5525857 [155] 0.5526053 0.5526250 0.5526446 0.5526642 0.5526838 0.5527035 0.5527231 [162] 0.5527427 0.5527623 0.5527819 0.5528015 0.5528211 0.5528407 0.5528603 [169] 0.5528799 0.5528995 0.5529191 0.5529387 0.5529583 0.5529779 0.5529974 [176] 0.5530170 0.5530366 0.5530561 0.5530757 0.5530953 0.5531148 0.5531344 [183] 0.5531539 0.5531734 0.5531930 0.5532125 0.5532321 0.5532516 0.5532711 [190] 0.5532906 0.5533102 0.5533297 0.5533492 0.5533687 0.5533882 0.5534077 [197] 0.5534272 0.5534467 0.5534662 0.5534857 0.5535052 0.5535247 0.5535442 [204] 0.5535637 0.5535831 0.5536026 0.5536221 0.5536415 0.5536610 0.5536805 [211] 0.5536999 0.5537194 0.5537388 0.5537583 0.5537777 0.5537971 0.5538166 [218] 0.5538360 0.5538554 0.5538749 0.5538943 0.5539137 0.5539331 0.5539525 [225] 0.5539720 0.5539914 0.5540108 0.5540302 0.5540496 0.5540690 0.5540883 [232] 0.5541077 0.5541271 0.5541465 0.5541659 0.5541853 0.5542046 0.5542240 [239] 0.5542434 0.5542627 0.5542821 0.5543014 0.5543208 0.5543401 0.5543595 [246] 0.5543788 0.5543981 0.5544175 0.5544368 0.5544561 0.5544755 0.5544948 [253] 0.5545141 0.5545334 0.5545527 0.5545720 0.5545913 0.5546106 0.5546299 [260] 0.5546492 0.5546685 0.5546878 0.5547071 0.5547264 0.5547457 0.5547649 [267] 0.5547842 0.5548035 0.5548227 0.5548420 0.5548612 0.5548805 0.5548998 [274] 0.5549190 0.5549382 0.5549575 0.5549767 0.5549960 0.5550152 0.5550344 [281] 0.5550536 0.5550729 0.5550921 0.5551113 0.5551305 0.5551497 0.5551689 [288] 0.5551881 0.5552073 0.5552265 0.5552457 0.5552649 0.5552841 0.5553033 [295] 0.5553224 0.5553416 0.5553608 0.5553800 0.5553991 0.5554183 0.5554374 [302] 0.5554566 0.5554757 0.5554949 0.5555140 0.5555332 0.5555523 0.5555714 [309] 0.5555906 0.5556097 0.5556288 0.5556480 0.5556671 0.5556862 0.5557053 [316] 0.5557244 0.5557435 0.5557626 0.5557817 0.5558008 0.5558199 0.5558390 [323] 0.5558581 0.5558771 0.5558962 0.5559153 0.5559344 0.5559534 0.5559725 [330] 0.5559916 0.5560106 0.5560297 0.5560487 0.5560678 0.5560868 0.5561059 [337] 0.5561249 0.5561439 0.5561630 0.5561820 0.5562010 0.5562200 0.5562390 [344] 0.5562581 0.5562771 0.5562961 0.5563151 0.5563341 0.5563531 0.5563721 [351] 0.5563911 0.5564101 0.5564290 0.5564480 0.5564670 0.5564860 0.5565049 [358] 0.5565239 0.5565429 0.5565618 0.5565808 0.5565997 0.5566187 0.5566376 [365] 0.5566566 0.5566755 0.5566945 0.5567134 0.5567323 0.5567512 0.5567702 [372] 0.5567891 0.5568080 0.5568269 0.5568458 0.5568647 0.5568836 0.5569025 [379] 0.5569214 0.5569403 0.5569592 0.5569781 0.5569970 0.5570159 0.5570347 [386] 0.5570536 0.5570725 0.5570913 0.5571102 0.5571291 0.5571479 0.5571668 [393] 0.5571856 0.5572045 0.5572233 0.5572421 0.5572610 0.5572798 0.5572986 [400] 0.5573175 0.5573363 > mx [1] 0.5573363 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1w7zr1199649524.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/2i2mt1199649524.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/3f48r1199649524.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/4g2pw1199649524.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/5cc0n1199649524.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/6kvis1199649525.tab") > > system("convert tmp/1w7zr1199649524.ps tmp/1w7zr1199649524.png") > system("convert tmp/2i2mt1199649524.ps tmp/2i2mt1199649524.png") > system("convert tmp/3f48r1199649524.ps tmp/3f48r1199649524.png") > system("convert tmp/4g2pw1199649524.ps tmp/4g2pw1199649524.png") > system("convert tmp/5cc0n1199649524.ps tmp/5cc0n1199649524.png") > > > proc.time() user system elapsed 1.400 0.825 1.722