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(1962.3,2095.2,2161,2115.1,1929,2004.5,2009.9,1524.9,2061.1,2261.6,2103.6,2224.3,2173.8,2119.2,2226.4,2159.6,1918.3,2116.1,1948.3,1514.3,2180.5,2312.6,2019.8,2200.8,2028.9,2178.7,2433.7,2230.5,1884.2,2372.7,1918.6,1679.4,2327.3,2225.2,2211.7,2463.6,2029.5,2173.6,2387,2234,2179.9,2397,1960.2,1824.1,2479.3,2234.9,2345.9,2428.9,2179.4,2216.9,2642.3,2340.5,2474.6,2641.8,2165.1,1996.2,2562.9,2529.9,2549.6,2455.1,2472,2424.7,2820.1,2666,2654.6,2732.2,2546.9) > #'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.5305901 0.5310559 0.5315213 0.5319864 0.5324510 0.5329152 0.5333791 [8] 0.5338425 0.5343055 0.5347681 0.5352304 0.5356922 0.5361536 0.5366145 [15] 0.5370751 0.5375352 0.5379949 0.5384542 0.5389130 0.5393714 0.5398294 [22] 0.5402870 0.5407441 0.5412007 0.5416570 0.5421127 0.5425680 0.5430229 [29] 0.5434773 0.5439313 0.5443848 0.5448378 0.5452904 0.5457425 0.5461941 [36] 0.5466453 0.5470960 0.5475462 0.5479959 0.5484452 0.5488940 0.5493423 [43] 0.5497901 0.5502374 0.5506842 0.5511305 0.5515763 0.5520217 0.5524665 [50] 0.5529108 0.5533546 0.5537979 0.5542407 0.5546830 0.5551248 0.5555660 [57] 0.5560068 0.5564470 0.5568867 0.5573259 0.5577645 0.5582026 0.5586402 [64] 0.5590772 0.5595137 0.5599497 0.5603851 0.5608200 0.5612543 0.5616881 [71] 0.5621214 0.5625540 0.5629862 0.5634178 0.5638488 0.5642793 0.5647092 [78] 0.5651385 0.5655673 0.5659955 0.5664231 0.5668502 0.5672767 0.5677026 [85] 0.5681280 0.5685527 0.5689769 0.5694005 0.5698236 0.5702460 0.5706678 [92] 0.5710891 0.5715098 0.5719298 0.5723493 0.5727682 0.5731865 0.5736042 [99] 0.5740212 0.5744377 0.5748536 0.5752688 0.5756835 0.5760975 0.5765110 [106] 0.5769238 0.5773360 0.5777476 0.5781585 0.5785689 0.5789786 0.5793877 [113] 0.5797961 0.5802040 0.5806112 0.5810178 0.5814237 0.5818290 0.5822337 [120] 0.5826377 0.5830411 0.5834439 0.5838460 0.5842475 0.5846483 0.5850485 [127] 0.5854480 0.5858469 0.5862452 0.5866427 0.5870397 0.5874360 0.5878316 [134] 0.5882265 0.5886208 0.5890145 0.5894075 0.5897998 0.5901914 0.5905824 [141] 0.5909727 0.5913624 0.5917514 0.5921397 0.5925273 0.5929143 0.5933006 [148] 0.5936862 0.5940711 0.5944554 0.5948390 0.5952218 0.5956041 0.5959856 [155] 0.5963664 0.5967466 0.5971261 0.5975049 0.5978829 0.5982604 0.5986371 [162] 0.5990131 0.5993884 0.5997630 0.6001370 0.6005102 0.6008828 0.6012546 [169] 0.6016257 0.6019962 0.6023659 0.6027350 0.6031033 0.6034709 0.6038378 [176] 0.6042040 0.6045696 0.6049343 0.6052984 0.6056618 0.6060245 0.6063864 [183] 0.6067477 0.6071082 0.6074680 0.6078271 0.6081855 0.6085431 0.6089001 [190] 0.6092563 0.6096118 0.6099666 0.6103206 0.6106740 0.6110266 0.6113785 [197] 0.6117296 0.6120801 0.6124298 0.6127788 0.6131270 0.6134746 0.6138214 [204] 0.6141675 0.6145128 0.6148574 0.6152013 0.6155444 0.6158868 0.6162285 [211] 0.6165695 0.6169097 0.6172492 0.6175879 0.6179259 0.6182632 0.6185997 [218] 0.6189355 0.6192706 0.6196049 0.6199385 0.6202713 0.6206034 0.6209348 [225] 0.6212654 0.6215952 0.6219244 0.6222528 0.6225804 0.6229073 0.6232335 [232] 0.6235589 0.6238835 0.6242075 0.6245306 0.6248531 0.6251748 0.6254957 [239] 0.6258159 0.6261353 0.6264540 0.6267720 0.6270892 0.6274056 0.6277213 [246] 0.6280363 0.6283505 0.6286640 0.6289767 0.6292886 0.6295998 0.6299103 [253] 0.6302200 0.6305289 0.6308371 0.6311446 0.6314513 0.6317572 0.6320624 [260] 0.6323668 0.6326705 0.6329735 0.6332757 0.6335771 0.6338778 0.6341777 [267] 0.6344769 0.6347753 0.6350730 0.6353699 0.6356660 0.6359614 0.6362561 [274] 0.6365500 0.6368431 0.6371355 0.6374272 0.6377180 0.6380082 0.6382976 [281] 0.6385862 0.6388740 0.6391612 0.6394475 0.6397331 0.6400180 0.6403021 [288] 0.6405854 0.6408680 0.6411499 0.6414310 0.6417113 0.6419909 0.6422697 [295] 0.6425478 0.6428251 0.6431017 0.6433775 0.6436526 0.6439269 0.6442004 [302] 0.6444733 0.6447453 0.6450166 0.6452872 0.6455570 0.6458260 0.6460943 [309] 0.6463619 0.6466287 0.6468948 0.6471601 0.6474246 0.6476884 0.6479515 [316] 0.6482138 0.6484753 0.6487361 0.6489962 0.6492555 0.6495141 0.6497719 [323] 0.6500289 0.6502853 0.6505408 0.6507957 0.6510498 0.6513031 0.6515557 [330] 0.6518075 0.6520586 0.6523090 0.6525586 0.6528075 0.6530556 0.6533030 [337] 0.6535496 0.6537955 0.6540407 0.6542851 0.6545288 0.6547717 0.6550139 [344] 0.6552554 0.6554961 0.6557361 0.6559753 0.6562138 0.6564516 0.6566886 [351] 0.6569249 0.6571605 0.6573953 0.6576294 0.6578627 0.6580953 0.6583272 [358] 0.6585584 0.6587888 0.6590185 0.6592474 0.6594756 0.6597031 0.6599299 [365] 0.6601559 0.6603812 0.6606058 0.6608296 0.6610527 0.6612751 0.6614968 [372] 0.6617177 0.6619379 0.6621574 0.6623762 0.6625942 0.6628115 0.6630281 [379] 0.6632440 0.6634591 0.6636735 0.6638872 0.6641002 0.6643125 0.6645240 [386] 0.6647348 0.6649450 0.6651543 0.6653630 0.6655710 0.6657782 0.6659847 [393] 0.6661906 0.6663957 0.6666001 0.6668037 0.6670067 0.6672090 0.6674105 [400] 0.6676113 0.6678115 > mx [1] 0.6678115 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1940b1194292903.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/2ujeb1194292903.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/3kcf61194292903.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/46t7j1194292903.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/5unuh1194292903.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/6bojx1194292903.tab") > > system("convert tmp/1940b1194292903.ps tmp/1940b1194292903.png") > system("convert tmp/2ujeb1194292903.ps tmp/2ujeb1194292903.png") > system("convert tmp/3kcf61194292903.ps tmp/3kcf61194292903.png") > system("convert tmp/46t7j1194292903.ps tmp/46t7j1194292903.png") > system("convert tmp/5unuh1194292903.ps tmp/5unuh1194292903.png") > > > proc.time() user system elapsed 1.354 0.793 1.609