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(100.00,99.95,102.07,102.02,102.63,102.88,103.01,104.33,105.21,104.73,104.17,103.69,104.33,105.21,105.31,105.54,106.70,106.60,105.01,104.33,104.17,103.42,102.33,101.82,103.57,103.90,104.58,105.03,105.67,105.69,105.72,105.84,105.79,105.39,105.97,106.50,107.13,109.36,109.36,108.42,107.94,108.10,108.40,110.55,111.81,112.55,111.66,111.38,113.10,115.18,121.07,123.07,123.40,122.92,122.39,123.55,124.97,124.87,123.27,121.96,122.49,125.68,126.76,126.44,125.35,126.01,127.45,130.58,133.09,133.34,132.84,133.80) > #'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.9163420 0.9163089 0.9162757 0.9162425 0.9162092 0.9161759 0.9161426 [8] 0.9161092 0.9160757 0.9160423 0.9160087 0.9159752 0.9159416 0.9159079 [15] 0.9158742 0.9158405 0.9158067 0.9157729 0.9157390 0.9157051 0.9156711 [22] 0.9156371 0.9156031 0.9155690 0.9155349 0.9155007 0.9154665 0.9154322 [29] 0.9153979 0.9153636 0.9153292 0.9152948 0.9152603 0.9152258 0.9151912 [36] 0.9151566 0.9151219 0.9150873 0.9150525 0.9150177 0.9149829 0.9149480 [43] 0.9149131 0.9148782 0.9148432 0.9148082 0.9147731 0.9147379 0.9147028 [50] 0.9146676 0.9146323 0.9145970 0.9145617 0.9145263 0.9144909 0.9144554 [57] 0.9144199 0.9143843 0.9143487 0.9143131 0.9142774 0.9142417 0.9142059 [64] 0.9141701 0.9141342 0.9140983 0.9140624 0.9140264 0.9139904 0.9139543 [71] 0.9139182 0.9138820 0.9138458 0.9138096 0.9137733 0.9137370 0.9137006 [78] 0.9136642 0.9136277 0.9135912 0.9135547 0.9135181 0.9134815 0.9134448 [85] 0.9134081 0.9133713 0.9133345 0.9132977 0.9132608 0.9132239 0.9131869 [92] 0.9131499 0.9131128 0.9130757 0.9130386 0.9130014 0.9129642 0.9129269 [99] 0.9128896 0.9128522 0.9128148 0.9127774 0.9127399 0.9127024 0.9126648 [106] 0.9126272 0.9125895 0.9125518 0.9125141 0.9124763 0.9124385 0.9124006 [113] 0.9123627 0.9123247 0.9122867 0.9122487 0.9122106 0.9121725 0.9121343 [120] 0.9120961 0.9120578 0.9120196 0.9119812 0.9119428 0.9119044 0.9118659 [127] 0.9118274 0.9117889 0.9117503 0.9117116 0.9116730 0.9116342 0.9115955 [134] 0.9115567 0.9115178 0.9114789 0.9114400 0.9114010 0.9113620 0.9113229 [141] 0.9112838 0.9112447 0.9112055 0.9111663 0.9111270 0.9110877 0.9110483 [148] 0.9110089 0.9109695 0.9109300 0.9108905 0.9108509 0.9108113 0.9107716 [155] 0.9107319 0.9106922 0.9106524 0.9106126 0.9105727 0.9105328 0.9104928 [162] 0.9104528 0.9104128 0.9103727 0.9103326 0.9102924 0.9102522 0.9102120 [169] 0.9101717 0.9101313 0.9100910 0.9100505 0.9100101 0.9099696 0.9099290 [176] 0.9098884 0.9098478 0.9098071 0.9097664 0.9097257 0.9096849 0.9096440 [183] 0.9096031 0.9095622 0.9095212 0.9094802 0.9094392 0.9093981 0.9093569 [190] 0.9093158 0.9092745 0.9092333 0.9091920 0.9091506 0.9091092 0.9090678 [197] 0.9090263 0.9089848 0.9089432 0.9089016 0.9088600 0.9088183 0.9087766 [204] 0.9087348 0.9086930 0.9086511 0.9086092 0.9085673 0.9085253 0.9084833 [211] 0.9084412 0.9083991 0.9083570 0.9083148 0.9082725 0.9082303 0.9081879 [218] 0.9081456 0.9081032 0.9080607 0.9080182 0.9079757 0.9079331 0.9078905 [225] 0.9078479 0.9078052 0.9077624 0.9077196 0.9076768 0.9076339 0.9075910 [232] 0.9075481 0.9075051 0.9074620 0.9074190 0.9073758 0.9073327 0.9072895 [239] 0.9072462 0.9072029 0.9071596 0.9071162 0.9070728 0.9070294 0.9069859 [246] 0.9069423 0.9068987 0.9068551 0.9068114 0.9067677 0.9067240 0.9066802 [253] 0.9066363 0.9065925 0.9065485 0.9065046 0.9064606 0.9064165 0.9063724 [260] 0.9063283 0.9062841 0.9062399 0.9061957 0.9061514 0.9061070 0.9060626 [267] 0.9060182 0.9059738 0.9059292 0.9058847 0.9058401 0.9057955 0.9057508 [274] 0.9057061 0.9056613 0.9056165 0.9055717 0.9055268 0.9054818 0.9054369 [281] 0.9053918 0.9053468 0.9053017 0.9052566 0.9052114 0.9051661 0.9051209 [288] 0.9050756 0.9050302 0.9049848 0.9049394 0.9048939 0.9048484 0.9048028 [295] 0.9047572 0.9047116 0.9046659 0.9046202 0.9045744 0.9045286 0.9044827 [302] 0.9044368 0.9043909 0.9043449 0.9042989 0.9042528 0.9042067 0.9041606 [309] 0.9041144 0.9040682 0.9040219 0.9039756 0.9039292 0.9038828 0.9038364 [316] 0.9037899 0.9037433 0.9036968 0.9036502 0.9036035 0.9035568 0.9035101 [323] 0.9034633 0.9034165 0.9033696 0.9033227 0.9032758 0.9032288 0.9031817 [330] 0.9031347 0.9030876 0.9030404 0.9029932 0.9029460 0.9028987 0.9028513 [337] 0.9028040 0.9027566 0.9027091 0.9026616 0.9026141 0.9025665 0.9025189 [344] 0.9024712 0.9024235 0.9023758 0.9023280 0.9022802 0.9022323 0.9021844 [351] 0.9021364 0.9020884 0.9020404 0.9019923 0.9019442 0.9018960 0.9018478 [358] 0.9017995 0.9017512 0.9017029 0.9016545 0.9016061 0.9015577 0.9015091 [365] 0.9014606 0.9014120 0.9013634 0.9013147 0.9012660 0.9012172 0.9011684 [372] 0.9011196 0.9010707 0.9010218 0.9009728 0.9009238 0.9008748 0.9008257 [379] 0.9007766 0.9007274 0.9006782 0.9006289 0.9005796 0.9005302 0.9004809 [386] 0.9004314 0.9003820 0.9003324 0.9002829 0.9002333 0.9001837 0.9001340 [393] 0.9000842 0.9000345 0.8999847 0.8999348 0.8998849 0.8998350 0.8997850 [400] 0.8997350 0.8996849 > mx [1] 0.916342 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/rcomp/tmp/11gng1258052326.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/22jif1258052326.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/32mp01258052326.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/4dvwr1258052326.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/5chpx1258052326.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/6hz4m1258052326.tab") > > system("convert tmp/11gng1258052326.ps tmp/11gng1258052326.png") > system("convert tmp/22jif1258052326.ps tmp/22jif1258052326.png") > system("convert tmp/32mp01258052326.ps tmp/32mp01258052326.png") > system("convert tmp/4dvwr1258052326.ps tmp/4dvwr1258052326.png") > system("convert tmp/5chpx1258052326.ps tmp/5chpx1258052326.png") > > > proc.time() user system elapsed 1.320 1.240 1.957