R version 2.6.1 (2007-11-26) 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(102.61,102.18,101.64,102,102.18,101.89,102.09,101.6,101.33,101.44,101.49,100.41,101.38,101.4,102.16,104.46,104.75,104.2,106.05,107.54,108.23,108.99,109.51,111.99,111.08,112.95,115.49,114.67,116.85,119.57,119.41,118.46,122.81,121.76,121.37,118.61,116.08,117.84,117.02,119.78,122.58,120.98,118.92,117.81,119.73,117.16,116.03,115.55,115.36,116.09,117.32,120.45,119.86,118.51,118.92,119.11,120.34,121.23,119.43,119.28,120.64,122.24,123.1,120.72,118.34,118.8,119.29,121.47,122.35,121.53,121.72,121.58,121.55,122.02,123.74,125.8,129.29,128.89,130.04,131.57,131.97,134.43,132.63,130.26,129,131.65,134.21,138.63,138.1,140.51,144.36,145.57,148.7,147.86,143.16,141.96) > #'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.9376065 0.9376661 0.9377254 0.9377844 0.9378431 0.9379015 0.9379596 [8] 0.9380174 0.9380750 0.9381322 0.9381891 0.9382457 0.9383020 0.9383580 [15] 0.9384137 0.9384691 0.9385242 0.9385790 0.9386335 0.9386877 0.9387415 [22] 0.9387951 0.9388484 0.9389013 0.9389540 0.9390063 0.9390583 0.9391100 [29] 0.9391614 0.9392125 0.9392633 0.9393137 0.9393639 0.9394137 0.9394632 [36] 0.9395124 0.9395613 0.9396098 0.9396581 0.9397060 0.9397536 0.9398009 [43] 0.9398479 0.9398946 0.9399409 0.9399869 0.9400326 0.9400780 0.9401230 [50] 0.9401677 0.9402121 0.9402562 0.9402999 0.9403434 0.9403865 0.9404292 [57] 0.9404717 0.9405138 0.9405556 0.9405970 0.9406382 0.9406790 0.9407194 [64] 0.9407596 0.9407994 0.9408389 0.9408780 0.9409168 0.9409553 0.9409934 [71] 0.9410312 0.9410687 0.9411058 0.9411426 0.9411791 0.9412152 0.9412510 [78] 0.9412865 0.9413216 0.9413563 0.9413908 0.9414249 0.9414586 0.9414920 [85] 0.9415251 0.9415578 0.9415902 0.9416222 0.9416539 0.9416853 0.9417163 [92] 0.9417469 0.9417773 0.9418072 0.9418368 0.9418661 0.9418950 0.9419236 [99] 0.9419519 0.9419797 0.9420073 0.9420345 0.9420613 0.9420878 0.9421139 [106] 0.9421397 0.9421651 0.9421902 0.9422149 0.9422392 0.9422632 0.9422869 [113] 0.9423102 0.9423331 0.9423557 0.9423780 0.9423998 0.9424213 0.9424425 [120] 0.9424633 0.9424837 0.9425038 0.9425236 0.9425429 0.9425619 0.9425806 [127] 0.9425988 0.9426167 0.9426343 0.9426515 0.9426683 0.9426848 0.9427009 [134] 0.9427166 0.9427320 0.9427470 0.9427616 0.9427759 0.9427898 0.9428034 [141] 0.9428165 0.9428293 0.9428418 0.9428538 0.9428655 0.9428769 0.9428878 [148] 0.9428984 0.9429086 0.9429185 0.9429280 0.9429371 0.9429458 0.9429542 [155] 0.9429622 0.9429698 0.9429770 0.9429839 0.9429904 0.9429965 0.9430022 [162] 0.9430076 0.9430126 0.9430172 0.9430215 0.9430253 0.9430288 0.9430319 [169] 0.9430346 0.9430370 0.9430390 0.9430406 0.9430418 0.9430426 0.9430431 [176] 0.9430431 0.9430428 0.9430421 0.9430411 0.9430396 0.9430378 0.9430356 [183] 0.9430330 0.9430300 0.9430266 0.9430229 0.9430188 0.9430142 0.9430093 [190] 0.9430041 0.9429984 0.9429923 0.9429859 0.9429791 0.9429719 0.9429643 [197] 0.9429563 0.9429479 0.9429391 0.9429300 0.9429204 0.9429105 0.9429002 [204] 0.9428895 0.9428784 0.9428669 0.9428551 0.9428428 0.9428301 0.9428171 [211] 0.9428037 0.9427898 0.9427756 0.9427610 0.9427460 0.9427306 0.9427149 [218] 0.9426987 0.9426821 0.9426651 0.9426478 0.9426300 0.9426119 0.9425934 [225] 0.9425744 0.9425551 0.9425354 0.9425153 0.9424948 0.9424739 0.9424526 [232] 0.9424309 0.9424088 0.9423863 0.9423634 0.9423401 0.9423165 0.9422924 [239] 0.9422679 0.9422431 0.9422178 0.9421921 0.9421661 0.9421396 0.9421128 [246] 0.9420855 0.9420579 0.9420298 0.9420014 0.9419725 0.9419433 0.9419136 [253] 0.9418836 0.9418531 0.9418223 0.9417910 0.9417594 0.9417273 0.9416949 [260] 0.9416620 0.9416288 0.9415951 0.9415611 0.9415266 0.9414918 0.9414565 [267] 0.9414209 0.9413848 0.9413484 0.9413115 0.9412743 0.9412366 0.9411985 [274] 0.9411601 0.9411212 0.9410819 0.9410423 0.9410022 0.9409617 0.9409208 [281] 0.9408795 0.9408378 0.9407958 0.9407533 0.9407104 0.9406671 0.9406234 [288] 0.9405793 0.9405347 0.9404898 0.9404445 0.9403988 0.9403527 0.9403061 [295] 0.9402592 0.9402119 0.9401641 0.9401160 0.9400675 0.9400185 0.9399692 [302] 0.9399194 0.9398692 0.9398187 0.9397677 0.9397163 0.9396645 0.9396124 [309] 0.9395598 0.9395068 0.9394534 0.9393996 0.9393454 0.9392908 0.9392358 [316] 0.9391803 0.9391245 0.9390683 0.9390117 0.9389546 0.9388972 0.9388394 [323] 0.9387811 0.9387225 0.9386634 0.9386040 0.9385441 0.9384838 0.9384232 [330] 0.9383621 0.9383006 0.9382387 0.9381765 0.9381138 0.9380507 0.9379872 [337] 0.9379233 0.9378590 0.9377943 0.9377292 0.9376637 0.9375978 0.9375314 [344] 0.9374647 0.9373976 0.9373301 0.9372622 0.9371938 0.9371251 0.9370560 [351] 0.9369864 0.9369165 0.9368461 0.9367754 0.9367043 0.9366327 0.9365608 [358] 0.9364884 0.9364157 0.9363425 0.9362690 0.9361950 0.9361206 0.9360459 [365] 0.9359707 0.9358952 0.9358192 0.9357429 0.9356661 0.9355889 0.9355114 [372] 0.9354334 0.9353551 0.9352763 0.9351972 0.9351176 0.9350377 0.9349573 [379] 0.9348765 0.9347954 0.9347139 0.9346319 0.9345496 0.9344668 0.9343837 [386] 0.9343002 0.9342162 0.9341319 0.9340472 0.9339621 0.9338765 0.9337906 [393] 0.9337043 0.9336176 0.9335305 0.9334430 0.9333551 0.9332668 0.9331782 [400] 0.9330891 0.9329996 > mx [1] 0.9430431 > mxli [1] -0.25 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1ekyr1197554252.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/2rvr01197554252.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/369dr1197554252.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/48ixn1197554252.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/5s02u1197554252.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/61ht61197554252.tab") > > system("convert tmp/1ekyr1197554252.ps tmp/1ekyr1197554252.png") > system("convert tmp/2rvr01197554252.ps tmp/2rvr01197554252.png") > system("convert tmp/369dr1197554252.ps tmp/369dr1197554252.png") > system("convert tmp/48ixn1197554252.ps tmp/48ixn1197554252.png") > system("convert tmp/5s02u1197554252.ps tmp/5s02u1197554252.png") > > > proc.time() user system elapsed 2.373 1.305 2.555