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(467.037,460.070,447.988,442.867,436.087,431.328,484.015,509.673,512.927,502.831,470.984,471.067,476.049,474.605,470.439,461.251,454.724,455.626,516.847,525.192,522.975,518.585,509.239,512.238,519.164,517.009,509.933,509.127,500.857,506.971,569.323,579.714,577.992,565.464,547.344,554.788,562.325,560.854,555.332,543.599,536.662,542.722,593.530,610.763,612.613,611.324,594.167,595.454,590.865,589.379,584.428,573.100,567.456,569.028,620.735,628.884,628.232,612.117,595.404,597.141,593.408,590.072,579.799,574.205,572.775,572.942,619.567,625.809,619.916,587.625,565.742,557.274,560.576,548.854,531.673,525.919,511.038,498.662,555.362,564.591,541.657) > #'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.6789489 0.6788854 0.6788216 0.6787577 0.6786935 0.6786290 0.6785644 [8] 0.6784995 0.6784344 0.6783691 0.6783035 0.6782377 0.6781717 0.6781054 [15] 0.6780390 0.6779723 0.6779053 0.6778382 0.6777708 0.6777032 0.6776354 [22] 0.6775673 0.6774990 0.6774305 0.6773618 0.6772928 0.6772236 0.6771542 [29] 0.6770845 0.6770147 0.6769446 0.6768743 0.6768037 0.6767329 0.6766619 [36] 0.6765907 0.6765193 0.6764476 0.6763757 0.6763036 0.6762312 0.6761587 [43] 0.6760859 0.6760129 0.6759396 0.6758661 0.6757924 0.6757185 0.6756444 [50] 0.6755700 0.6754954 0.6754206 0.6753456 0.6752703 0.6751948 0.6751191 [57] 0.6750432 0.6749671 0.6748907 0.6748141 0.6747373 0.6746602 0.6745830 [64] 0.6745055 0.6744278 0.6743498 0.6742717 0.6741933 0.6741147 0.6740359 [71] 0.6739568 0.6738776 0.6737981 0.6737184 0.6736385 0.6735583 0.6734780 [78] 0.6733974 0.6733166 0.6732355 0.6731543 0.6730728 0.6729911 0.6729092 [85] 0.6728271 0.6727447 0.6726622 0.6725794 0.6724964 0.6724131 0.6723297 [92] 0.6722460 0.6721622 0.6720781 0.6719937 0.6719092 0.6718244 0.6717395 [99] 0.6716543 0.6715689 0.6714832 0.6713974 0.6713113 0.6712251 0.6711386 [106] 0.6710518 0.6709649 0.6708778 0.6707904 0.6707028 0.6706150 0.6705270 [113] 0.6704388 0.6703504 0.6702617 0.6701728 0.6700837 0.6699944 0.6699049 [120] 0.6698152 0.6697252 0.6696351 0.6695447 0.6694541 0.6693633 0.6692723 [127] 0.6691810 0.6690896 0.6689979 0.6689060 0.6688140 0.6687217 0.6686291 [134] 0.6685364 0.6684435 0.6683503 0.6682570 0.6681634 0.6680696 0.6679756 [141] 0.6678814 0.6677870 0.6676924 0.6675975 0.6675025 0.6674072 0.6673117 [148] 0.6672160 0.6671201 0.6670240 0.6669277 0.6668312 0.6667345 0.6666375 [155] 0.6665404 0.6664430 0.6663454 0.6662477 0.6661497 0.6660515 0.6659531 [162] 0.6658545 0.6657557 0.6656566 0.6655574 0.6654580 0.6653583 0.6652585 [169] 0.6651584 0.6650581 0.6649577 0.6648570 0.6647561 0.6646550 0.6645537 [176] 0.6644522 0.6643505 0.6642486 0.6641465 0.6640442 0.6639417 0.6638389 [183] 0.6637360 0.6636329 0.6635295 0.6634260 0.6633222 0.6632183 0.6631141 [190] 0.6630098 0.6629052 0.6628005 0.6626955 0.6625904 0.6624850 0.6623794 [197] 0.6622737 0.6621677 0.6620615 0.6619552 0.6618486 0.6617418 0.6616349 [204] 0.6615277 0.6614203 0.6613128 0.6612050 0.6610971 0.6609889 0.6608805 [211] 0.6607720 0.6606632 0.6605543 0.6604451 0.6603358 0.6602262 0.6601165 [218] 0.6600065 0.6598964 0.6597861 0.6596755 0.6595648 0.6594539 0.6593428 [225] 0.6592315 0.6591200 0.6590083 0.6588964 0.6587843 0.6586720 0.6585595 [232] 0.6584469 0.6583340 0.6582209 0.6581077 0.6579942 0.6578806 0.6577668 [239] 0.6576528 0.6575385 0.6574241 0.6573095 0.6571948 0.6570798 0.6569646 [246] 0.6568493 0.6567337 0.6566180 0.6565020 0.6563859 0.6562696 0.6561531 [253] 0.6560364 0.6559196 0.6558025 0.6556852 0.6555678 0.6554502 0.6553324 [260] 0.6552144 0.6550962 0.6549778 0.6548592 0.6547405 0.6546216 0.6545024 [267] 0.6543831 0.6542636 0.6541440 0.6540241 0.6539041 0.6537838 0.6536634 [274] 0.6535428 0.6534220 0.6533011 0.6531799 0.6530586 0.6529371 0.6528154 [281] 0.6526935 0.6525714 0.6524492 0.6523268 0.6522042 0.6520814 0.6519584 [288] 0.6518353 0.6517119 0.6515884 0.6514648 0.6513409 0.6512168 0.6510926 [295] 0.6509682 0.6508436 0.6507189 0.6505939 0.6504688 0.6503435 0.6502181 [302] 0.6500924 0.6499666 0.6498406 0.6497144 0.6495881 0.6494615 0.6493348 [309] 0.6492080 0.6490809 0.6489537 0.6488263 0.6486987 0.6485710 0.6484430 [316] 0.6483149 0.6481867 0.6480582 0.6479296 0.6478008 0.6476719 0.6475427 [323] 0.6474134 0.6472840 0.6471543 0.6470245 0.6468945 0.6467644 0.6466340 [330] 0.6465035 0.6463729 0.6462420 0.6461110 0.6459799 0.6458485 0.6457170 [337] 0.6455854 0.6454535 0.6453215 0.6451893 0.6450570 0.6449245 0.6447918 [344] 0.6446590 0.6445260 0.6443928 0.6442594 0.6441259 0.6439923 0.6438585 [351] 0.6437245 0.6435903 0.6434560 0.6433215 0.6431869 0.6430520 0.6429171 [358] 0.6427819 0.6426466 0.6425112 0.6423756 0.6422398 0.6421038 0.6419677 [365] 0.6418315 0.6416951 0.6415585 0.6414218 0.6412849 0.6411478 0.6410106 [372] 0.6408732 0.6407357 0.6405980 0.6404602 0.6403222 0.6401840 0.6400457 [379] 0.6399072 0.6397686 0.6396298 0.6394909 0.6393518 0.6392125 0.6390731 [386] 0.6389336 0.6387939 0.6386540 0.6385140 0.6383738 0.6382335 0.6380930 [393] 0.6379524 0.6378116 0.6376707 0.6375296 0.6373884 0.6372470 0.6371054 [400] 0.6369638 0.6368219 > mx [1] 0.6789489 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1n9wy1196019173.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/2r4gh1196019173.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/3ghtd1196019173.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/4xjci1196019173.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/5ngjj1196019173.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/6qm6y1196019173.tab") > > system("convert tmp/1n9wy1196019173.ps tmp/1n9wy1196019173.png") > system("convert tmp/2r4gh1196019173.ps tmp/2r4gh1196019173.png") > system("convert tmp/3ghtd1196019173.ps tmp/3ghtd1196019173.png") > system("convert tmp/4xjci1196019173.ps tmp/4xjci1196019173.png") > system("convert tmp/5ngjj1196019173.ps tmp/5ngjj1196019173.png") > > > proc.time() user system elapsed 1.327 0.798 1.530