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(99.20,93.60,104.20,95.30,102.70,103.10,100.00,107.20,107.00,119.00,110.40,101.70,102.40,98.80,105.60,104.40,106.30,107.20,108.50,106.90,114.20,125.90,110.60,110.50,106.70,104.70,107.40,109.80,103.40,114.80,114.30,109.60,118.30,127.30,112.30,114.90,108.20,105.40,122.10,113.50,110.00,125.30,114.30,115.60,127.10,123.00,122.20,126.40,112.70,105.80,120.90,116.30,115.70,127.90,108.30,121.10,128.60,123.10,127.70,126.60,118.40,110.00,129.60,115.80,125.90,128.40,114.00,125.60,128.50,136.60,133.10,124.60,123.50,117.20,135.50,124.80,127.80,132.00,125.50,126.90) > #'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.7955432 0.7955394 0.7955354 0.7955311 0.7955267 0.7955222 0.7955174 [8] 0.7955125 0.7955073 0.7955020 0.7954966 0.7954909 0.7954850 0.7954790 [15] 0.7954728 0.7954664 0.7954598 0.7954531 0.7954462 0.7954390 0.7954318 [22] 0.7954243 0.7954166 0.7954088 0.7954008 0.7953926 0.7953842 0.7953757 [29] 0.7953669 0.7953580 0.7953489 0.7953397 0.7953302 0.7953206 0.7953108 [36] 0.7953008 0.7952907 0.7952803 0.7952698 0.7952591 0.7952483 0.7952372 [43] 0.7952260 0.7952146 0.7952030 0.7951913 0.7951793 0.7951672 0.7951549 [50] 0.7951425 0.7951298 0.7951170 0.7951040 0.7950909 0.7950775 0.7950640 [57] 0.7950503 0.7950365 0.7950224 0.7950082 0.7949938 0.7949792 0.7949645 [64] 0.7949496 0.7949345 0.7949192 0.7949038 0.7948882 0.7948724 0.7948564 [71] 0.7948403 0.7948240 0.7948075 0.7947909 0.7947740 0.7947570 0.7947399 [78] 0.7947225 0.7947050 0.7946873 0.7946695 0.7946514 0.7946332 0.7946148 [85] 0.7945963 0.7945776 0.7945587 0.7945396 0.7945204 0.7945010 0.7944814 [92] 0.7944617 0.7944418 0.7944217 0.7944014 0.7943810 0.7943604 0.7943396 [99] 0.7943187 0.7942976 0.7942763 0.7942549 0.7942333 0.7942115 0.7941895 [106] 0.7941674 0.7941451 0.7941227 0.7941001 0.7940773 0.7940543 0.7940312 [113] 0.7940079 0.7939844 0.7939608 0.7939370 0.7939131 0.7938889 0.7938646 [120] 0.7938402 0.7938155 0.7937908 0.7937658 0.7937407 0.7937154 0.7936899 [127] 0.7936643 0.7936385 0.7936126 0.7935864 0.7935601 0.7935337 0.7935071 [134] 0.7934803 0.7934534 0.7934263 0.7933990 0.7933716 0.7933440 0.7933162 [141] 0.7932883 0.7932602 0.7932319 0.7932035 0.7931749 0.7931462 0.7931173 [148] 0.7930882 0.7930590 0.7930296 0.7930001 0.7929703 0.7929405 0.7929104 [155] 0.7928802 0.7928499 0.7928194 0.7927887 0.7927578 0.7927268 0.7926957 [162] 0.7926643 0.7926329 0.7926012 0.7925694 0.7925375 0.7925053 0.7924730 [169] 0.7924406 0.7924080 0.7923752 0.7923423 0.7923093 0.7922760 0.7922426 [176] 0.7922091 0.7921754 0.7921415 0.7921075 0.7920733 0.7920389 0.7920044 [183] 0.7919698 0.7919350 0.7919000 0.7918649 0.7918296 0.7917942 0.7917586 [190] 0.7917228 0.7916869 0.7916508 0.7916146 0.7915782 0.7915417 0.7915050 [197] 0.7914682 0.7914312 0.7913940 0.7913567 0.7913193 0.7912817 0.7912439 [204] 0.7912060 0.7911679 0.7911297 0.7910913 0.7910528 0.7910141 0.7909752 [211] 0.7909362 0.7908971 0.7908578 0.7908183 0.7907787 0.7907390 0.7906991 [218] 0.7906590 0.7906188 0.7905784 0.7905379 0.7904972 0.7904564 0.7904155 [225] 0.7903743 0.7903331 0.7902917 0.7902501 0.7902084 0.7901665 0.7901245 [232] 0.7900823 0.7900400 0.7899975 0.7899549 0.7899121 0.7898692 0.7898261 [239] 0.7897829 0.7897396 0.7896961 0.7896524 0.7896086 0.7895646 0.7895205 [246] 0.7894763 0.7894319 0.7893873 0.7893426 0.7892978 0.7892528 0.7892077 [253] 0.7891624 0.7891170 0.7890714 0.7890257 0.7889798 0.7889338 0.7888877 [260] 0.7888414 0.7887949 0.7887483 0.7887016 0.7886547 0.7886077 0.7885605 [267] 0.7885132 0.7884658 0.7884182 0.7883704 0.7883225 0.7882745 0.7882263 [274] 0.7881780 0.7881295 0.7880809 0.7880322 0.7879833 0.7879343 0.7878851 [281] 0.7878358 0.7877863 0.7877367 0.7876870 0.7876371 0.7875870 0.7875369 [288] 0.7874866 0.7874361 0.7873855 0.7873348 0.7872839 0.7872329 0.7871818 [295] 0.7871305 0.7870790 0.7870275 0.7869758 0.7869239 0.7868719 0.7868198 [302] 0.7867675 0.7867151 0.7866626 0.7866099 0.7865571 0.7865041 0.7864510 [309] 0.7863978 0.7863444 0.7862909 0.7862372 0.7861834 0.7861295 0.7860755 [316] 0.7860213 0.7859669 0.7859124 0.7858578 0.7858031 0.7857482 0.7856932 [323] 0.7856381 0.7855828 0.7855273 0.7854718 0.7854161 0.7853603 0.7853043 [330] 0.7852482 0.7851920 0.7851356 0.7850791 0.7850225 0.7849657 0.7849088 [337] 0.7848518 0.7847946 0.7847373 0.7846799 0.7846223 0.7845646 0.7845067 [344] 0.7844488 0.7843907 0.7843324 0.7842741 0.7842156 0.7841570 0.7840982 [351] 0.7840393 0.7839803 0.7839211 0.7838618 0.7838024 0.7837429 0.7836832 [358] 0.7836234 0.7835635 0.7835034 0.7834432 0.7833829 0.7833224 0.7832618 [365] 0.7832011 0.7831403 0.7830793 0.7830182 0.7829569 0.7828956 0.7828341 [372] 0.7827725 0.7827107 0.7826488 0.7825868 0.7825247 0.7824625 0.7824001 [379] 0.7823376 0.7822749 0.7822121 0.7821493 0.7820862 0.7820231 0.7819598 [386] 0.7818964 0.7818329 0.7817692 0.7817054 0.7816415 0.7815775 0.7815134 [393] 0.7814491 0.7813847 0.7813201 0.7812555 0.7811907 0.7811258 0.7810608 [400] 0.7809956 0.7809303 > mx [1] 0.7955432 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1dhm31194255755.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/2kjks1194255755.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/3pcir1194255755.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/43npk1194255755.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/5sz211194255755.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/6ljst1194255756.tab") > > system("convert tmp/1dhm31194255755.ps tmp/1dhm31194255755.png") > system("convert tmp/2kjks1194255755.ps tmp/2kjks1194255755.png") > system("convert tmp/3pcir1194255755.ps tmp/3pcir1194255755.png") > system("convert tmp/43npk1194255755.ps tmp/43npk1194255755.png") > system("convert tmp/5sz211194255755.ps tmp/5sz211194255755.png") > > > proc.time() user system elapsed 1.351 0.806 1.763