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(14271,14013,15912,14290,14744,14721,13918,13263,15660,15629,15113,14526,15132,14908,16167,14122,13985,14236,13921,12394,15454,16146,15107,14593,14695,14513,17071,15179,15460,17173,15938,15003,18216,17847,18029,17281,16706,16750,18912,17763,16736,18061,16713,16769,19514,19251,19951,19052,19555,19083,22534,18854,19801,20346,18169,19087,20842,21602,22360,20334,21215,20530,23152,20134,21193,21628,20823,20493,22106,24178,24958,21620) > #'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.8533473 0.8535308 0.8537137 0.8538959 0.8540776 0.8542586 0.8544390 [8] 0.8546187 0.8547978 0.8549763 0.8551542 0.8553314 0.8555080 0.8556839 [15] 0.8558593 0.8560340 0.8562080 0.8563815 0.8565543 0.8567264 0.8568979 [22] 0.8570688 0.8572391 0.8574087 0.8575777 0.8577460 0.8579137 0.8580808 [29] 0.8582472 0.8584130 0.8585782 0.8587427 0.8589066 0.8590698 0.8592324 [36] 0.8593943 0.8595556 0.8597163 0.8598763 0.8600357 0.8601945 0.8603525 [43] 0.8605100 0.8606668 0.8608230 0.8609785 0.8611333 0.8612876 0.8614411 [50] 0.8615941 0.8617463 0.8618980 0.8620489 0.8621993 0.8623490 0.8624980 [57] 0.8626464 0.8627941 0.8629412 0.8630876 0.8632334 0.8633785 0.8635230 [64] 0.8636668 0.8638100 0.8639525 0.8640944 0.8642356 0.8643761 0.8645160 [71] 0.8646552 0.8647938 0.8649318 0.8650690 0.8652056 0.8653416 0.8654769 [78] 0.8656115 0.8657455 0.8658788 0.8660115 0.8661435 0.8662748 0.8664055 [85] 0.8665355 0.8666649 0.8667936 0.8669216 0.8670490 0.8671757 0.8673018 [92] 0.8674271 0.8675519 0.8676759 0.8677993 0.8679220 0.8680441 0.8681655 [99] 0.8682862 0.8684063 0.8685257 0.8686444 0.8687625 0.8688799 0.8689966 [106] 0.8691126 0.8692280 0.8693427 0.8694568 0.8695702 0.8696829 0.8697949 [113] 0.8699063 0.8700170 0.8701270 0.8702364 0.8703450 0.8704530 0.8705604 [120] 0.8706670 0.8707730 0.8708783 0.8709830 0.8710869 0.8711902 0.8712928 [127] 0.8713948 0.8714960 0.8715966 0.8716965 0.8717958 0.8718943 0.8719922 [134] 0.8720894 0.8721859 0.8722818 0.8723770 0.8724714 0.8725653 0.8726584 [141] 0.8727508 0.8728426 0.8729337 0.8730241 0.8731138 0.8732029 0.8732912 [148] 0.8733789 0.8734659 0.8735523 0.8736379 0.8737228 0.8738071 0.8738907 [155] 0.8739736 0.8740558 0.8741374 0.8742182 0.8742984 0.8743778 0.8744566 [162] 0.8745347 0.8746122 0.8746889 0.8747650 0.8748403 0.8749150 0.8749890 [169] 0.8750623 0.8751349 0.8752068 0.8752781 0.8753486 0.8754185 0.8754876 [176] 0.8755561 0.8756239 0.8756910 0.8757574 0.8758232 0.8758882 0.8759525 [183] 0.8760162 0.8760791 0.8761414 0.8762030 0.8762639 0.8763241 0.8763836 [190] 0.8764424 0.8765005 0.8765579 0.8766146 0.8766707 0.8767260 0.8767807 [197] 0.8768346 0.8768879 0.8769404 0.8769923 0.8770435 0.8770940 0.8771438 [204] 0.8771928 0.8772412 0.8772889 0.8773359 0.8773823 0.8774279 0.8774728 [211] 0.8775170 0.8775605 0.8776033 0.8776455 0.8776869 0.8777276 0.8777677 [218] 0.8778070 0.8778457 0.8778836 0.8779208 0.8779574 0.8779932 0.8780284 [225] 0.8780628 0.8780966 0.8781296 0.8781620 0.8781936 0.8782246 0.8782548 [232] 0.8782844 0.8783132 0.8783414 0.8783688 0.8783956 0.8784216 0.8784470 [239] 0.8784716 0.8784956 0.8785188 0.8785414 0.8785632 0.8785844 0.8786048 [246] 0.8786246 0.8786436 0.8786619 0.8786796 0.8786965 0.8787127 0.8787283 [253] 0.8787431 0.8787572 0.8787706 0.8787834 0.8787954 0.8788067 0.8788173 [260] 0.8788272 0.8788364 0.8788449 0.8788527 0.8788598 0.8788662 0.8788719 [267] 0.8788769 0.8788812 0.8788848 0.8788877 0.8788898 0.8788913 0.8788921 [274] 0.8788921 0.8788915 0.8788901 0.8788881 0.8788854 0.8788819 0.8788777 [281] 0.8788729 0.8788673 0.8788610 0.8788541 0.8788464 0.8788380 0.8788289 [288] 0.8788192 0.8788087 0.8787975 0.8787856 0.8787730 0.8787597 0.8787456 [295] 0.8787309 0.8787155 0.8786994 0.8786826 0.8786650 0.8786468 0.8786279 [302] 0.8786082 0.8785879 0.8785668 0.8785451 0.8785226 0.8784995 0.8784756 [309] 0.8784511 0.8784258 0.8783998 0.8783732 0.8783458 0.8783177 0.8782889 [316] 0.8782594 0.8782292 0.8781984 0.8781668 0.8781345 0.8781015 0.8780678 [323] 0.8780334 0.8779983 0.8779625 0.8779260 0.8778888 0.8778508 0.8778122 [330] 0.8777729 0.8777329 0.8776922 0.8776508 0.8776086 0.8775658 0.8775223 [337] 0.8774781 0.8774332 0.8773875 0.8773412 0.8772942 0.8772465 0.8771981 [344] 0.8771489 0.8770991 0.8770486 0.8769974 0.8769455 0.8768928 0.8768395 [351] 0.8767855 0.8767308 0.8766754 0.8766193 0.8765625 0.8765050 0.8764468 [358] 0.8763879 0.8763283 0.8762680 0.8762070 0.8761453 0.8760829 0.8760199 [365] 0.8759561 0.8758916 0.8758265 0.8757606 0.8756941 0.8756268 0.8755589 [372] 0.8754902 0.8754209 0.8753509 0.8752802 0.8752088 0.8751367 0.8750639 [379] 0.8749904 0.8749162 0.8748413 0.8747658 0.8746895 0.8746126 0.8745349 [386] 0.8744566 0.8743776 0.8742979 0.8742175 0.8741364 0.8740546 0.8739722 [393] 0.8738890 0.8738052 0.8737207 0.8736355 0.8735496 0.8734630 0.8733757 [400] 0.8732878 0.8731991 > mx [1] 0.8788921 > mxli [1] 0.73 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/18xvl1257505456.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/28s2f1257505456.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/3syyv1257505456.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/49km11257505456.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/5cj1v1257505456.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/6ut201257505456.tab") > > system("convert tmp/18xvl1257505456.ps tmp/18xvl1257505456.png") > system("convert tmp/28s2f1257505456.ps tmp/28s2f1257505456.png") > system("convert tmp/3syyv1257505456.ps tmp/3syyv1257505456.png") > system("convert tmp/49km11257505456.ps tmp/49km11257505456.png") > system("convert tmp/5cj1v1257505456.ps tmp/5cj1v1257505456.png") > > > proc.time() user system elapsed 1.085 0.781 4.460