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(96.8,91.2,97.1,104.9,110.9,104.8,94.1,95.8,99.3,101.1,104.0,99.0,105.4,107.1,110.7,117.1,118.7,126.5,127.5,134.6,131.8,135.9,142.7,141.7,153.4,145.0,137.7,148.3,152.2,169.4,168.6,161.1,174.1,179.0,190.6,190.0,181.6,174.8,180.5,196.8,193.8,197.0,216.3,221.4,217.9,229.7,227.4,204.2,196.6,198.8,207.5,190.7,201.6,210.5,223.5,223.8,231.2,244.0,234.7,250.2) > #'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.9049907 0.9052351 0.9054791 0.9057225 0.9059655 0.9062079 0.9064499 [8] 0.9066913 0.9069322 0.9071726 0.9074125 0.9076519 0.9078908 0.9081291 [15] 0.9083669 0.9086041 0.9088408 0.9090770 0.9093126 0.9095477 0.9097822 [22] 0.9100162 0.9102496 0.9104825 0.9107148 0.9109465 0.9111776 0.9114082 [29] 0.9116381 0.9118675 0.9120963 0.9123245 0.9125522 0.9127792 0.9130056 [36] 0.9132314 0.9134566 0.9136812 0.9139051 0.9141285 0.9143512 0.9145733 [43] 0.9147948 0.9150156 0.9152358 0.9154554 0.9156743 0.9158925 0.9161101 [50] 0.9163271 0.9165434 0.9167590 0.9169739 0.9171882 0.9174018 0.9176148 [57] 0.9178270 0.9180386 0.9182495 0.9184597 0.9186692 0.9188780 0.9190861 [64] 0.9192935 0.9195002 0.9197062 0.9199114 0.9201160 0.9203198 0.9205229 [71] 0.9207252 0.9209269 0.9211277 0.9213279 0.9215273 0.9217260 0.9219239 [78] 0.9221210 0.9223175 0.9225131 0.9227080 0.9229021 0.9230954 0.9232880 [85] 0.9234798 0.9236708 0.9238610 0.9240505 0.9242391 0.9244270 0.9246141 [92] 0.9248003 0.9249858 0.9251704 0.9253543 0.9255373 0.9257195 0.9259009 [99] 0.9260815 0.9262612 0.9264401 0.9266182 0.9267955 0.9269719 0.9271474 [106] 0.9273222 0.9274960 0.9276691 0.9278412 0.9280125 0.9281830 0.9283526 [113] 0.9285213 0.9286891 0.9288561 0.9290222 0.9291874 0.9293518 0.9295152 [120] 0.9296778 0.9298395 0.9300002 0.9301601 0.9303191 0.9304772 0.9306344 [127] 0.9307907 0.9309460 0.9311005 0.9312540 0.9314066 0.9315583 0.9317090 [134] 0.9318589 0.9320078 0.9321558 0.9323028 0.9324489 0.9325940 0.9327383 [141] 0.9328815 0.9330238 0.9331652 0.9333056 0.9334451 0.9335836 0.9337211 [148] 0.9338577 0.9339933 0.9341279 0.9342615 0.9343942 0.9345259 0.9346567 [155] 0.9347864 0.9349152 0.9350429 0.9351697 0.9352955 0.9354203 0.9355441 [162] 0.9356669 0.9357887 0.9359095 0.9360293 0.9361481 0.9362659 0.9363827 [169] 0.9364984 0.9366132 0.9367269 0.9368396 0.9369513 0.9370620 0.9371716 [176] 0.9372802 0.9373878 0.9374943 0.9375998 0.9377043 0.9378078 0.9379102 [183] 0.9380115 0.9381118 0.9382111 0.9383093 0.9384065 0.9385026 0.9385977 [190] 0.9386917 0.9387847 0.9388766 0.9389675 0.9390573 0.9391460 0.9392337 [197] 0.9393203 0.9394058 0.9394903 0.9395737 0.9396560 0.9397373 0.9398175 [204] 0.9398966 0.9399746 0.9400516 0.9401275 0.9402023 0.9402760 0.9403487 [211] 0.9404202 0.9404907 0.9405601 0.9406284 0.9406956 0.9407617 0.9408267 [218] 0.9408907 0.9409535 0.9410153 0.9410760 0.9411355 0.9411940 0.9412514 [225] 0.9413077 0.9413628 0.9414169 0.9414699 0.9415218 0.9415726 0.9416222 [232] 0.9416708 0.9417183 0.9417646 0.9418099 0.9418541 0.9418971 0.9419391 [239] 0.9419799 0.9420196 0.9420582 0.9420957 0.9421321 0.9421674 0.9422016 [246] 0.9422347 0.9422667 0.9422975 0.9423272 0.9423559 0.9423834 0.9424098 [253] 0.9424351 0.9424593 0.9424823 0.9425043 0.9425251 0.9425449 0.9425635 [260] 0.9425810 0.9425974 0.9426127 0.9426268 0.9426399 0.9426518 0.9426626 [267] 0.9426724 0.9426810 0.9426885 0.9426948 0.9427001 0.9427043 0.9427073 [274] 0.9427093 0.9427101 0.9427098 0.9427084 0.9427059 0.9427023 0.9426976 [281] 0.9426918 0.9426848 0.9426768 0.9426676 0.9426574 0.9426460 0.9426336 [288] 0.9426200 0.9426054 0.9425896 0.9425727 0.9425547 0.9425357 0.9425155 [295] 0.9424942 0.9424719 0.9424484 0.9424238 0.9423982 0.9423714 0.9423436 [302] 0.9423147 0.9422846 0.9422535 0.9422213 0.9421880 0.9421536 0.9421182 [309] 0.9420816 0.9420440 0.9420053 0.9419655 0.9419246 0.9418826 0.9418396 [316] 0.9417955 0.9417503 0.9417040 0.9416567 0.9416083 0.9415588 0.9415083 [323] 0.9414566 0.9414040 0.9413502 0.9412954 0.9412395 0.9411826 0.9411246 [330] 0.9410656 0.9410055 0.9409443 0.9408821 0.9408188 0.9407545 0.9406892 [337] 0.9406228 0.9405553 0.9404868 0.9404173 0.9403467 0.9402751 0.9402025 [344] 0.9401288 0.9400541 0.9399783 0.9399016 0.9398238 0.9397449 0.9396651 [351] 0.9395842 0.9395024 0.9394195 0.9393355 0.9392506 0.9391647 0.9390777 [358] 0.9389898 0.9389008 0.9388108 0.9387199 0.9386279 0.9385349 0.9384410 [365] 0.9383460 0.9382501 0.9381532 0.9380553 0.9379564 0.9378565 0.9377556 [372] 0.9376538 0.9375510 0.9374472 0.9373424 0.9372367 0.9371300 0.9370223 [379] 0.9369137 0.9368042 0.9366936 0.9365821 0.9364697 0.9363563 0.9362420 [386] 0.9361267 0.9360105 0.9358933 0.9357752 0.9356561 0.9355362 0.9354153 [393] 0.9352934 0.9351707 0.9350470 0.9349224 0.9347969 0.9346705 0.9345431 [400] 0.9344149 0.9342857 > mx [1] 0.94271 > mxli [1] 0.74 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1cbkz1225988516.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/2jo2l1225988516.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/3i8d91225988516.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/4aoti1225988516.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/5otmm1225988516.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(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/6ropk1225988516.tab") > > system("convert tmp/1cbkz1225988516.ps tmp/1cbkz1225988516.png") > system("convert tmp/2jo2l1225988516.ps tmp/2jo2l1225988516.png") > system("convert tmp/3i8d91225988516.ps tmp/3i8d91225988516.png") > system("convert tmp/4aoti1225988516.ps tmp/4aoti1225988516.png") > system("convert tmp/5otmm1225988516.ps tmp/5otmm1225988516.png") > > > proc.time() user system elapsed 1.307 0.803 1.577