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(124.9,132,151.4,108.9,121.3,123.4,90.3,79.3,117.2,116.9,120.8,96.1,100.8,105.3,116.1,112.8,114.5,117.2,77.1,80.1,120.3,133.4,109.4,93.2,91.2,99.2,108.2,101.5,106.9,104.4,77.9,60,99.5,95,105.6,102.5,93.3,97.3,127,111.7,96.4,133,72.2,95.8,124.1,127.6,110.7,104.6,112.7,115.3,139.4,119,97.4,154,81.5,88.8,127.7,105.1,114.9,106.4,104.5,121.6,141.4,99,126.7,134.1,81.3,88.6,132.7,132.9,134.4,103.7,119.7,115,132.9,108.5,113.9,142.9,95.2,93) > #'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.05283810 0.05283626 0.05283441 0.05283255 0.05283069 0.05282881 [7] 0.05282693 0.05282504 0.05282315 0.05282125 0.05281934 0.05281743 [13] 0.05281551 0.05281359 0.05281167 0.05280974 0.05280781 0.05280587 [19] 0.05280394 0.05280200 0.05280006 0.05279813 0.05279619 0.05279425 [25] 0.05279231 0.05279037 0.05278844 0.05278651 0.05278457 0.05278265 [31] 0.05278072 0.05277880 0.05277689 0.05277497 0.05277307 0.05277117 [37] 0.05276927 0.05276738 0.05276550 0.05276363 0.05276176 0.05275990 [43] 0.05275806 0.05275621 0.05275438 0.05275256 0.05275075 0.05274895 [49] 0.05274716 0.05274539 0.05274362 0.05274187 0.05274013 0.05273840 [55] 0.05273669 0.05273499 0.05273330 0.05273163 0.05272998 0.05272834 [61] 0.05272671 0.05272511 0.05272352 0.05272195 0.05272039 0.05271885 [67] 0.05271734 0.05271584 0.05271436 0.05271289 0.05271145 0.05271003 [73] 0.05270863 0.05270725 0.05270590 0.05270456 0.05270325 0.05270196 [79] 0.05270069 0.05269945 0.05269823 0.05269703 0.05269586 0.05269471 [85] 0.05269359 0.05269249 0.05269142 0.05269037 0.05268935 0.05268836 [91] 0.05268740 0.05268646 0.05268555 0.05268467 0.05268381 0.05268299 [97] 0.05268219 0.05268143 0.05268069 0.05267999 0.05267931 0.05267867 [103] 0.05267805 0.05267747 0.05267692 0.05267640 0.05267591 0.05267546 [109] 0.05267504 0.05267465 0.05267429 0.05267397 0.05267368 0.05267343 [115] 0.05267321 0.05267303 0.05267288 0.05267277 0.05267269 0.05267264 [121] 0.05267264 0.05267267 0.05267273 0.05267284 0.05267298 0.05267316 [127] 0.05267337 0.05267363 0.05267392 0.05267425 0.05267461 0.05267502 [133] 0.05267547 0.05267595 0.05267648 0.05267704 0.05267765 0.05267829 [139] 0.05267897 0.05267970 0.05268046 0.05268127 0.05268212 0.05268301 [145] 0.05268394 0.05268491 0.05268592 0.05268698 0.05268808 0.05268922 [151] 0.05269040 0.05269163 0.05269289 0.05269421 0.05269556 0.05269696 [157] 0.05269840 0.05269989 0.05270141 0.05270299 0.05270460 0.05270627 [163] 0.05270797 0.05270972 0.05271152 0.05271336 0.05271524 0.05271717 [169] 0.05271915 0.05272117 0.05272323 0.05272534 0.05272750 0.05272970 [175] 0.05273195 0.05273424 0.05273658 0.05273897 0.05274140 0.05274388 [181] 0.05274641 0.05274898 0.05275160 0.05275426 0.05275697 0.05275973 [187] 0.05276253 0.05276538 0.05276828 0.05277123 0.05277422 0.05277726 [193] 0.05278034 0.05278348 0.05278666 0.05278988 0.05279316 0.05279648 [199] 0.05279985 0.05280327 0.05280673 0.05281024 0.05281380 0.05281741 [205] 0.05282106 0.05282476 0.05282851 0.05283230 0.05283615 0.05284004 [211] 0.05284398 0.05284796 0.05285199 0.05285607 0.05286020 0.05286438 [217] 0.05286860 0.05287287 0.05287718 0.05288155 0.05288596 0.05289041 [223] 0.05289492 0.05289947 0.05290407 0.05290871 0.05291341 0.05291815 [229] 0.05292293 0.05292776 0.05293264 0.05293757 0.05294254 0.05294756 [235] 0.05295263 0.05295774 0.05296289 0.05296810 0.05297335 0.05297864 [241] 0.05298398 0.05298937 0.05299480 0.05300028 0.05300580 0.05301137 [247] 0.05301699 0.05302265 0.05302835 0.05303410 0.05303989 0.05304573 [253] 0.05305161 0.05305754 0.05306351 0.05306953 0.05307559 0.05308169 [259] 0.05308784 0.05309403 0.05310026 0.05310654 0.05311286 0.05311922 [265] 0.05312562 0.05313207 0.05313856 0.05314510 0.05315167 0.05315829 [271] 0.05316495 0.05317165 0.05317839 0.05318517 0.05319200 0.05319886 [277] 0.05320577 0.05321271 0.05321970 0.05322673 0.05323379 0.05324090 [283] 0.05324805 0.05325523 0.05326246 0.05326972 0.05327702 0.05328436 [289] 0.05329174 0.05329916 0.05330661 0.05331411 0.05332164 0.05332921 [295] 0.05333681 0.05334445 0.05335213 0.05335984 0.05336759 0.05337538 [301] 0.05338320 0.05339106 0.05339895 0.05340688 0.05341484 0.05342284 [307] 0.05343087 0.05343893 0.05344703 0.05345516 0.05346332 0.05347152 [313] 0.05347975 0.05348801 0.05349631 0.05350464 0.05351299 0.05352138 [319] 0.05352980 0.05353825 0.05354673 0.05355525 0.05356379 0.05357236 [325] 0.05358096 0.05358959 0.05359825 0.05360693 0.05361565 0.05362439 [331] 0.05363316 0.05364196 0.05365079 0.05365964 0.05366852 0.05367742 [337] 0.05368635 0.05369531 0.05370429 0.05371329 0.05372232 0.05373138 [343] 0.05374046 0.05374956 0.05375869 0.05376783 0.05377701 0.05378620 [349] 0.05379542 0.05380465 0.05381391 0.05382319 0.05383250 0.05384182 [355] 0.05385116 0.05386052 0.05386990 0.05387931 0.05388872 0.05389816 [361] 0.05390762 0.05391709 0.05392659 0.05393609 0.05394562 0.05395516 [367] 0.05396472 0.05397429 0.05398388 0.05399349 0.05400311 0.05401274 [373] 0.05402239 0.05403205 0.05404173 0.05405142 0.05406112 0.05407083 [379] 0.05408056 0.05409029 0.05410004 0.05410980 0.05411957 0.05412935 [385] 0.05413914 0.05414894 0.05415875 0.05416856 0.05417839 0.05418822 [391] 0.05419806 0.05420791 0.05421777 0.05422763 0.05423750 0.05424737 [397] 0.05425725 0.05426714 0.05427702 0.05428692 0.05429682 > mx [1] 0.05429682 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1sbc61194296369.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/2a7pq1194296369.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/3y1tz1194296369.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/4durv1194296369.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/50jkb1194296369.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/62rxd1194296369.tab") > > system("convert tmp/1sbc61194296369.ps tmp/1sbc61194296369.png") > system("convert tmp/2a7pq1194296369.ps tmp/2a7pq1194296369.png") > system("convert tmp/3y1tz1194296369.ps tmp/3y1tz1194296369.png") > system("convert tmp/4durv1194296369.ps tmp/4durv1194296369.png") > system("convert tmp/50jkb1194296369.ps tmp/50jkb1194296369.png") > > > proc.time() user system elapsed 2.332 1.272 2.528