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(10.9,10.0,9.2,9.2,9.5,9.6,9.5,9.1,8.9,9.0,10.1,10.3,10.2,9.6,9.2,9.3,9.4,9.4,9.2,9.0,9.0,9.0,9.8,10.0,9.8,9.3,9.0,9.0,9.1,9.1,9.1,9.2,8.8,8.3,8.4,8.1,7.7,7.9,7.9,8.0,7.9,7.6,7.1,6.8,6.5,6.9,8.2,8.7,8.3,7.9,7.5,7.8,8.3,8.4,8.2,7.7,7.2,7.3,8.1,8.5) > #'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.6853335 -0.6855906 -0.6858473 -0.6861037 -0.6863597 -0.6866154 [7] -0.6868706 -0.6871256 -0.6873801 -0.6876343 -0.6878881 -0.6881416 [13] -0.6883946 -0.6886473 -0.6888997 -0.6891516 -0.6894032 -0.6896545 [19] -0.6899053 -0.6901558 -0.6904059 -0.6906556 -0.6909049 -0.6911539 [25] -0.6914025 -0.6916507 -0.6918986 -0.6921460 -0.6923931 -0.6926398 [31] -0.6928861 -0.6931321 -0.6933776 -0.6936228 -0.6938676 -0.6941120 [37] -0.6943561 -0.6945997 -0.6948430 -0.6950859 -0.6953284 -0.6955705 [43] -0.6958122 -0.6960535 -0.6962944 -0.6965350 -0.6967752 -0.6970149 [49] -0.6972543 -0.6974933 -0.6977319 -0.6979701 -0.6982080 -0.6984454 [55] -0.6986824 -0.6989191 -0.6991553 -0.6993912 -0.6996266 -0.6998617 [61] -0.7000963 -0.7003306 -0.7005645 -0.7007979 -0.7010310 -0.7012637 [67] -0.7014959 -0.7017278 -0.7019593 -0.7021903 -0.7024210 -0.7026513 [73] -0.7028811 -0.7031106 -0.7033396 -0.7035683 -0.7037965 -0.7040244 [79] -0.7042518 -0.7044788 -0.7047055 -0.7049317 -0.7051575 -0.7053829 [85] -0.7056079 -0.7058324 -0.7060566 -0.7062804 -0.7065037 -0.7067267 [91] -0.7069492 -0.7071713 -0.7073930 -0.7076143 -0.7078352 -0.7080556 [97] -0.7082757 -0.7084953 -0.7087145 -0.7089333 -0.7091517 -0.7093697 [103] -0.7095872 -0.7098043 -0.7100210 -0.7102373 -0.7104532 -0.7106687 [109] -0.7108837 -0.7110983 -0.7113125 -0.7115263 -0.7117396 -0.7119526 [115] -0.7121651 -0.7123772 -0.7125888 -0.7128001 -0.7130109 -0.7132212 [121] -0.7134312 -0.7136407 -0.7138499 -0.7140585 -0.7142668 -0.7144746 [127] -0.7146820 -0.7148890 -0.7150955 -0.7153017 -0.7155073 -0.7157126 [133] -0.7159174 -0.7161218 -0.7163258 -0.7165293 -0.7167324 -0.7169351 [139] -0.7171373 -0.7173391 -0.7175405 -0.7177414 -0.7179419 -0.7181420 [145] -0.7183416 -0.7185408 -0.7187396 -0.7189379 -0.7191358 -0.7193333 [151] -0.7195303 -0.7197269 -0.7199230 -0.7201187 -0.7203140 -0.7205088 [157] -0.7207032 -0.7208971 -0.7210906 -0.7212837 -0.7214763 -0.7216685 [163] -0.7218602 -0.7220515 -0.7222424 -0.7224328 -0.7226227 -0.7228123 [169] -0.7230014 -0.7231900 -0.7233782 -0.7235659 -0.7237532 -0.7239401 [175] -0.7241265 -0.7243125 -0.7244980 -0.7246831 -0.7248677 -0.7250519 [181] -0.7252356 -0.7254189 -0.7256017 -0.7257841 -0.7259661 -0.7261476 [187] -0.7263286 -0.7265092 -0.7266893 -0.7268690 -0.7270483 -0.7272270 [193] -0.7274054 -0.7275833 -0.7277607 -0.7279377 -0.7281142 -0.7282903 [199] -0.7284659 -0.7286411 -0.7288158 -0.7289900 -0.7291638 -0.7293372 [205] -0.7295101 -0.7296825 -0.7298545 -0.7300261 -0.7301971 -0.7303677 [211] -0.7305379 -0.7307076 -0.7308769 -0.7310457 -0.7312140 -0.7313819 [217] -0.7315493 -0.7317162 -0.7318827 -0.7320488 -0.7322144 -0.7323795 [223] -0.7325441 -0.7327084 -0.7328721 -0.7330354 -0.7331982 -0.7333606 [229] -0.7335225 -0.7336839 -0.7338449 -0.7340054 -0.7341655 -0.7343250 [235] -0.7344842 -0.7346428 -0.7348010 -0.7349588 -0.7351161 -0.7352729 [241] -0.7354292 -0.7355851 -0.7357405 -0.7358955 -0.7360500 -0.7362040 [247] -0.7363576 -0.7365107 -0.7366633 -0.7368155 -0.7369672 -0.7371184 [253] -0.7372692 -0.7374195 -0.7375693 -0.7377187 -0.7378676 -0.7380160 [259] -0.7381640 -0.7383115 -0.7384585 -0.7386051 -0.7387512 -0.7388968 [265] -0.7390420 -0.7391867 -0.7393309 -0.7394747 -0.7396180 -0.7397608 [271] -0.7399031 -0.7400450 -0.7401864 -0.7403273 -0.7404678 -0.7406078 [277] -0.7407473 -0.7408864 -0.7410250 -0.7411631 -0.7413007 -0.7414379 [283] -0.7415746 -0.7417108 -0.7418466 -0.7419819 -0.7421167 -0.7422510 [289] -0.7423849 -0.7425183 -0.7426512 -0.7427837 -0.7429157 -0.7430472 [295] -0.7431782 -0.7433088 -0.7434389 -0.7435685 -0.7436976 -0.7438263 [301] -0.7439545 -0.7440822 -0.7442095 -0.7443362 -0.7444625 -0.7445884 [307] -0.7447137 -0.7448386 -0.7449630 -0.7450869 -0.7452104 -0.7453334 [313] -0.7454559 -0.7455779 -0.7456995 -0.7458205 -0.7459411 -0.7460613 [319] -0.7461809 -0.7463001 -0.7464188 -0.7465370 -0.7466548 -0.7467721 [325] -0.7468889 -0.7470052 -0.7471211 -0.7472364 -0.7473513 -0.7474657 [331] -0.7475797 -0.7476932 -0.7478062 -0.7479187 -0.7480307 -0.7481423 [337] -0.7482534 -0.7483640 -0.7484741 -0.7485838 -0.7486930 -0.7488017 [343] -0.7489099 -0.7490177 -0.7491249 -0.7492317 -0.7493380 -0.7494439 [349] -0.7495493 -0.7496542 -0.7497586 -0.7498625 -0.7499660 -0.7500689 [355] -0.7501715 -0.7502735 -0.7503750 -0.7504761 -0.7505767 -0.7506768 [361] -0.7507765 -0.7508756 -0.7509743 -0.7510725 -0.7511703 -0.7512675 [367] -0.7513643 -0.7514606 -0.7515564 -0.7516518 -0.7517467 -0.7518410 [373] -0.7519350 -0.7520284 -0.7521214 -0.7522139 -0.7523059 -0.7523974 [379] -0.7524884 -0.7525790 -0.7526691 -0.7527587 -0.7528479 -0.7529366 [385] -0.7530248 -0.7531125 -0.7531997 -0.7532865 -0.7533728 -0.7534586 [391] -0.7535439 -0.7536287 -0.7537131 -0.7537970 -0.7538804 -0.7539634 [397] -0.7540459 -0.7541279 -0.7542094 -0.7542904 -0.7543710 > mx [1] 0 > mxli [1] -999 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/rcomp/tmp/1oxg41257772072.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/2cd981257772072.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/3sxeo1257772072.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/4g2f01257772072.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/5vlzj1257772072.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/628r01257772072.tab") > > system("convert tmp/1oxg41257772072.ps tmp/1oxg41257772072.png") > system("convert tmp/2cd981257772072.ps tmp/2cd981257772072.png") > system("convert tmp/3sxeo1257772072.ps tmp/3sxeo1257772072.png") > system("convert tmp/4g2f01257772072.ps tmp/4g2f01257772072.png") > system("convert tmp/5vlzj1257772072.ps tmp/5vlzj1257772072.png") > > > proc.time() user system elapsed 1.380 1.240 2.403