R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(97.9,96.6,96.2,95.8,96,96.2,96.5,95.4,96.2,96.8,97,97.1,96.6,95.8,96.2,96,95.9,95.8,96,96.2,96.8,96.9,97.2,98.9,98.9,98.8,99,99.6,99.9,100.1,99.9,100.5,100.7,101.3,101.3,101.7,103,104.7,104.5,104.6,104.2,104.5,104.8,104.7,104.6,104.5,104.7,104.8,106.2,105.6,104.5,104.2,104.1,103.3,103.8,103.3,103.7,103.5,103.7,103.4,102.8) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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.8309031 0.8308942 0.8308853 0.8308764 0.8308675 0.8308586 0.8308496 [8] 0.8308407 0.8308317 0.8308227 0.8308137 0.8308047 0.8307957 0.8307866 [15] 0.8307776 0.8307685 0.8307594 0.8307503 0.8307412 0.8307321 0.8307229 [22] 0.8307138 0.8307046 0.8306954 0.8306862 0.8306770 0.8306678 0.8306586 [29] 0.8306493 0.8306401 0.8306308 0.8306215 0.8306122 0.8306028 0.8305935 [36] 0.8305842 0.8305748 0.8305654 0.8305560 0.8305466 0.8305372 0.8305278 [43] 0.8305183 0.8305089 0.8304994 0.8304899 0.8304804 0.8304709 0.8304614 [50] 0.8304518 0.8304423 0.8304327 0.8304231 0.8304135 0.8304039 0.8303942 [57] 0.8303846 0.8303749 0.8303653 0.8303556 0.8303459 0.8303362 0.8303265 [64] 0.8303167 0.8303070 0.8302972 0.8302874 0.8302776 0.8302678 0.8302580 [71] 0.8302481 0.8302383 0.8302284 0.8302185 0.8302087 0.8301987 0.8301888 [78] 0.8301789 0.8301689 0.8301590 0.8301490 0.8301390 0.8301290 0.8301190 [85] 0.8301089 0.8300989 0.8300888 0.8300788 0.8300687 0.8300586 0.8300484 [92] 0.8300383 0.8300282 0.8300180 0.8300078 0.8299976 0.8299874 0.8299772 [99] 0.8299670 0.8299568 0.8299465 0.8299362 0.8299259 0.8299156 0.8299053 [106] 0.8298950 0.8298847 0.8298743 0.8298639 0.8298535 0.8298431 0.8298327 [113] 0.8298223 0.8298119 0.8298014 0.8297910 0.8297805 0.8297700 0.8297595 [120] 0.8297489 0.8297384 0.8297279 0.8297173 0.8297067 0.8296961 0.8296855 [127] 0.8296749 0.8296642 0.8296536 0.8296429 0.8296323 0.8296216 0.8296109 [134] 0.8296001 0.8295894 0.8295787 0.8295679 0.8295571 0.8295463 0.8295355 [141] 0.8295247 0.8295139 0.8295030 0.8294922 0.8294813 0.8294704 0.8294595 [148] 0.8294486 0.8294377 0.8294267 0.8294158 0.8294048 0.8293938 0.8293828 [155] 0.8293718 0.8293608 0.8293497 0.8293387 0.8293276 0.8293165 0.8293054 [162] 0.8292943 0.8292832 0.8292720 0.8292609 0.8292497 0.8292385 0.8292273 [169] 0.8292161 0.8292049 0.8291937 0.8291824 0.8291712 0.8291599 0.8291486 [176] 0.8291373 0.8291260 0.8291146 0.8291033 0.8290919 0.8290805 0.8290691 [183] 0.8290577 0.8290463 0.8290349 0.8290234 0.8290120 0.8290005 0.8289890 [190] 0.8289775 0.8289660 0.8289545 0.8289429 0.8289314 0.8289198 0.8289082 [197] 0.8288966 0.8288850 0.8288733 0.8288617 0.8288500 0.8288384 0.8288267 [204] 0.8288150 0.8288033 0.8287915 0.8287798 0.8287680 0.8287563 0.8287445 [211] 0.8287327 0.8287209 0.8287091 0.8286972 0.8286854 0.8286735 0.8286616 [218] 0.8286497 0.8286378 0.8286259 0.8286139 0.8286020 0.8285900 0.8285781 [225] 0.8285661 0.8285540 0.8285420 0.8285300 0.8285179 0.8285059 0.8284938 [232] 0.8284817 0.8284696 0.8284575 0.8284453 0.8284332 0.8284210 0.8284089 [239] 0.8283967 0.8283845 0.8283723 0.8283600 0.8283478 0.8283355 0.8283232 [246] 0.8283110 0.8282987 0.8282863 0.8282740 0.8282617 0.8282493 0.8282369 [253] 0.8282245 0.8282121 0.8281997 0.8281873 0.8281749 0.8281624 0.8281499 [260] 0.8281375 0.8281250 0.8281124 0.8280999 0.8280874 0.8280748 0.8280623 [267] 0.8280497 0.8280371 0.8280245 0.8280118 0.8279992 0.8279866 0.8279739 [274] 0.8279612 0.8279485 0.8279358 0.8279231 0.8279104 0.8278976 0.8278848 [281] 0.8278721 0.8278593 0.8278465 0.8278336 0.8278208 0.8278080 0.8277951 [288] 0.8277822 0.8277693 0.8277564 0.8277435 0.8277306 0.8277176 0.8277047 [295] 0.8276917 0.8276787 0.8276657 0.8276527 0.8276397 0.8276266 0.8276136 [302] 0.8276005 0.8275874 0.8275743 0.8275612 0.8275481 0.8275349 0.8275218 [309] 0.8275086 0.8274954 0.8274822 0.8274690 0.8274558 0.8274426 0.8274293 [316] 0.8274160 0.8274028 0.8273895 0.8273762 0.8273628 0.8273495 0.8273361 [323] 0.8273228 0.8273094 0.8272960 0.8272826 0.8272692 0.8272557 0.8272423 [330] 0.8272288 0.8272154 0.8272019 0.8271884 0.8271748 0.8271613 0.8271478 [337] 0.8271342 0.8271206 0.8271070 0.8270934 0.8270798 0.8270662 0.8270525 [344] 0.8270389 0.8270252 0.8270115 0.8269978 0.8269841 0.8269704 0.8269566 [351] 0.8269429 0.8269291 0.8269153 0.8269015 0.8268877 0.8268739 0.8268600 [358] 0.8268462 0.8268323 0.8268184 0.8268045 0.8267906 0.8267767 0.8267628 [365] 0.8267488 0.8267349 0.8267209 0.8267069 0.8266929 0.8266789 0.8266648 [372] 0.8266508 0.8266367 0.8266226 0.8266085 0.8265944 0.8265803 0.8265662 [379] 0.8265520 0.8265379 0.8265237 0.8265095 0.8264953 0.8264811 0.8264669 [386] 0.8264526 0.8264384 0.8264241 0.8264098 0.8263955 0.8263812 0.8263669 [393] 0.8263525 0.8263382 0.8263238 0.8263094 0.8262950 0.8262806 0.8262662 [400] 0.8262517 0.8262373 > mx [1] 0.830903 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1g9ih1257944314.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/2u6d91257944314.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/33v131257944314.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/4qoyr1257944314.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x) > qqline(x) > grid() > mtext('Original Data') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/51aub1257944314.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x1) > qqline(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/63ph31257944315.tab") > > system("convert tmp/1g9ih1257944314.ps tmp/1g9ih1257944314.png") > system("convert tmp/2u6d91257944314.ps tmp/2u6d91257944314.png") > system("convert tmp/33v131257944314.ps tmp/33v131257944314.png") > system("convert tmp/4qoyr1257944314.ps tmp/4qoyr1257944314.png") > system("convert tmp/51aub1257944314.ps tmp/51aub1257944314.png") > > > proc.time() user system elapsed 1.045 0.752 1.842