R version 2.7.2 (2008-08-25) Copyright (C) 2008 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(113.5,121.2,130.4,115.2,117.9,110.7,107.6,124.3,115.1,112.5,127.9,117.4,119.3,130.4,126,125.4,130.5,115.9,108.7,124,119.4,118.6,131.3,111.1,124.8,132.3,126.7,131.7,130.9,122.1,113.2,133.6,119.2,129.4,131.4,117.1,130.5,132.3,140.8,137.5,128.6,126.7,120.8,139.3,128.6,131.3,136.3,128.8,133.2,136.3,151.1,145,134.4,135.7,128.7,129.2,138.6,132.7,132.5,135.2) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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.6319120 0.6319588 0.6320055 0.6320521 0.6320985 0.6321447 0.6321908 [8] 0.6322368 0.6322826 0.6323283 0.6323738 0.6324192 0.6324645 0.6325096 [15] 0.6325545 0.6325993 0.6326440 0.6326885 0.6327329 0.6327771 0.6328211 [22] 0.6328651 0.6329088 0.6329525 0.6329959 0.6330393 0.6330825 0.6331255 [29] 0.6331684 0.6332111 0.6332537 0.6332961 0.6333384 0.6333806 0.6334226 [36] 0.6334644 0.6335061 0.6335476 0.6335890 0.6336303 0.6336713 0.6337123 [43] 0.6337531 0.6337937 0.6338342 0.6338745 0.6339147 0.6339547 0.6339946 [50] 0.6340343 0.6340739 0.6341133 0.6341526 0.6341917 0.6342307 0.6342695 [57] 0.6343081 0.6343466 0.6343850 0.6344232 0.6344612 0.6344991 0.6345368 [64] 0.6345744 0.6346118 0.6346491 0.6346862 0.6347231 0.6347599 0.6347966 [71] 0.6348331 0.6348694 0.6349056 0.6349416 0.6349775 0.6350132 0.6350487 [78] 0.6350841 0.6351193 0.6351544 0.6351893 0.6352241 0.6352587 0.6352931 [85] 0.6353274 0.6353616 0.6353955 0.6354293 0.6354630 0.6354965 0.6355298 [92] 0.6355630 0.6355960 0.6356289 0.6356616 0.6356941 0.6357265 0.6357587 [99] 0.6357907 0.6358226 0.6358544 0.6358859 0.6359173 0.6359486 0.6359797 [106] 0.6360106 0.6360413 0.6360719 0.6361024 0.6361327 0.6361628 0.6361927 [113] 0.6362225 0.6362521 0.6362816 0.6363109 0.6363400 0.6363690 0.6363978 [120] 0.6364264 0.6364549 0.6364832 0.6365114 0.6365393 0.6365672 0.6365948 [127] 0.6366223 0.6366496 0.6366768 0.6367038 0.6367306 0.6367572 0.6367837 [134] 0.6368100 0.6368362 0.6368622 0.6368880 0.6369137 0.6369391 0.6369645 [141] 0.6369896 0.6370146 0.6370394 0.6370641 0.6370885 0.6371129 0.6371370 [148] 0.6371610 0.6371848 0.6372084 0.6372319 0.6372552 0.6372783 0.6373012 [155] 0.6373240 0.6373466 0.6373691 0.6373914 0.6374135 0.6374354 0.6374572 [162] 0.6374788 0.6375002 0.6375214 0.6375425 0.6375634 0.6375841 0.6376047 [169] 0.6376251 0.6376453 0.6376653 0.6376852 0.6377049 0.6377244 0.6377438 [176] 0.6377629 0.6377819 0.6378008 0.6378194 0.6378379 0.6378562 0.6378743 [183] 0.6378923 0.6379101 0.6379277 0.6379451 0.6379624 0.6379794 0.6379963 [190] 0.6380131 0.6380296 0.6380460 0.6380622 0.6380782 0.6380941 0.6381097 [197] 0.6381252 0.6381405 0.6381557 0.6381706 0.6381854 0.6382000 0.6382145 [204] 0.6382287 0.6382428 0.6382567 0.6382704 0.6382839 0.6382973 0.6383105 [211] 0.6383235 0.6383363 0.6383489 0.6383614 0.6383737 0.6383858 0.6383977 [218] 0.6384094 0.6384210 0.6384324 0.6384436 0.6384546 0.6384654 0.6384761 [225] 0.6384865 0.6384968 0.6385069 0.6385169 0.6385266 0.6385362 0.6385456 [232] 0.6385548 0.6385638 0.6385726 0.6385813 0.6385897 0.6385980 0.6386061 [239] 0.6386140 0.6386218 0.6386293 0.6386367 0.6386439 0.6386509 0.6386577 [246] 0.6386643 0.6386707 0.6386770 0.6386831 0.6386890 0.6386947 0.6387002 [253] 0.6387055 0.6387107 0.6387156 0.6387204 0.6387250 0.6387294 0.6387336 [260] 0.6387376 0.6387415 0.6387451 0.6387486 0.6387519 0.6387550 0.6387579 [267] 0.6387606 0.6387631 0.6387655 0.6387676 0.6387696 0.6387714 0.6387729 [274] 0.6387743 0.6387756 0.6387766 0.6387774 0.6387781 0.6387785 0.6387788 [281] 0.6387788 0.6387787 0.6387784 0.6387779 0.6387772 0.6387764 0.6387753 [288] 0.6387740 0.6387726 0.6387709 0.6387691 0.6387671 0.6387649 0.6387625 [295] 0.6387599 0.6387571 0.6387541 0.6387509 0.6387475 0.6387440 0.6387402 [302] 0.6387363 0.6387321 0.6387278 0.6387233 0.6387186 0.6387137 0.6387085 [309] 0.6387032 0.6386978 0.6386921 0.6386862 0.6386801 0.6386738 0.6386674 [316] 0.6386607 0.6386539 0.6386468 0.6386396 0.6386321 0.6386245 0.6386167 [323] 0.6386086 0.6386004 0.6385920 0.6385834 0.6385746 0.6385656 0.6385564 [330] 0.6385470 0.6385374 0.6385276 0.6385176 0.6385074 0.6384970 0.6384864 [337] 0.6384757 0.6384647 0.6384535 0.6384421 0.6384306 0.6384188 0.6384068 [344] 0.6383947 0.6383823 0.6383698 0.6383570 0.6383440 0.6383309 0.6383175 [351] 0.6383040 0.6382902 0.6382763 0.6382621 0.6382477 0.6382332 0.6382184 [358] 0.6382035 0.6381883 0.6381730 0.6381574 0.6381417 0.6381257 0.6381095 [365] 0.6380932 0.6380766 0.6380599 0.6380429 0.6380257 0.6380084 0.6379908 [372] 0.6379730 0.6379550 0.6379369 0.6379185 0.6378999 0.6378811 0.6378622 [379] 0.6378430 0.6378236 0.6378040 0.6377842 0.6377642 0.6377440 0.6377236 [386] 0.6377030 0.6376822 0.6376612 0.6376399 0.6376185 0.6375969 0.6375751 [393] 0.6375530 0.6375308 0.6375083 0.6374857 0.6374628 0.6374398 0.6374165 [400] 0.6373930 0.6373694 > mx [1] 0.6387788 > mxli [1] 0.8 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1znpw1226422222.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/2fkya1226422222.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/3les21226422222.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/4cgg11226422222.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/5pq5p1226422222.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/6sp171226422222.tab") > > system("convert tmp/1znpw1226422222.ps tmp/1znpw1226422222.png") > system("convert tmp/2fkya1226422222.ps tmp/2fkya1226422222.png") > system("convert tmp/3les21226422222.ps tmp/3les21226422222.png") > system("convert tmp/4cgg11226422222.ps tmp/4cgg11226422222.png") > system("convert tmp/5pq5p1226422222.ps tmp/5pq5p1226422222.png") > > > proc.time() user system elapsed 1.308 0.793 3.858