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(63.1,63,74.9,64.7,68.5,73.9,57.3,62.5,75.7,73.5,71,76.1,65,66.3,74.4,71.1,71.9,75.7,64.3,62.6,75.3,80.3,72.2,80.3,71.3,70.7,77.5,79.2,75.4,83.4,72.9,68.4,85,86.2,76.7,91.2,76,77,87.3,83.1,81.1,88.4,76.7,70.9,85.9,84.8,79.6,89.9,74,74.8,91.4,84.1,80,92.2,77.3,78.1,93.6,92.9,89.8,101.8,84.8,90.8,106.8,92.2,101.5,101.6,86,89.7,106.3,107.8,106.7,118.1,100.3,97.5,112.9,101.3,107.8,110.3,94.6,93.9,104.8,109.4,107.6,112.3,99,99.9,111.1,111.2,109.5,111.6,102.2,94.5,114.4,116.8,110.5,121.1,106.3,104.6,117.3,112.4,107.5,116.9,104.9,95.9,121.5,124.1,110.7,128.1,108.9,111.2,131.9,120.5,115.4,130.8,112.6,111.1,129.5,131.8,127.7,142.6,115.8,119.5,139.8,130.6,126.2,141.7,118.9,120.3,141.2,138.9,141.3,153.7,131,136.5,160.1,139.8,143.8) > #'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.8960791 0.8963441 0.8966081 0.8968712 0.8971333 0.8973945 0.8976547 [8] 0.8979140 0.8981723 0.8984296 0.8986859 0.8989413 0.8991958 0.8994492 [15] 0.8997017 0.8999532 0.9002037 0.9004532 0.9007017 0.9009493 0.9011959 [22] 0.9014414 0.9016860 0.9019296 0.9021722 0.9024138 0.9026544 0.9028940 [29] 0.9031326 0.9033702 0.9036067 0.9038423 0.9040768 0.9043104 0.9045429 [36] 0.9047744 0.9050048 0.9052343 0.9054627 0.9056901 0.9059164 0.9061418 [43] 0.9063660 0.9065893 0.9068115 0.9070327 0.9072528 0.9074719 0.9076899 [50] 0.9079069 0.9081229 0.9083377 0.9085516 0.9087643 0.9089761 0.9091867 [57] 0.9093963 0.9096048 0.9098123 0.9100187 0.9102240 0.9104282 0.9106314 [64] 0.9108335 0.9110345 0.9112344 0.9114333 0.9116310 0.9118277 0.9120233 [71] 0.9122178 0.9124112 0.9126035 0.9127947 0.9129848 0.9131738 0.9133617 [78] 0.9135485 0.9137342 0.9139188 0.9141023 0.9142847 0.9144659 0.9146461 [85] 0.9148251 0.9150030 0.9151798 0.9153555 0.9155300 0.9157034 0.9158757 [92] 0.9160468 0.9162169 0.9163857 0.9165535 0.9167201 0.9168856 0.9170499 [99] 0.9172131 0.9173751 0.9175360 0.9176958 0.9178544 0.9180118 0.9181681 [106] 0.9183233 0.9184772 0.9186301 0.9187817 0.9189322 0.9190816 0.9192297 [113] 0.9193767 0.9195226 0.9196672 0.9198107 0.9199531 0.9200942 0.9202342 [120] 0.9203729 0.9205106 0.9206470 0.9207822 0.9209163 0.9210491 0.9211808 [127] 0.9213113 0.9214406 0.9215687 0.9216956 0.9218214 0.9219459 0.9220692 [134] 0.9221913 0.9223122 0.9224319 0.9225504 0.9226677 0.9227838 0.9228987 [141] 0.9230124 0.9231248 0.9232361 0.9233461 0.9234549 0.9235625 0.9236689 [148] 0.9237740 0.9238779 0.9239806 0.9240821 0.9241824 0.9242814 0.9243792 [155] 0.9244757 0.9245711 0.9246652 0.9247580 0.9248496 0.9249400 0.9250292 [162] 0.9251171 0.9252037 0.9252891 0.9253733 0.9254563 0.9255379 0.9256184 [169] 0.9256976 0.9257755 0.9258522 0.9259276 0.9260018 0.9260747 0.9261464 [176] 0.9262168 0.9262860 0.9263539 0.9264205 0.9264859 0.9265500 0.9266128 [183] 0.9266744 0.9267347 0.9267938 0.9268515 0.9269081 0.9269633 0.9270173 [190] 0.9270700 0.9271214 0.9271715 0.9272204 0.9272680 0.9273143 0.9273594 [197] 0.9274031 0.9274456 0.9274868 0.9275268 0.9275654 0.9276028 0.9276388 [204] 0.9276736 0.9277071 0.9277394 0.9277703 0.9277999 0.9278283 0.9278553 [211] 0.9278811 0.9279056 0.9279288 0.9279507 0.9279713 0.9279906 0.9280086 [218] 0.9280254 0.9280408 0.9280549 0.9280677 0.9280793 0.9280895 0.9280985 [225] 0.9281061 0.9281124 0.9281175 0.9281212 0.9281237 0.9281248 0.9281246 [232] 0.9281231 0.9281204 0.9281163 0.9281109 0.9281042 0.9280962 0.9280869 [239] 0.9280763 0.9280644 0.9280512 0.9280367 0.9280208 0.9280037 0.9279852 [246] 0.9279655 0.9279444 0.9279220 0.9278984 0.9278734 0.9278471 0.9278194 [253] 0.9277905 0.9277603 0.9277287 0.9276959 0.9276617 0.9276262 0.9275895 [260] 0.9275514 0.9275119 0.9274712 0.9274292 0.9273858 0.9273412 0.9272952 [267] 0.9272479 0.9271994 0.9271495 0.9270982 0.9270457 0.9269919 0.9269367 [274] 0.9268803 0.9268225 0.9267634 0.9267031 0.9266414 0.9265784 0.9265140 [281] 0.9264484 0.9263815 0.9263132 0.9262437 0.9261728 0.9261006 0.9260271 [288] 0.9259524 0.9258763 0.9257989 0.9257201 0.9256401 0.9255588 0.9254762 [295] 0.9253922 0.9253070 0.9252204 0.9251326 0.9250434 0.9249530 0.9248612 [302] 0.9247682 0.9246738 0.9245782 0.9244812 0.9243829 0.9242834 0.9241825 [309] 0.9240804 0.9239769 0.9238722 0.9237661 0.9236588 0.9235501 0.9234402 [316] 0.9233290 0.9232165 0.9231027 0.9229876 0.9228712 0.9227535 0.9226345 [323] 0.9225143 0.9223927 0.9222699 0.9221458 0.9220204 0.9218938 0.9217658 [330] 0.9216366 0.9215060 0.9213742 0.9212412 0.9211068 0.9209712 0.9208343 [337] 0.9206961 0.9205567 0.9204159 0.9202739 0.9201307 0.9199861 0.9198403 [344] 0.9196933 0.9195450 0.9193954 0.9192445 0.9190924 0.9189390 0.9187844 [351] 0.9186285 0.9184713 0.9183129 0.9181533 0.9179924 0.9178302 0.9176668 [358] 0.9175021 0.9173362 0.9171691 0.9170007 0.9168310 0.9166602 0.9164881 [365] 0.9163147 0.9161401 0.9159643 0.9157872 0.9156089 0.9154294 0.9152486 [372] 0.9150667 0.9148835 0.9146990 0.9145134 0.9143265 0.9141384 0.9139491 [379] 0.9137586 0.9135668 0.9133739 0.9131797 0.9129843 0.9127878 0.9125900 [386] 0.9123910 0.9121908 0.9119894 0.9117868 0.9115830 0.9113781 0.9111719 [393] 0.9109645 0.9107560 0.9105462 0.9103353 0.9101232 0.9099099 0.9096954 [400] 0.9094798 0.9092630 > mx [1] 0.9281248 > mxli [1] 0.29 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/11p611194176878.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/2sz1d1194176878.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/3s94v1194176878.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/45sxo1194176878.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/5oasm1194176878.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/64itc1194176879.tab") > > system("convert tmp/11p611194176878.ps tmp/11p611194176878.png") > system("convert tmp/2sz1d1194176878.ps tmp/2sz1d1194176878.png") > system("convert tmp/3s94v1194176878.ps tmp/3s94v1194176878.png") > system("convert tmp/45sxo1194176878.ps tmp/45sxo1194176878.png") > system("convert tmp/5oasm1194176878.ps tmp/5oasm1194176878.png") > > > proc.time() user system elapsed 2.405 1.329 2.589