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(18.33,22.6,24.9,24.8,23.8,25.1,26,27.4,27.3,24.3,28.4,24.4,30.3,31.5,29.8,25.3,25.6,26.7,27.4,28.6,26.3,28.5,28.4,29.4,30.3,29.6,32.1,32.4,36.3,34.6,36.3,40.3,40.4,45.4,39,35.7,40.2,41.7,49.1,49.6,47,52,53.1,57.8,57.9,54.6,51.3,52.7,58.5,56.6,57.9,64.4,65.1,64.6,68.9,68.8,59.3,55,55.4,58,50.8,54.6,58.6,63.6,64.5,66.9,71.9,68.7,74.2,75.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.9040239 0.9043639 0.9047016 0.9050371 0.9053704 0.9057014 0.9060301 [8] 0.9063566 0.9066809 0.9070029 0.9073228 0.9076403 0.9079557 0.9082689 [15] 0.9085798 0.9088885 0.9091951 0.9094994 0.9098015 0.9101015 0.9103992 [22] 0.9106948 0.9109882 0.9112794 0.9115684 0.9118553 0.9121400 0.9124226 [29] 0.9127030 0.9129812 0.9132573 0.9135313 0.9138031 0.9140728 0.9143403 [36] 0.9146058 0.9148691 0.9151303 0.9153894 0.9156464 0.9159013 0.9161541 [43] 0.9164049 0.9166535 0.9169000 0.9171445 0.9173869 0.9176273 0.9178655 [50] 0.9181018 0.9183359 0.9185681 0.9187981 0.9190262 0.9192522 0.9194762 [57] 0.9196982 0.9199181 0.9201361 0.9203520 0.9205659 0.9207779 0.9209878 [64] 0.9211958 0.9214018 0.9216058 0.9218078 0.9220079 0.9222060 0.9224021 [71] 0.9225964 0.9227886 0.9229789 0.9231673 0.9233538 0.9235383 0.9237209 [78] 0.9239016 0.9240804 0.9242573 0.9244323 0.9246054 0.9247766 0.9249459 [85] 0.9251133 0.9252789 0.9254426 0.9256044 0.9257644 0.9259226 0.9260788 [92] 0.9262333 0.9263859 0.9265367 0.9266856 0.9268327 0.9269780 0.9271215 [99] 0.9272632 0.9274031 0.9275412 0.9276775 0.9278120 0.9279447 0.9280757 [106] 0.9282049 0.9283323 0.9284580 0.9285819 0.9287040 0.9288244 0.9289431 [113] 0.9290600 0.9291752 0.9292887 0.9294004 0.9295105 0.9296188 0.9297254 [120] 0.9298303 0.9299335 0.9300351 0.9301349 0.9302331 0.9303295 0.9304243 [127] 0.9305175 0.9306090 0.9306988 0.9307869 0.9308734 0.9309583 0.9310415 [134] 0.9311231 0.9312031 0.9312814 0.9313581 0.9314332 0.9315067 0.9315786 [141] 0.9316489 0.9317176 0.9317846 0.9318501 0.9319140 0.9319764 0.9320371 [148] 0.9320963 0.9321539 0.9322099 0.9322644 0.9323174 0.9323687 0.9324186 [155] 0.9324669 0.9325136 0.9325589 0.9326026 0.9326447 0.9326854 0.9327245 [162] 0.9327621 0.9327982 0.9328329 0.9328660 0.9328976 0.9329277 0.9329563 [169] 0.9329835 0.9330092 0.9330333 0.9330561 0.9330773 0.9330971 0.9331154 [176] 0.9331323 0.9331477 0.9331617 0.9331742 0.9331853 0.9331950 0.9332032 [183] 0.9332100 0.9332153 0.9332193 0.9332218 0.9332229 0.9332226 0.9332208 [190] 0.9332177 0.9332132 0.9332073 0.9332000 0.9331913 0.9331812 0.9331697 [197] 0.9331568 0.9331426 0.9331270 0.9331100 0.9330917 0.9330720 0.9330509 [204] 0.9330285 0.9330047 0.9329796 0.9329532 0.9329254 0.9328962 0.9328657 [211] 0.9328339 0.9328008 0.9327663 0.9327305 0.9326934 0.9326549 0.9326152 [218] 0.9325741 0.9325318 0.9324881 0.9324431 0.9323968 0.9323493 0.9323004 [225] 0.9322503 0.9321988 0.9321461 0.9320921 0.9320368 0.9319803 0.9319224 [232] 0.9318633 0.9318030 0.9317414 0.9316785 0.9316143 0.9315489 0.9314823 [239] 0.9314144 0.9313452 0.9312748 0.9312032 0.9311304 0.9310562 0.9309809 [246] 0.9309043 0.9308266 0.9307475 0.9306673 0.9305858 0.9305032 0.9304193 [253] 0.9303342 0.9302479 0.9301604 0.9300717 0.9299818 0.9298906 0.9297983 [260] 0.9297048 0.9296101 0.9295143 0.9294172 0.9293190 0.9292195 0.9291189 [267] 0.9290172 0.9289142 0.9288101 0.9287048 0.9285984 0.9284908 0.9283820 [274] 0.9282721 0.9281610 0.9280488 0.9279354 0.9278208 0.9277052 0.9275883 [281] 0.9274704 0.9273513 0.9272311 0.9271097 0.9269872 0.9268636 0.9267389 [288] 0.9266130 0.9264860 0.9263579 0.9262287 0.9260984 0.9259669 0.9258344 [295] 0.9257007 0.9255660 0.9254301 0.9252931 0.9251551 0.9250159 0.9248757 [302] 0.9247344 0.9245920 0.9244485 0.9243039 0.9241582 0.9240115 0.9238637 [309] 0.9237148 0.9235648 0.9234138 0.9232617 0.9231086 0.9229544 0.9227991 [316] 0.9226428 0.9224854 0.9223270 0.9221675 0.9220070 0.9218454 0.9216828 [323] 0.9215192 0.9213545 0.9211888 0.9210221 0.9208543 0.9206855 0.9205157 [330] 0.9203448 0.9201730 0.9200001 0.9198262 0.9196513 0.9194754 0.9192984 [337] 0.9191205 0.9189416 0.9187617 0.9185807 0.9183988 0.9182159 0.9180320 [344] 0.9178471 0.9176612 0.9174744 0.9172865 0.9170977 0.9169079 0.9167171 [351] 0.9165254 0.9163327 0.9161390 0.9159444 0.9157488 0.9155523 0.9153548 [358] 0.9151563 0.9149569 0.9147566 0.9145553 0.9143530 0.9141499 0.9139457 [365] 0.9137407 0.9135347 0.9133278 0.9131200 0.9129112 0.9127015 0.9124909 [372] 0.9122794 0.9120670 0.9118536 0.9116394 0.9114242 0.9112081 0.9109912 [379] 0.9107733 0.9105546 0.9103349 0.9101144 0.9098930 0.9096706 0.9094475 [386] 0.9092234 0.9089984 0.9087726 0.9085459 0.9083184 0.9080899 0.9078607 [393] 0.9076305 0.9073995 0.9071676 0.9069349 0.9067014 0.9064670 0.9062317 [400] 0.9059956 0.9057587 > mx [1] 0.9332229 > mxli [1] -0.14 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1g8t21197036887.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/2mlgk1197036888.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/3k0j01197036888.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/4pfqq1197036888.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/5njwv1197036888.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/62ka21197036888.tab") > > system("convert tmp/1g8t21197036887.ps tmp/1g8t21197036887.png") > system("convert tmp/2mlgk1197036888.ps tmp/2mlgk1197036888.png") > system("convert tmp/3k0j01197036888.ps tmp/3k0j01197036888.png") > system("convert tmp/4pfqq1197036888.ps tmp/4pfqq1197036888.png") > system("convert tmp/5njwv1197036888.ps tmp/5njwv1197036888.png") > > > proc.time() user system elapsed 1.347 0.802 1.845