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(108.8,128.4,121.1,119.5,128.7,108.7,105.5,119.8,111.3,110.6,120.1,97.5,107.7,127.3,117.2,119.8,116.2,111,112.4,130.6,109.1,118.8,123.9,101.6,112.8,128,129.6,125.8,119.5,115.7,113.6,129.7,112,116.8,127,112.1,114.2,121.1,131.6,125,120.4,117.7,117.5,120.6,127.5,112.3,124.5,115.2,104.7,130.9,129.2,113.5,125.6,107.6,107,121.6,110.7,106.3,118.6,104.6,103.5) > 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.08453711 -0.08452985 -0.08452254 -0.08451519 -0.08450780 -0.08450036 [7] -0.08449288 -0.08448536 -0.08447780 -0.08447019 -0.08446254 -0.08445484 [13] -0.08444710 -0.08443932 -0.08443150 -0.08442363 -0.08441572 -0.08440777 [19] -0.08439978 -0.08439174 -0.08438366 -0.08437554 -0.08436737 -0.08435917 [25] -0.08435092 -0.08434262 -0.08433429 -0.08432591 -0.08431750 -0.08430904 [31] -0.08430053 -0.08429199 -0.08428340 -0.08427477 -0.08426610 -0.08425739 [37] -0.08424864 -0.08423984 -0.08423100 -0.08422212 -0.08421320 -0.08420424 [43] -0.08419524 -0.08418619 -0.08417711 -0.08416798 -0.08415881 -0.08414960 [49] -0.08414035 -0.08413106 -0.08412172 -0.08411235 -0.08410293 -0.08409348 [55] -0.08408398 -0.08407444 -0.08406486 -0.08405525 -0.08404559 -0.08403588 [61] -0.08402614 -0.08401636 -0.08400654 -0.08399668 -0.08398678 -0.08397683 [67] -0.08396685 -0.08395683 -0.08394676 -0.08393666 -0.08392652 -0.08391633 [73] -0.08390611 -0.08389584 -0.08388554 -0.08387520 -0.08386482 -0.08385439 [79] -0.08384393 -0.08383343 -0.08382289 -0.08381231 -0.08380169 -0.08379103 [85] -0.08378033 -0.08376959 -0.08375882 -0.08374800 -0.08373715 -0.08372625 [91] -0.08371532 -0.08370435 -0.08369334 -0.08368229 -0.08367120 -0.08366007 [97] -0.08364890 -0.08363770 -0.08362646 -0.08361517 -0.08360385 -0.08359250 [103] -0.08358110 -0.08356966 -0.08355819 -0.08354668 -0.08353513 -0.08352354 [109] -0.08351192 -0.08350025 -0.08348855 -0.08347681 -0.08346503 -0.08345322 [115] -0.08344136 -0.08342947 -0.08341754 -0.08340558 -0.08339358 -0.08338153 [121] -0.08336946 -0.08335734 -0.08334519 -0.08333300 -0.08332077 -0.08330851 [127] -0.08329620 -0.08328387 -0.08327149 -0.08325908 -0.08324663 -0.08323414 [133] -0.08322162 -0.08320906 -0.08319646 -0.08318383 -0.08317116 -0.08315846 [139] -0.08314571 -0.08313293 -0.08312012 -0.08310727 -0.08309438 -0.08308146 [145] -0.08306850 -0.08305550 -0.08304247 -0.08302940 -0.08301630 -0.08300316 [151] -0.08298998 -0.08297677 -0.08296352 -0.08295024 -0.08293692 -0.08292357 [157] -0.08291018 -0.08289675 -0.08288329 -0.08286980 -0.08285627 -0.08284270 [163] -0.08282910 -0.08281546 -0.08280179 -0.08278808 -0.08277434 -0.08276057 [169] -0.08274676 -0.08273291 -0.08271903 -0.08270511 -0.08269116 -0.08267718 [175] -0.08266316 -0.08264911 -0.08263502 -0.08262090 -0.08260674 -0.08259255 [181] -0.08257832 -0.08256406 -0.08254977 -0.08253544 -0.08252108 -0.08250669 [187] -0.08249226 -0.08247779 -0.08246330 -0.08244877 -0.08243420 -0.08241961 [193] -0.08240497 -0.08239031 -0.08237561 -0.08236088 -0.08234611 -0.08233132 [199] -0.08231648 -0.08230162 -0.08228672 -0.08227179 -0.08225683 -0.08224183 [205] -0.08222680 -0.08221174 -0.08219664 -0.08218151 -0.08216635 -0.08215116 [211] -0.08213593 -0.08212068 -0.08210538 -0.08209006 -0.08207470 -0.08205932 [217] -0.08204390 -0.08202844 -0.08201296 -0.08199744 -0.08198189 -0.08196631 [223] -0.08195070 -0.08193505 -0.08191938 -0.08190367 -0.08188793 -0.08187215 [229] -0.08185635 -0.08184052 -0.08182465 -0.08180875 -0.08179282 -0.08177686 [235] -0.08176087 -0.08174485 -0.08172879 -0.08171270 -0.08169659 -0.08168044 [241] -0.08166426 -0.08164805 -0.08163181 -0.08161554 -0.08159924 -0.08158290 [247] -0.08156654 -0.08155015 -0.08153372 -0.08151727 -0.08150078 -0.08148426 [253] -0.08146772 -0.08145114 -0.08143454 -0.08141790 -0.08140123 -0.08138453 [259] -0.08136781 -0.08135105 -0.08133426 -0.08131745 -0.08130060 -0.08128372 [265] -0.08126682 -0.08124988 -0.08123291 -0.08121592 -0.08119890 -0.08118184 [271] -0.08116476 -0.08114765 -0.08113050 -0.08111333 -0.08109613 -0.08107890 [277] -0.08106165 -0.08104436 -0.08102704 -0.08100970 -0.08099232 -0.08097492 [283] -0.08095749 -0.08094003 -0.08092254 -0.08090502 -0.08088748 -0.08086990 [289] -0.08085230 -0.08083467 -0.08081701 -0.08079932 -0.08078161 -0.08076386 [295] -0.08074609 -0.08072829 -0.08071046 -0.08069261 -0.08067472 -0.08065681 [301] -0.08063887 -0.08062091 -0.08060291 -0.08058489 -0.08056684 -0.08054876 [307] -0.08053066 -0.08051253 -0.08049437 -0.08047618 -0.08045797 -0.08043972 [313] -0.08042146 -0.08040316 -0.08038484 -0.08036649 -0.08034811 -0.08032971 [319] -0.08031128 -0.08029282 -0.08027434 -0.08025583 -0.08023729 -0.08021873 [325] -0.08020014 -0.08018152 -0.08016288 -0.08014421 -0.08012552 -0.08010680 [331] -0.08008805 -0.08006927 -0.08005047 -0.08003165 -0.08001280 -0.07999392 [337] -0.07997502 -0.07995609 -0.07993713 -0.07991815 -0.07989914 -0.07988011 [343] -0.07986105 -0.07984197 -0.07982286 -0.07980373 -0.07978457 -0.07976539 [349] -0.07974618 -0.07972694 -0.07970768 -0.07968840 -0.07966909 -0.07964975 [355] -0.07963039 -0.07961101 -0.07959160 -0.07957216 -0.07955270 -0.07953322 [361] -0.07951371 -0.07949418 -0.07947462 -0.07945504 -0.07943543 -0.07941580 [367] -0.07939615 -0.07937647 -0.07935676 -0.07933704 -0.07931728 -0.07929751 [373] -0.07927771 -0.07925789 -0.07923804 -0.07921817 -0.07919827 -0.07917835 [379] -0.07915841 -0.07913845 -0.07911846 -0.07909844 -0.07907841 -0.07905835 [385] -0.07903826 -0.07901816 -0.07899803 -0.07897787 -0.07895770 -0.07893750 [391] -0.07891728 -0.07889703 -0.07887676 -0.07885647 -0.07883616 -0.07881582 [397] -0.07879546 -0.07877508 -0.07875467 -0.07873425 -0.07871380 > 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/1m4191260978621.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/25gku1260978621.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/3h92h1260978621.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/4zens1260978621.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/5esoc1260978621.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/6wqx91260978621.tab") > > try(system("convert tmp/1m4191260978621.ps tmp/1m4191260978621.png",intern=TRUE)) character(0) > try(system("convert tmp/25gku1260978621.ps tmp/25gku1260978621.png",intern=TRUE)) character(0) > try(system("convert tmp/3h92h1260978621.ps tmp/3h92h1260978621.png",intern=TRUE)) character(0) > try(system("convert tmp/4zens1260978621.ps tmp/4zens1260978621.png",intern=TRUE)) character(0) > try(system("convert tmp/5esoc1260978621.ps tmp/5esoc1260978621.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.067 0.782 1.789