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(12055,12113,9617,12646,13581,12162,10970,11880,11888,12927,12300,12093,12381,12197,9455,13168,13428,11981,11885,11692,12234,14341,13131,12421,14286,12865,11160,14316,14389,14014,13419,12770,13316,15333,14243,13824,14963,13203,12199,15509,14200,15170,14058,13786,14148,16542,13588,15582,15803,14131,12923,15612,16034,16037,14038,15331,15038,17402,14993,16044,16930,15921,14417,15961,17852,16484,14216,17430,17840,17629) > #'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.7478207 0.7481725 0.7485235 0.7488735 0.7492226 0.7495707 0.7499180 [8] 0.7502642 0.7506096 0.7509540 0.7512974 0.7516400 0.7519815 0.7523222 [15] 0.7526619 0.7530006 0.7533384 0.7536753 0.7540112 0.7543462 0.7546802 [22] 0.7550133 0.7553454 0.7556765 0.7560067 0.7563360 0.7566643 0.7569917 [29] 0.7573181 0.7576435 0.7579680 0.7582915 0.7586141 0.7589357 0.7592564 [36] 0.7595761 0.7598948 0.7602126 0.7605294 0.7608453 0.7611602 0.7614741 [43] 0.7617871 0.7620991 0.7624101 0.7627202 0.7630293 0.7633374 0.7636446 [50] 0.7639508 0.7642561 0.7645603 0.7648636 0.7651660 0.7654674 0.7657678 [57] 0.7660672 0.7663657 0.7666632 0.7669597 0.7672552 0.7675498 0.7678434 [64] 0.7681361 0.7684278 0.7687185 0.7690082 0.7692969 0.7695847 0.7698715 [71] 0.7701574 0.7704422 0.7707261 0.7710091 0.7712910 0.7715720 0.7718520 [78] 0.7721310 0.7724091 0.7726861 0.7729623 0.7732374 0.7735115 0.7737847 [85] 0.7740569 0.7743282 0.7745985 0.7748677 0.7751361 0.7754034 0.7756698 [92] 0.7759352 0.7761996 0.7764631 0.7767255 0.7769870 0.7772476 0.7775071 [99] 0.7777657 0.7780233 0.7782800 0.7785357 0.7787904 0.7790441 0.7792968 [106] 0.7795486 0.7797995 0.7800493 0.7802982 0.7805461 0.7807930 0.7810390 [113] 0.7812840 0.7815280 0.7817711 0.7820132 0.7822543 0.7824945 0.7827337 [120] 0.7829719 0.7832091 0.7834454 0.7836808 0.7839151 0.7841485 0.7843810 [127] 0.7846124 0.7848429 0.7850725 0.7853011 0.7855287 0.7857554 0.7859811 [134] 0.7862058 0.7864296 0.7866524 0.7868743 0.7870952 0.7873151 0.7875341 [141] 0.7877521 0.7879692 0.7881854 0.7884005 0.7886147 0.7888280 0.7890403 [148] 0.7892517 0.7894621 0.7896715 0.7898801 0.7900876 0.7902942 0.7904999 [155] 0.7907046 0.7909084 0.7911112 0.7913131 0.7915140 0.7917140 0.7919131 [162] 0.7921112 0.7923083 0.7925046 0.7926998 0.7928942 0.7930876 0.7932801 [169] 0.7934716 0.7936622 0.7938519 0.7940406 0.7942284 0.7944153 0.7946012 [176] 0.7947862 0.7949703 0.7951535 0.7953357 0.7955170 0.7956974 0.7958768 [183] 0.7960553 0.7962329 0.7964096 0.7965854 0.7967602 0.7969341 0.7971071 [190] 0.7972792 0.7974503 0.7976206 0.7977899 0.7979584 0.7981259 0.7982925 [197] 0.7984581 0.7986229 0.7987868 0.7989498 0.7991118 0.7992730 0.7994332 [204] 0.7995926 0.7997510 0.7999085 0.8000652 0.8002209 0.8003758 0.8005297 [211] 0.8006828 0.8008349 0.8009862 0.8011366 0.8012861 0.8014346 0.8015824 [218] 0.8017292 0.8018751 0.8020201 0.8021643 0.8023076 0.8024500 0.8025915 [225] 0.8027321 0.8028719 0.8030108 0.8031488 0.8032859 0.8034222 0.8035575 [232] 0.8036921 0.8038257 0.8039585 0.8040904 0.8042214 0.8043516 0.8044809 [239] 0.8046094 0.8047370 0.8048637 0.8049896 0.8051146 0.8052387 0.8053620 [246] 0.8054845 0.8056061 0.8057268 0.8058467 0.8059657 0.8060839 0.8062013 [253] 0.8063178 0.8064335 0.8065483 0.8066623 0.8067754 0.8068877 0.8069992 [260] 0.8071098 0.8072196 0.8073286 0.8074367 0.8075440 0.8076505 0.8077561 [267] 0.8078609 0.8079649 0.8080681 0.8081704 0.8082720 0.8083727 0.8084725 [274] 0.8085716 0.8086699 0.8087673 0.8088639 0.8089598 0.8090548 0.8091490 [281] 0.8092424 0.8093349 0.8094267 0.8095177 0.8096079 0.8096973 0.8097858 [288] 0.8098736 0.8099606 0.8100468 0.8101322 0.8102168 0.8103006 0.8103836 [295] 0.8104659 0.8105473 0.8106280 0.8107079 0.8107870 0.8108653 0.8109428 [302] 0.8110196 0.8110956 0.8111708 0.8112452 0.8113189 0.8113918 0.8114639 [309] 0.8115353 0.8116058 0.8116757 0.8117447 0.8118130 0.8118806 0.8119474 [316] 0.8120134 0.8120787 0.8121432 0.8122069 0.8122699 0.8123322 0.8123937 [323] 0.8124545 0.8125145 0.8125738 0.8126323 0.8126901 0.8127471 0.8128034 [330] 0.8128590 0.8129138 0.8129679 0.8130213 0.8130740 0.8131259 0.8131770 [337] 0.8132275 0.8132772 0.8133262 0.8133745 0.8134221 0.8134689 0.8135150 [344] 0.8135604 0.8136051 0.8136491 0.8136924 0.8137349 0.8137768 0.8138179 [351] 0.8138583 0.8138980 0.8139371 0.8139754 0.8140130 0.8140499 0.8140862 [358] 0.8141217 0.8141565 0.8141907 0.8142241 0.8142569 0.8142889 0.8143203 [365] 0.8143510 0.8143810 0.8144104 0.8144390 0.8144670 0.8144943 0.8145209 [372] 0.8145468 0.8145721 0.8145967 0.8146206 0.8146439 0.8146664 0.8146884 [379] 0.8147096 0.8147302 0.8147501 0.8147694 0.8147880 0.8148060 0.8148233 [386] 0.8148399 0.8148559 0.8148712 0.8148859 0.8149000 0.8149134 0.8149261 [393] 0.8149382 0.8149497 0.8149605 0.8149707 0.8149802 0.8149891 0.8149974 [400] 0.8150050 0.8150120 > mx [1] 0.815012 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1jzc11226257355.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/24d0m1226257355.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/35qx71226257355.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/4dvs71226257355.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/5dfvi1226257355.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/664yn1226257355.tab") > > system("convert tmp/1jzc11226257355.ps tmp/1jzc11226257355.png") > system("convert tmp/24d0m1226257355.ps tmp/24d0m1226257355.png") > system("convert tmp/35qx71226257355.ps tmp/35qx71226257355.png") > system("convert tmp/4dvs71226257355.ps tmp/4dvs71226257355.png") > system("convert tmp/5dfvi1226257355.ps tmp/5dfvi1226257355.png") > > > proc.time() user system elapsed 1.270 0.788 1.641