R version 2.7.0 (2008-04-22) 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(34,44,37,34,45,50,54,61,62,60,67,70,86) > #'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.8710575 0.8714571 0.8718563 0.8722552 0.8726538 0.8730521 0.8734500 [8] 0.8738475 0.8742448 0.8746416 0.8750381 0.8754343 0.8758300 0.8762254 [15] 0.8766204 0.8770150 0.8774092 0.8778030 0.8781964 0.8785893 0.8789818 [22] 0.8793739 0.8797656 0.8801568 0.8805475 0.8809378 0.8813276 0.8817170 [29] 0.8821058 0.8824942 0.8828821 0.8832695 0.8836563 0.8840427 0.8844285 [36] 0.8848138 0.8851986 0.8855828 0.8859665 0.8863496 0.8867321 0.8871141 [43] 0.8874955 0.8878763 0.8882565 0.8886361 0.8890151 0.8893935 0.8897713 [50] 0.8901484 0.8905249 0.8909008 0.8912760 0.8916505 0.8920244 0.8923976 [57] 0.8927702 0.8931420 0.8935131 0.8938836 0.8942533 0.8946223 0.8949906 [64] 0.8953581 0.8957249 0.8960910 0.8964562 0.8968208 0.8971845 0.8975475 [71] 0.8979097 0.8982711 0.8986317 0.8989915 0.8993504 0.8997086 0.9000659 [78] 0.9004223 0.9007779 0.9011327 0.9014866 0.9018396 0.9021917 0.9025429 [85] 0.9028933 0.9032427 0.9035912 0.9039388 0.9042855 0.9046312 0.9049760 [92] 0.9053199 0.9056628 0.9060047 0.9063456 0.9066855 0.9070245 0.9073624 [99] 0.9076994 0.9080353 0.9083702 0.9087041 0.9090369 0.9093686 0.9096994 [106] 0.9100290 0.9103576 0.9106851 0.9110115 0.9113368 0.9116609 0.9119840 [113] 0.9123060 0.9126268 0.9129465 0.9132650 0.9135824 0.9138986 0.9142136 [120] 0.9145275 0.9148401 0.9151516 0.9154619 0.9157709 0.9160787 0.9163853 [127] 0.9166907 0.9169948 0.9172976 0.9175992 0.9178995 0.9181986 0.9184963 [134] 0.9187928 0.9190879 0.9193817 0.9196743 0.9199654 0.9202553 0.9205438 [141] 0.9208309 0.9211167 0.9214011 0.9216841 0.9219658 0.9222460 0.9225249 [148] 0.9228023 0.9230783 0.9233529 0.9236261 0.9238978 0.9241680 0.9244368 [155] 0.9247042 0.9249700 0.9252344 0.9254972 0.9257586 0.9260185 0.9262768 [162] 0.9265336 0.9267889 0.9270427 0.9272949 0.9275455 0.9277946 0.9280421 [169] 0.9282880 0.9285324 0.9287751 0.9290163 0.9292558 0.9294937 0.9297300 [176] 0.9299646 0.9301976 0.9304290 0.9306587 0.9308867 0.9311131 0.9313378 [183] 0.9315608 0.9317821 0.9320016 0.9322195 0.9324357 0.9326501 0.9328628 [190] 0.9330738 0.9332830 0.9334905 0.9336961 0.9339001 0.9341022 0.9343026 [197] 0.9345012 0.9346979 0.9348929 0.9350860 0.9352774 0.9354669 0.9356546 [204] 0.9358404 0.9360244 0.9362065 0.9363868 0.9365652 0.9367417 0.9369163 [211] 0.9370891 0.9372599 0.9374289 0.9375960 0.9377611 0.9379243 0.9380856 [218] 0.9382449 0.9384023 0.9385578 0.9387113 0.9388628 0.9390124 0.9391600 [225] 0.9393057 0.9394493 0.9395910 0.9397306 0.9398683 0.9400039 0.9401376 [232] 0.9402692 0.9403988 0.9405263 0.9406519 0.9407753 0.9408968 0.9410161 [239] 0.9411335 0.9412487 0.9413619 0.9414730 0.9415821 0.9416890 0.9417939 [246] 0.9418966 0.9419973 0.9420958 0.9421923 0.9422866 0.9423788 0.9424689 [253] 0.9425569 0.9426427 0.9427264 0.9428079 0.9428873 0.9429646 0.9430397 [260] 0.9431126 0.9431834 0.9432520 0.9433184 0.9433826 0.9434447 0.9435046 [267] 0.9435623 0.9436178 0.9436711 0.9437222 0.9437711 0.9438178 0.9438623 [274] 0.9439046 0.9439446 0.9439825 0.9440181 0.9440515 0.9440826 0.9441116 [281] 0.9441383 0.9441627 0.9441849 0.9442049 0.9442227 0.9442381 0.9442514 [288] 0.9442623 0.9442711 0.9442775 0.9442817 0.9442837 0.9442834 0.9442808 [295] 0.9442759 0.9442688 0.9442594 0.9442477 0.9442338 0.9442176 0.9441991 [302] 0.9441783 0.9441552 0.9441299 0.9441023 0.9440723 0.9440401 0.9440057 [309] 0.9439689 0.9439298 0.9438885 0.9438448 0.9437989 0.9437507 0.9437002 [316] 0.9436474 0.9435923 0.9435349 0.9434752 0.9434132 0.9433490 0.9432824 [323] 0.9432136 0.9431424 0.9430690 0.9429933 0.9429152 0.9428349 0.9427523 [330] 0.9426675 0.9425803 0.9424908 0.9423991 0.9423050 0.9422087 0.9421101 [337] 0.9420092 0.9419060 0.9418006 0.9416928 0.9415828 0.9414705 0.9413560 [344] 0.9412391 0.9411200 0.9409987 0.9408750 0.9407491 0.9406210 0.9404905 [351] 0.9403578 0.9402229 0.9400857 0.9399462 0.9398045 0.9396606 0.9395144 [358] 0.9393660 0.9392153 0.9390624 0.9389073 0.9387499 0.9385903 0.9384285 [365] 0.9382645 0.9380982 0.9379298 0.9377591 0.9375862 0.9374111 0.9372338 [372] 0.9370544 0.9368727 0.9366888 0.9365028 0.9363146 0.9361242 0.9359316 [379] 0.9357369 0.9355400 0.9353409 0.9351397 0.9349364 0.9347309 0.9345232 [386] 0.9343134 0.9341015 0.9338875 0.9336713 0.9334530 0.9332326 0.9330102 [393] 0.9327856 0.9325589 0.9323301 0.9320992 0.9318663 0.9316312 0.9313942 [400] 0.9311550 0.9309138 > mx [1] 0.9442837 > mxli [1] 0.91 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1r07t1226580990.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/2tss31226580990.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/3mqiy1226580990.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/4rpko1226580990.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/5dh141226580990.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/6dcs41226580990.tab") > > system("convert tmp/1r07t1226580990.ps tmp/1r07t1226580990.png") > system("convert tmp/2tss31226580990.ps tmp/2tss31226580990.png") > system("convert tmp/3mqiy1226580990.ps tmp/3mqiy1226580990.png") > system("convert tmp/4rpko1226580990.ps tmp/4rpko1226580990.png") > system("convert tmp/5dh141226580990.ps tmp/5dh141226580990.png") > > > proc.time() user system elapsed 2.359 1.313 2.535