R version 2.6.1 (2007-11-26) 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(87.3,97.6,107.1,96.1,109.5,105,83.9,89.2,107,113.6,108.1,91.9,104.9,99.2,104.3,104,101.5,105.4,88.7,83.6,98,108.9,92.8,82,101.3,106.3,94,102.8,102,105.1,92.4,81.4,105.8,120.3,100.7,88.8,94.3,99.9,103.4,103.3,98.8,104.2,91.2,74.7,108.5,114.5,96.9,89.6,97.1,100.3,122.6,115.4,109,129.1,102.8,96.2,127.7,128.9,126.5,119.8,113.2,114.1,134.1,130,121.8,132.1,105.3,103,117.1,126.3,138.1,119.5,138,135.5,178.6,162.2,176.9,204.9,132.2,142.5,164.3,174.9,175.4,143,158.7,155.4,176.6,163.3,178.9,182.7) > #'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.7112369 0.7116523 0.7120664 0.7124791 0.7128905 0.7133006 0.7137093 [8] 0.7141166 0.7145226 0.7149273 0.7153305 0.7157324 0.7161330 0.7165321 [15] 0.7169299 0.7173263 0.7177213 0.7181149 0.7185072 0.7188980 0.7192874 [22] 0.7196754 0.7200620 0.7204472 0.7208310 0.7212133 0.7215943 0.7219737 [29] 0.7223518 0.7227284 0.7231036 0.7234773 0.7238496 0.7242205 0.7245898 [36] 0.7249578 0.7253242 0.7256892 0.7260527 0.7264148 0.7267753 0.7271344 [43] 0.7274920 0.7278481 0.7282027 0.7285559 0.7289075 0.7292576 0.7296062 [50] 0.7299533 0.7302989 0.7306430 0.7309856 0.7313266 0.7316661 0.7320041 [57] 0.7323405 0.7326755 0.7330088 0.7333407 0.7336710 0.7339997 0.7343269 [64] 0.7346525 0.7349766 0.7352991 0.7356201 0.7359395 0.7362573 0.7365735 [71] 0.7368882 0.7372013 0.7375128 0.7378227 0.7381310 0.7384378 0.7387429 [78] 0.7390465 0.7393485 0.7396488 0.7399476 0.7402447 0.7405403 0.7408342 [85] 0.7411265 0.7414172 0.7417063 0.7419937 0.7422795 0.7425637 0.7428463 [92] 0.7431272 0.7434065 0.7436842 0.7439602 0.7442346 0.7445073 0.7447784 [99] 0.7450478 0.7453156 0.7455817 0.7458462 0.7461090 0.7463702 0.7466297 [106] 0.7468875 0.7471437 0.7473982 0.7476510 0.7479021 0.7481516 0.7483994 [113] 0.7486455 0.7488899 0.7491327 0.7493737 0.7496131 0.7498508 0.7500868 [120] 0.7503211 0.7505537 0.7507846 0.7510138 0.7512413 0.7514671 0.7516912 [127] 0.7519136 0.7521343 0.7523533 0.7525706 0.7527862 0.7530000 0.7532122 [134] 0.7534226 0.7536313 0.7538383 0.7540436 0.7542472 0.7544490 0.7546491 [141] 0.7548475 0.7550441 0.7552391 0.7554323 0.7556238 0.7558135 0.7560015 [148] 0.7561878 0.7563723 0.7565552 0.7567362 0.7569156 0.7570932 0.7572690 [155] 0.7574432 0.7576156 0.7577862 0.7579551 0.7581223 0.7582877 0.7584514 [162] 0.7586133 0.7587735 0.7589319 0.7590886 0.7592436 0.7593968 0.7595482 [169] 0.7596979 0.7598459 0.7599921 0.7601365 0.7602792 0.7604202 0.7605594 [176] 0.7606968 0.7608325 0.7609665 0.7610987 0.7612291 0.7613578 0.7614847 [183] 0.7616099 0.7617334 0.7618550 0.7619750 0.7620931 0.7622096 0.7623242 [190] 0.7624371 0.7625483 0.7626577 0.7627654 0.7628713 0.7629754 0.7630778 [197] 0.7631785 0.7632774 0.7633745 0.7634699 0.7635636 0.7636555 0.7637456 [204] 0.7638340 0.7639207 0.7640056 0.7640887 0.7641701 0.7642498 0.7643277 [211] 0.7644039 0.7644783 0.7645510 0.7646219 0.7646911 0.7647585 0.7648243 [218] 0.7648882 0.7649505 0.7650110 0.7650697 0.7651267 0.7651820 0.7652356 [225] 0.7652874 0.7653375 0.7653858 0.7654324 0.7654773 0.7655205 0.7655619 [232] 0.7656016 0.7656396 0.7656759 0.7657104 0.7657432 0.7657743 0.7658037 [239] 0.7658314 0.7658573 0.7658815 0.7659040 0.7659249 0.7659439 0.7659613 [246] 0.7659770 0.7659910 0.7660032 0.7660138 0.7660227 0.7660298 0.7660353 [253] 0.7660391 0.7660411 0.7660415 0.7660402 0.7660372 0.7660325 0.7660262 [260] 0.7660181 0.7660084 0.7659969 0.7659838 0.7659691 0.7659526 0.7659345 [267] 0.7659147 0.7658932 0.7658701 0.7658453 0.7658189 0.7657908 0.7657610 [274] 0.7657296 0.7656965 0.7656617 0.7656254 0.7655873 0.7655476 0.7655063 [281] 0.7654634 0.7654188 0.7653725 0.7653247 0.7652752 0.7652240 0.7651713 [288] 0.7651169 0.7650609 0.7650033 0.7649440 0.7648832 0.7648207 0.7647566 [295] 0.7646910 0.7646237 0.7645548 0.7644843 0.7644122 0.7643385 0.7642633 [302] 0.7641864 0.7641080 0.7640279 0.7639463 0.7638632 0.7637784 0.7636921 [309] 0.7636042 0.7635147 0.7634237 0.7633311 0.7632369 0.7631412 0.7630440 [316] 0.7629452 0.7628448 0.7627429 0.7626395 0.7625345 0.7624280 0.7623200 [323] 0.7622104 0.7620993 0.7619867 0.7618726 0.7617569 0.7616397 0.7615211 [330] 0.7614009 0.7612792 0.7611560 0.7610313 0.7609052 0.7607775 0.7606483 [337] 0.7605177 0.7603856 0.7602520 0.7601169 0.7599804 0.7598423 0.7597029 [344] 0.7595619 0.7594195 0.7592757 0.7591304 0.7589836 0.7588354 0.7586858 [351] 0.7585347 0.7583822 0.7582282 0.7580729 0.7579161 0.7577579 0.7575982 [358] 0.7574372 0.7572747 0.7571109 0.7569456 0.7567789 0.7566108 0.7564414 [365] 0.7562705 0.7560983 0.7559247 0.7557497 0.7555733 0.7553956 0.7552165 [372] 0.7550360 0.7548542 0.7546710 0.7544864 0.7543005 0.7541133 0.7539247 [379] 0.7537348 0.7535435 0.7533509 0.7531570 0.7529618 0.7527652 0.7525673 [386] 0.7523681 0.7521677 0.7519658 0.7517627 0.7515583 0.7513526 0.7511456 [393] 0.7509374 0.7507278 0.7505170 0.7503049 0.7500915 0.7498768 0.7496609 [400] 0.7494437 0.7492253 > mx [1] 0.7660415 > mxli [1] 0.54 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1cvhg1199650104.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/25lzg1199650104.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/3pue11199650104.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/4yyrh1199650104.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/5g44f1199650104.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/6kpmu1199650104.tab") > > system("convert tmp/1cvhg1199650104.ps tmp/1cvhg1199650104.png") > system("convert tmp/25lzg1199650104.ps tmp/25lzg1199650104.png") > system("convert tmp/3pue11199650104.ps tmp/3pue11199650104.png") > system("convert tmp/4yyrh1199650104.ps tmp/4yyrh1199650104.png") > system("convert tmp/5g44f1199650104.ps tmp/5g44f1199650104.png") > > > proc.time() user system elapsed 1.359 0.869 2.032