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(103.1,100.6,103.1,95.5,90.5,90.9,88.8,90.7,94.3,104.6,111.1,110.8,107.2,99,99,91,96.2,96.9,96.2,100.1,99,115.4,106.9,107.1,99.3,99.2,108.3,105.6,99.5,107.4,93.1,88.1,110.7,113.1,99.6,93.6,98.6,99.6,114.3,107.8,101.2,112.5,100.5,93.9,116.2,112,106.4,95.7,96,95.8,103,102.2,98.4,111.4,86.6,91.3,107.9,101.8,104.4,93.4,100.1,98.5,112.9,101.4,107.1,110.8,90.3,95.5,111.4,113,107.5,95.9,106.3,105.2,117.2,106.9,108.2,110,96.1,100.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.2273973 0.2274096 0.2274218 0.2274340 0.2274461 0.2274582 0.2274703 [8] 0.2274823 0.2274943 0.2275062 0.2275181 0.2275300 0.2275419 0.2275537 [15] 0.2275654 0.2275771 0.2275888 0.2276005 0.2276121 0.2276236 0.2276352 [22] 0.2276466 0.2276581 0.2276695 0.2276809 0.2276922 0.2277035 0.2277148 [29] 0.2277260 0.2277372 0.2277483 0.2277594 0.2277705 0.2277815 0.2277925 [36] 0.2278035 0.2278144 0.2278253 0.2278361 0.2278469 0.2278577 0.2278684 [43] 0.2278791 0.2278897 0.2279003 0.2279109 0.2279214 0.2279319 0.2279424 [50] 0.2279528 0.2279632 0.2279735 0.2279838 0.2279941 0.2280043 0.2280145 [57] 0.2280246 0.2280348 0.2280448 0.2280549 0.2280649 0.2280748 0.2280847 [64] 0.2280946 0.2281045 0.2281143 0.2281240 0.2281338 0.2281435 0.2281531 [71] 0.2281627 0.2281723 0.2281818 0.2281913 0.2282008 0.2282102 0.2282196 [78] 0.2282290 0.2282383 0.2282475 0.2282568 0.2282660 0.2282751 0.2282843 [85] 0.2282933 0.2283024 0.2283114 0.2283204 0.2283293 0.2283382 0.2283470 [92] 0.2283558 0.2283646 0.2283734 0.2283821 0.2283907 0.2283994 0.2284079 [99] 0.2284165 0.2284250 0.2284335 0.2284419 0.2284503 0.2284587 0.2284670 [106] 0.2284753 0.2284835 0.2284917 0.2284999 0.2285080 0.2285161 0.2285242 [113] 0.2285322 0.2285402 0.2285481 0.2285560 0.2285639 0.2285717 0.2285795 [120] 0.2285873 0.2285950 0.2286027 0.2286103 0.2286179 0.2286255 0.2286330 [127] 0.2286405 0.2286479 0.2286554 0.2286627 0.2286701 0.2286774 0.2286846 [134] 0.2286919 0.2286990 0.2287062 0.2287133 0.2287204 0.2287274 0.2287344 [141] 0.2287414 0.2287483 0.2287552 0.2287620 0.2287688 0.2287756 0.2287824 [148] 0.2287890 0.2287957 0.2288023 0.2288089 0.2288155 0.2288220 0.2288284 [155] 0.2288349 0.2288413 0.2288476 0.2288540 0.2288602 0.2288665 0.2288727 [162] 0.2288789 0.2288850 0.2288911 0.2288972 0.2289032 0.2289092 0.2289151 [169] 0.2289210 0.2289269 0.2289328 0.2289386 0.2289443 0.2289500 0.2289557 [176] 0.2289614 0.2289670 0.2289726 0.2289781 0.2289836 0.2289891 0.2289945 [183] 0.2289999 0.2290052 0.2290105 0.2290158 0.2290211 0.2290263 0.2290314 [190] 0.2290366 0.2290417 0.2290467 0.2290517 0.2290567 0.2290616 0.2290666 [197] 0.2290714 0.2290763 0.2290810 0.2290858 0.2290905 0.2290952 0.2290999 [204] 0.2291045 0.2291090 0.2291136 0.2291181 0.2291225 0.2291270 0.2291314 [211] 0.2291357 0.2291400 0.2291443 0.2291485 0.2291527 0.2291569 0.2291610 [218] 0.2291651 0.2291692 0.2291732 0.2291772 0.2291811 0.2291850 0.2291889 [225] 0.2291928 0.2291966 0.2292003 0.2292040 0.2292077 0.2292114 0.2292150 [232] 0.2292186 0.2292221 0.2292256 0.2292291 0.2292325 0.2292359 0.2292393 [239] 0.2292426 0.2292459 0.2292492 0.2292524 0.2292555 0.2292587 0.2292618 [246] 0.2292649 0.2292679 0.2292709 0.2292738 0.2292768 0.2292797 0.2292825 [253] 0.2292853 0.2292881 0.2292908 0.2292935 0.2292962 0.2292988 0.2293014 [260] 0.2293040 0.2293065 0.2293090 0.2293115 0.2293139 0.2293163 0.2293186 [267] 0.2293209 0.2293232 0.2293254 0.2293276 0.2293298 0.2293319 0.2293340 [274] 0.2293360 0.2293381 0.2293401 0.2293420 0.2293439 0.2293458 0.2293476 [281] 0.2293494 0.2293512 0.2293529 0.2293546 0.2293563 0.2293579 0.2293595 [288] 0.2293610 0.2293626 0.2293640 0.2293655 0.2293669 0.2293683 0.2293696 [295] 0.2293709 0.2293722 0.2293734 0.2293746 0.2293758 0.2293769 0.2293780 [302] 0.2293790 0.2293800 0.2293810 0.2293820 0.2293829 0.2293838 0.2293846 [309] 0.2293854 0.2293862 0.2293869 0.2293876 0.2293883 0.2293889 0.2293895 [316] 0.2293900 0.2293906 0.2293910 0.2293915 0.2293919 0.2293923 0.2293926 [323] 0.2293929 0.2293932 0.2293935 0.2293937 0.2293938 0.2293940 0.2293941 [330] 0.2293941 0.2293942 0.2293941 0.2293941 0.2293940 0.2293939 0.2293938 [337] 0.2293936 0.2293934 0.2293931 0.2293928 0.2293925 0.2293922 0.2293918 [344] 0.2293913 0.2293909 0.2293904 0.2293899 0.2293893 0.2293887 0.2293881 [351] 0.2293874 0.2293867 0.2293860 0.2293852 0.2293844 0.2293835 0.2293827 [358] 0.2293817 0.2293808 0.2293798 0.2293788 0.2293778 0.2293767 0.2293756 [365] 0.2293744 0.2293732 0.2293720 0.2293707 0.2293694 0.2293681 0.2293668 [372] 0.2293654 0.2293639 0.2293625 0.2293610 0.2293595 0.2293579 0.2293563 [379] 0.2293547 0.2293530 0.2293513 0.2293496 0.2293478 0.2293460 0.2293441 [386] 0.2293423 0.2293404 0.2293384 0.2293365 0.2293344 0.2293324 0.2293303 [393] 0.2293282 0.2293261 0.2293239 0.2293217 0.2293194 0.2293172 0.2293149 [400] 0.2293125 0.2293101 > mx [1] 0.2293942 > mxli [1] 1.3 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1jjw11194696378.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/2unt81194696378.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/3xpki1194696378.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/4lyez1194696378.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/5nu1k1194696378.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/6deq61194696378.tab") > > system("convert tmp/1jjw11194696378.ps tmp/1jjw11194696378.png") > system("convert tmp/2unt81194696378.ps tmp/2unt81194696378.png") > system("convert tmp/3xpki1194696378.ps tmp/3xpki1194696378.png") > system("convert tmp/4lyez1194696378.ps tmp/4lyez1194696378.png") > system("convert tmp/5nu1k1194696378.ps tmp/5nu1k1194696378.png") > > > proc.time() user system elapsed 3.816 2.122 4.108