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(174.1,180.4,182.6,207.1,213.7,186.5,179.1,168.3,156.5,144.3,138.9,137.8,136.3,140.3,149.1,149.2,140.4,129,124.7,130.8,130.1,133.2,130.1,126.6,124.8,125.3,126.9,120.1,118.7,117.7,113.4,107.5,107.6,114.3,114.9,111.2,109.9,108.6,109.2,106.4,103.7,103,96.9,104.7,102.2,99,95.8,94.5,102.7,103.2,105.6,103.9,107.2,100.7,92.1,90.3,93.4,98.5,100.8,102.3,104.7,101.1,101.4,99.5,98.4,96.3,100.7,101.2,100.3,97.8,97.4,98.6,99.7,99,98.1,97,98.5,103.8,114.4,124.5,134.2,131.8,125.6,119.9,114.9,115.5,112.5,111.4,115.3,110.8,103.7,111.1,113,111.2,117.6,121.7,127.3,129.8,137.1,141.4,137.4,130.7,117.2,110.8,111.4,108.2,108.8,110.2,109.5,109.5,116,111.2,112.1,114,119.1,114.1,115.1,115.4,110.8,116,119.2,126.5,127.8,131.3,140.3,137.3,143,134.5,139.9,159.3,170.4,175,175.8,180.9,180.3,169.6,172.3,184.8,177.7,184.6,211.4) > #'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.06173524 0.06169510 0.06165495 0.06161478 0.06157461 0.06153443 [7] 0.06149423 0.06145402 0.06141381 0.06137358 0.06133334 0.06129309 [13] 0.06125283 0.06121256 0.06117228 0.06113198 0.06109168 0.06105136 [19] 0.06101103 0.06097069 0.06093035 0.06088998 0.06084961 0.06080923 [25] 0.06076883 0.06072843 0.06068801 0.06064758 0.06060714 0.06056669 [31] 0.06052622 0.06048575 0.06044526 0.06040476 0.06036425 0.06032373 [37] 0.06028320 0.06024265 0.06020209 0.06016152 0.06012094 0.06008035 [43] 0.06003974 0.05999912 0.05995849 0.05991785 0.05987719 0.05983652 [49] 0.05979584 0.05975515 0.05971444 0.05967373 0.05963300 0.05959225 [55] 0.05955150 0.05951073 0.05946994 0.05942915 0.05938834 0.05934752 [61] 0.05930668 0.05926584 0.05922498 0.05918410 0.05914321 0.05910231 [67] 0.05906140 0.05902047 0.05897953 0.05893857 0.05889760 0.05885661 [73] 0.05881562 0.05877460 0.05873358 0.05869254 0.05865148 0.05861041 [79] 0.05856933 0.05852823 0.05848712 0.05844599 0.05840485 0.05836369 [85] 0.05832252 0.05828133 0.05824013 0.05819891 0.05815768 0.05811643 [91] 0.05807517 0.05803389 0.05799259 0.05795128 0.05790996 0.05786862 [97] 0.05782726 0.05778588 0.05774449 0.05770309 0.05766166 0.05762022 [103] 0.05757877 0.05753730 0.05749581 0.05745430 0.05741278 0.05737124 [109] 0.05732968 0.05728811 0.05724651 0.05720491 0.05716328 0.05712163 [115] 0.05707997 0.05703829 0.05699659 0.05695488 0.05691315 0.05687139 [121] 0.05682962 0.05678783 0.05674603 0.05670420 0.05666236 0.05662049 [127] 0.05657861 0.05653671 0.05649479 0.05645285 0.05641089 0.05636891 [133] 0.05632691 0.05628489 0.05624285 0.05620079 0.05615871 0.05611661 [139] 0.05607449 0.05603235 0.05599019 0.05594801 0.05590581 0.05586358 [145] 0.05582134 0.05577907 0.05573679 0.05569448 0.05565215 0.05560980 [151] 0.05556742 0.05552503 0.05548261 0.05544017 0.05539771 0.05535523 [157] 0.05531272 0.05527019 0.05522764 0.05518506 0.05514246 0.05509984 [163] 0.05505720 0.05501453 0.05497184 0.05492912 0.05488638 0.05484362 [169] 0.05480083 0.05475802 0.05471518 0.05467232 0.05462943 0.05458652 [175] 0.05454359 0.05450063 0.05445764 0.05441463 0.05437159 0.05432853 [181] 0.05428544 0.05424233 0.05419919 0.05415602 0.05411283 0.05406961 [187] 0.05402636 0.05398309 0.05393979 0.05389647 0.05385311 0.05380973 [193] 0.05376632 0.05372289 0.05367942 0.05363593 0.05359241 0.05354887 [199] 0.05350529 0.05346168 0.05341805 0.05337439 0.05333070 0.05328698 [205] 0.05324323 0.05319945 0.05315564 0.05311181 0.05306794 0.05302404 [211] 0.05298011 0.05293616 0.05289217 0.05284815 0.05280410 0.05276002 [217] 0.05271591 0.05267177 0.05262760 0.05258339 0.05253915 0.05249489 [223] 0.05245059 0.05240625 0.05236189 0.05231749 0.05227306 0.05222860 [229] 0.05218411 0.05213958 0.05209502 0.05205043 0.05200580 0.05196114 [235] 0.05191644 0.05187172 0.05182695 0.05178216 0.05173733 0.05169246 [241] 0.05164756 0.05160263 0.05155766 0.05151265 0.05146761 0.05142254 [247] 0.05137743 0.05133228 0.05128710 0.05124188 0.05119663 0.05115134 [253] 0.05110601 0.05106064 0.05101524 0.05096981 0.05092433 0.05087882 [259] 0.05083327 0.05078768 0.05074206 0.05069640 0.05065070 0.05060496 [265] 0.05055918 0.05051337 0.05046751 0.05042162 0.05037569 0.05032972 [271] 0.05028371 0.05023766 0.05019157 0.05014544 0.05009927 0.05005307 [277] 0.05000682 0.04996053 0.04991420 0.04986783 0.04982142 0.04977497 [283] 0.04972847 0.04968194 0.04963537 0.04958875 0.04954209 0.04949539 [289] 0.04944865 0.04940187 0.04935504 0.04930817 0.04926126 0.04921430 [295] 0.04916731 0.04912027 0.04907319 0.04902606 0.04897889 0.04893168 [301] 0.04888442 0.04883712 0.04878977 0.04874238 0.04869495 0.04864747 [307] 0.04859995 0.04855238 0.04850477 0.04845711 0.04840941 0.04836166 [313] 0.04831387 0.04826603 0.04821815 0.04817022 0.04812224 0.04807422 [319] 0.04802615 0.04797803 0.04792987 0.04788166 0.04783340 0.04778510 [325] 0.04773675 0.04768835 0.04763991 0.04759142 0.04754288 0.04749429 [331] 0.04744565 0.04739697 0.04734824 0.04729946 0.04725063 0.04720175 [337] 0.04715282 0.04710385 0.04705482 0.04700575 0.04695663 0.04690745 [343] 0.04685823 0.04680896 0.04675964 0.04671027 0.04666085 0.04661137 [349] 0.04656185 0.04651228 0.04646266 0.04641298 0.04636326 0.04631348 [355] 0.04626366 0.04621378 0.04616385 0.04611387 0.04606384 0.04601375 [361] 0.04596362 0.04591343 0.04586319 0.04581290 0.04576256 0.04571216 [367] 0.04566171 0.04561121 0.04556065 0.04551005 0.04545939 0.04540867 [373] 0.04535791 0.04530709 0.04525622 0.04520529 0.04515431 0.04510328 [379] 0.04505219 0.04500105 0.04494985 0.04489860 0.04484730 0.04479594 [385] 0.04474453 0.04469306 0.04464154 0.04458997 0.04453834 0.04448665 [391] 0.04443491 0.04438311 0.04433126 0.04427936 0.04422739 0.04417538 [397] 0.04412330 0.04407118 0.04401899 0.04396675 0.04391446 > mx [1] 0.06173524 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1b3b71194292417.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/2a4vx1194292417.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/3rlah1194292417.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/4sbkv1194292417.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/56lmd1194292417.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/6lpp51194292417.tab") > > system("convert tmp/1b3b71194292417.ps tmp/1b3b71194292417.png") > system("convert tmp/2a4vx1194292417.ps tmp/2a4vx1194292417.png") > system("convert tmp/3rlah1194292417.ps tmp/3rlah1194292417.png") > system("convert tmp/4sbkv1194292417.ps tmp/4sbkv1194292417.png") > system("convert tmp/56lmd1194292417.ps tmp/56lmd1194292417.png") > > > proc.time() user system elapsed 1.372 0.850 1.616