R version 2.8.1 (2008-12-22) 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(96.96,93.11,95.62,98.30,96.38,100.82,99.06,94.03,102.07,99.31,98.64,101.82,99.14,97.63,100.06,101.32,101.49,105.43,105.09,99.48,108.53,104.34,106.10,107.35,103.00,104.50,105.17,104.84,106.18,108.86,107.77,102.74,112.63,106.26,108.86,111.38,106.85,107.86,107.94,111.38,111.29,113.72,111.88,109.87,113.72,111.71,114.81,112.05,111.54,110.87,110.87,115.48,111.63,116.24,113.56,106.01,110.45,107.77,108.61,108.19) > #'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.8224003 0.8223926 0.8223848 0.8223769 0.8223689 0.8223608 0.8223527 [8] 0.8223445 0.8223361 0.8223277 0.8223193 0.8223107 0.8223020 0.8222933 [15] 0.8222845 0.8222756 0.8222666 0.8222575 0.8222484 0.8222391 0.8222298 [22] 0.8222204 0.8222109 0.8222013 0.8221916 0.8221819 0.8221721 0.8221621 [29] 0.8221521 0.8221421 0.8221319 0.8221216 0.8221113 0.8221009 0.8220904 [36] 0.8220798 0.8220691 0.8220584 0.8220475 0.8220366 0.8220256 0.8220145 [43] 0.8220033 0.8219921 0.8219807 0.8219693 0.8219578 0.8219462 0.8219345 [50] 0.8219227 0.8219109 0.8218990 0.8218870 0.8218749 0.8218627 0.8218504 [57] 0.8218381 0.8218256 0.8218131 0.8218005 0.8217878 0.8217750 0.8217622 [64] 0.8217493 0.8217362 0.8217231 0.8217100 0.8216967 0.8216833 0.8216699 [71] 0.8216564 0.8216428 0.8216291 0.8216153 0.8216015 0.8215875 0.8215735 [78] 0.8215594 0.8215452 0.8215309 0.8215166 0.8215021 0.8214876 0.8214730 [85] 0.8214583 0.8214435 0.8214287 0.8214137 0.8213987 0.8213836 0.8213684 [92] 0.8213532 0.8213378 0.8213224 0.8213068 0.8212912 0.8212755 0.8212598 [99] 0.8212439 0.8212280 0.8212120 0.8211959 0.8211797 0.8211634 0.8211471 [106] 0.8211306 0.8211141 0.8210975 0.8210808 0.8210640 0.8210472 0.8210303 [113] 0.8210133 0.8209962 0.8209790 0.8209617 0.8209444 0.8209269 0.8209094 [120] 0.8208918 0.8208741 0.8208564 0.8208385 0.8208206 0.8208026 0.8207845 [127] 0.8207663 0.8207481 0.8207297 0.8207113 0.8206928 0.8206742 0.8206556 [134] 0.8206368 0.8206180 0.8205991 0.8205801 0.8205610 0.8205418 0.8205226 [141] 0.8205032 0.8204838 0.8204643 0.8204448 0.8204251 0.8204054 0.8203855 [148] 0.8203656 0.8203457 0.8203256 0.8203054 0.8202852 0.8202649 0.8202445 [155] 0.8202240 0.8202035 0.8201828 0.8201621 0.8201413 0.8201204 0.8200994 [162] 0.8200784 0.8200572 0.8200360 0.8200147 0.8199933 0.8199719 0.8199503 [169] 0.8199287 0.8199070 0.8198852 0.8198633 0.8198414 0.8198193 0.8197972 [176] 0.8197750 0.8197528 0.8197304 0.8197080 0.8196854 0.8196628 0.8196401 [183] 0.8196174 0.8195945 0.8195716 0.8195486 0.8195255 0.8195023 0.8194791 [190] 0.8194557 0.8194323 0.8194088 0.8193852 0.8193616 0.8193378 0.8193140 [197] 0.8192901 0.8192661 0.8192420 0.8192179 0.8191936 0.8191693 0.8191449 [204] 0.8191205 0.8190959 0.8190713 0.8190466 0.8190218 0.8189969 0.8189719 [211] 0.8189469 0.8189218 0.8188966 0.8188713 0.8188459 0.8188205 0.8187950 [218] 0.8187694 0.8187437 0.8187179 0.8186921 0.8186661 0.8186401 0.8186140 [225] 0.8185879 0.8185616 0.8185353 0.8185089 0.8184824 0.8184558 0.8184292 [232] 0.8184024 0.8183756 0.8183487 0.8183218 0.8182947 0.8182676 0.8182404 [239] 0.8182131 0.8181857 0.8181582 0.8181307 0.8181031 0.8180754 0.8180476 [246] 0.8180198 0.8179919 0.8179638 0.8179357 0.8179076 0.8178793 0.8178510 [253] 0.8178226 0.8177941 0.8177655 0.8177369 0.8177081 0.8176793 0.8176504 [260] 0.8176215 0.8175924 0.8175633 0.8175341 0.8175048 0.8174754 0.8174460 [267] 0.8174165 0.8173869 0.8173572 0.8173274 0.8172976 0.8172677 0.8172377 [274] 0.8172076 0.8171774 0.8171472 0.8171169 0.8170865 0.8170560 0.8170254 [281] 0.8169948 0.8169641 0.8169333 0.8169024 0.8168715 0.8168405 0.8168093 [288] 0.8167782 0.8167469 0.8167156 0.8166841 0.8166526 0.8166211 0.8165894 [295] 0.8165577 0.8165258 0.8164939 0.8164620 0.8164299 0.8163978 0.8163656 [302] 0.8163333 0.8163009 0.8162685 0.8162360 0.8162034 0.8161707 0.8161379 [309] 0.8161051 0.8160722 0.8160392 0.8160061 0.8159730 0.8159398 0.8159065 [316] 0.8158731 0.8158396 0.8158061 0.8157725 0.8157388 0.8157050 0.8156712 [323] 0.8156373 0.8156033 0.8155692 0.8155350 0.8155008 0.8154665 0.8154321 [330] 0.8153976 0.8153631 0.8153284 0.8152937 0.8152590 0.8152241 0.8151892 [337] 0.8151542 0.8151191 0.8150839 0.8150487 0.8150133 0.8149779 0.8149425 [344] 0.8149069 0.8148713 0.8148356 0.8147998 0.8147639 0.8147280 0.8146920 [351] 0.8146559 0.8146197 0.8145835 0.8145472 0.8145108 0.8144743 0.8144378 [358] 0.8144011 0.8143644 0.8143276 0.8142908 0.8142539 0.8142168 0.8141798 [365] 0.8141426 0.8141054 0.8140680 0.8140307 0.8139932 0.8139556 0.8139180 [372] 0.8138803 0.8138425 0.8138047 0.8137668 0.8137288 0.8136907 0.8136525 [379] 0.8136143 0.8135760 0.8135376 0.8134992 0.8134606 0.8134220 0.8133833 [386] 0.8133446 0.8133057 0.8132668 0.8132278 0.8131888 0.8131496 0.8131104 [393] 0.8130711 0.8130318 0.8129923 0.8129528 0.8129132 0.8128736 0.8128338 [400] 0.8127940 0.8127541 > mx [1] 0.8224003 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/rcomp/tmp/1bbzq1258054787.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/rcomp/tmp/2bae51258054787.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/rcomp/tmp/3fhr01258054787.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/rcomp/tmp/453ur1258054787.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/rcomp/tmp/57rzl1258054787.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/6flie1258054787.tab") > system("convert tmp/1bbzq1258054787.ps tmp/1bbzq1258054787.png") > system("convert tmp/2bae51258054787.ps tmp/2bae51258054787.png") > system("convert tmp/3fhr01258054787.ps tmp/3fhr01258054787.png") > system("convert tmp/453ur1258054787.ps tmp/453ur1258054787.png") > system("convert tmp/57rzl1258054787.ps tmp/57rzl1258054787.png") > > > proc.time() user system elapsed 1.390 1.250 1.923