R version 2.6.0 (2007-10-03) 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(98.6,98,106.8,96.7,100.2,107.7,92,98.4,107.4,117.7,105.7,97.5,99.9,98.2,104.5,100.8,101.5,103.9,99.6,98.4,112.7,118.4,108.1,105.4,114.6,106.9,115.9,109.8,101.8,114.2,110.8,108.4,127.5,128.6,116.6,127.4,105,108.3,125,111.6,106.5,130.3,115,116.1,134,126.5,125.8,136.4,114.9,110.9,125.5,116.8,116.8,125.5,104.2,115.1,132.8,123.3,124.8,122,117.4,117.9,137.4,114.6,124.7,129.6,109.4,120.9,134.9,136.3,133.2,127.2,122.7,120.5,137.8,119.1,124.3,134.3,121.7,125) > #'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.7389985 0.7389720 0.7389453 0.7389183 0.7388911 0.7388637 0.7388361 [8] 0.7388082 0.7387800 0.7387517 0.7387231 0.7386943 0.7386652 0.7386359 [15] 0.7386064 0.7385767 0.7385467 0.7385165 0.7384860 0.7384553 0.7384244 [22] 0.7383933 0.7383619 0.7383303 0.7382984 0.7382664 0.7382341 0.7382015 [29] 0.7381687 0.7381357 0.7381025 0.7380690 0.7380353 0.7380014 0.7379672 [36] 0.7379328 0.7378982 0.7378633 0.7378282 0.7377929 0.7377573 0.7377216 [43] 0.7376855 0.7376493 0.7376128 0.7375761 0.7375391 0.7375019 0.7374645 [50] 0.7374269 0.7373890 0.7373509 0.7373125 0.7372740 0.7372352 0.7371961 [57] 0.7371569 0.7371174 0.7370776 0.7370377 0.7369975 0.7369571 0.7369164 [64] 0.7368755 0.7368344 0.7367931 0.7367515 0.7367097 0.7366676 0.7366254 [71] 0.7365829 0.7365401 0.7364972 0.7364540 0.7364106 0.7363669 0.7363230 [78] 0.7362789 0.7362346 0.7361900 0.7361452 0.7361001 0.7360549 0.7360094 [85] 0.7359637 0.7359177 0.7358715 0.7358251 0.7357785 0.7357316 0.7356845 [92] 0.7356372 0.7355896 0.7355418 0.7354938 0.7354455 0.7353971 0.7353484 [99] 0.7352994 0.7352503 0.7352009 0.7351512 0.7351014 0.7350513 0.7350010 [106] 0.7349505 0.7348997 0.7348487 0.7347975 0.7347460 0.7346944 0.7346425 [113] 0.7345903 0.7345380 0.7344854 0.7344326 0.7343795 0.7343263 0.7342728 [120] 0.7342190 0.7341651 0.7341109 0.7340565 0.7340019 0.7339470 0.7338919 [127] 0.7338366 0.7337811 0.7337253 0.7336693 0.7336131 0.7335566 0.7335000 [134] 0.7334431 0.7333859 0.7333286 0.7332710 0.7332132 0.7331552 0.7330969 [141] 0.7330384 0.7329797 0.7329208 0.7328617 0.7328023 0.7327427 0.7326829 [148] 0.7326228 0.7325625 0.7325020 0.7324413 0.7323803 0.7323192 0.7322578 [155] 0.7321961 0.7321343 0.7320722 0.7320099 0.7319474 0.7318847 0.7318217 [162] 0.7317585 0.7316951 0.7316315 0.7315676 0.7315035 0.7314392 0.7313747 [169] 0.7313100 0.7312450 0.7311798 0.7311144 0.7310487 0.7309829 0.7309168 [176] 0.7308505 0.7307840 0.7307172 0.7306503 0.7305831 0.7305157 0.7304480 [183] 0.7303802 0.7303121 0.7302438 0.7301753 0.7301066 0.7300376 0.7299685 [190] 0.7298991 0.7298295 0.7297596 0.7296896 0.7296193 0.7295488 0.7294781 [197] 0.7294072 0.7293360 0.7292647 0.7291931 0.7291213 0.7290493 0.7289770 [204] 0.7289046 0.7288319 0.7287590 0.7286859 0.7286126 0.7285390 0.7284653 [211] 0.7283913 0.7283171 0.7282427 0.7281680 0.7280932 0.7280181 0.7279429 [218] 0.7278674 0.7277916 0.7277157 0.7276396 0.7275632 0.7274866 0.7274099 [225] 0.7273328 0.7272556 0.7271782 0.7271005 0.7270227 0.7269446 0.7268663 [232] 0.7267878 0.7267091 0.7266302 0.7265510 0.7264716 0.7263921 0.7263123 [239] 0.7262323 0.7261521 0.7260716 0.7259910 0.7259102 0.7258291 0.7257478 [246] 0.7256663 0.7255846 0.7255027 0.7254206 0.7253383 0.7252557 0.7251730 [253] 0.7250900 0.7250068 0.7249234 0.7248398 0.7247560 0.7246720 0.7245878 [260] 0.7245034 0.7244187 0.7243339 0.7242488 0.7241635 0.7240780 0.7239924 [267] 0.7239065 0.7238204 0.7237340 0.7236475 0.7235608 0.7234738 0.7233867 [274] 0.7232994 0.7232118 0.7231240 0.7230361 0.7229479 0.7228595 0.7227709 [281] 0.7226821 0.7225931 0.7225039 0.7224145 0.7223249 0.7222350 0.7221450 [288] 0.7220548 0.7219643 0.7218737 0.7217828 0.7216918 0.7216005 0.7215091 [295] 0.7214174 0.7213256 0.7212335 0.7211412 0.7210487 0.7209561 0.7208632 [302] 0.7207701 0.7206768 0.7205833 0.7204897 0.7203958 0.7203017 0.7202074 [309] 0.7201129 0.7200182 0.7199233 0.7198283 0.7197330 0.7196375 0.7195418 [316] 0.7194459 0.7193498 0.7192535 0.7191570 0.7190604 0.7189635 0.7188664 [323] 0.7187691 0.7186716 0.7185740 0.7184761 0.7183780 0.7182798 0.7181813 [330] 0.7180827 0.7179838 0.7178848 0.7177855 0.7176861 0.7175864 0.7174866 [337] 0.7173866 0.7172864 0.7171859 0.7170853 0.7169845 0.7168835 0.7167823 [344] 0.7166809 0.7165794 0.7164776 0.7163756 0.7162735 0.7161711 0.7160686 [351] 0.7159658 0.7158629 0.7157598 0.7156565 0.7155530 0.7154493 0.7153454 [358] 0.7152413 0.7151371 0.7150326 0.7149280 0.7148231 0.7147181 0.7146129 [365] 0.7145075 0.7144019 0.7142961 0.7141902 0.7140840 0.7139777 0.7138712 [372] 0.7137644 0.7136575 0.7135504 0.7134432 0.7133357 0.7132280 0.7131202 [379] 0.7130122 0.7129040 0.7127956 0.7126870 0.7125782 0.7124693 0.7123602 [386] 0.7122508 0.7121413 0.7120317 0.7119218 0.7118117 0.7117015 0.7115911 [393] 0.7114805 0.7113697 0.7112587 0.7111476 0.7110363 0.7109247 0.7108131 [400] 0.7107012 0.7105891 > mx [1] 0.7389985 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1lxs61194696295.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/2ma1w1194696295.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/3aqnq1194696295.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/4a9351194696295.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/5likv1194696295.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/629p71194696295.tab") > > system("convert tmp/1lxs61194696295.ps tmp/1lxs61194696295.png") > system("convert tmp/2ma1w1194696295.ps tmp/2ma1w1194696295.png") > system("convert tmp/3aqnq1194696295.ps tmp/3aqnq1194696295.png") > system("convert tmp/4a9351194696295.ps tmp/4a9351194696295.png") > system("convert tmp/5likv1194696295.ps tmp/5likv1194696295.png") > > > proc.time() user system elapsed 1.388 0.840 1.606