R version 2.9.0 (2009-04-17) Copyright (C) 2009 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. > y <- c(62,64,62,64,64,69,69,65,56,58,53,62,55,60,59,58,53,57,57,53,54,53,57,57,55,49,50,49,54,58,58,52,56,52,59,53,52,53,51,50,56,52,46,48,46,48,48,49,53,48,51,48,50,55,52,53,52,55,53,53,56,54,52,55,54,59,56,56,51,53,52,51,46,49,46,55,57,53,52,53,50,54,53,50,51,52,47,51,49,53,52,45,53,51,48,48,48,48,40,43,40,39,39,36,41,39,40,39,46,40,37,37,44,41,40,36,38,43,42,45,46) > x <- c(33,39,45,46,45,45,49,50,54,59,58,56,48,50,52,53,55,43,42,38,41,41,39,34,27,15,14,31,41,43,46,42,45,45,40,35,36,38,39,32,24,21,12,29,36,31,28,30,38,27,40,40,44,47,45,42,38,46,37,41,40,33,34,36,36,38,42,35,25,24,22,27,17,30,30,34,37,36,33,33,33,37,40,35,37,43,42,33,39,40,37,44,42,43,40,30,30,31,18,24,22,26,28,23,17,12,9,19,21,18,18,15,24,18,19,30,33,35,36,47,46) > #'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(x1,y) + if (mx < abs(c[i])) + { + mx <- abs(c[i]) + mxli <- l[i] + } + } > c [1] 0.4883116 0.4893854 0.4904586 0.4915311 0.4926031 0.4936743 0.4947447 [8] 0.4958144 0.4968832 0.4979512 0.4990182 0.5000843 0.5011494 0.5022135 [15] 0.5032765 0.5043384 0.5053991 0.5064586 0.5075169 0.5085740 0.5096297 [22] 0.5106840 0.5117369 0.5127884 0.5138385 0.5148870 0.5159339 0.5169792 [29] 0.5180229 0.5190649 0.5201052 0.5211437 0.5221805 0.5232153 0.5242483 [36] 0.5252794 0.5263085 0.5273356 0.5283607 0.5293837 0.5304045 0.5314232 [43] 0.5324397 0.5334540 0.5344660 0.5354757 0.5364830 0.5374880 0.5384905 [50] 0.5394905 0.5404881 0.5414831 0.5424755 0.5434653 0.5444524 0.5454369 [57] 0.5464187 0.5473976 0.5483738 0.5493472 0.5503177 0.5512852 0.5522499 [64] 0.5532115 0.5541702 0.5551258 0.5560783 0.5570278 0.5579740 0.5589171 [71] 0.5598570 0.5607937 0.5617270 0.5626571 0.5635838 0.5645071 0.5654271 [78] 0.5663436 0.5672566 0.5681661 0.5690721 0.5699746 0.5708734 0.5717686 [85] 0.5726602 0.5735481 0.5744324 0.5753128 0.5761895 0.5770625 0.5779316 [92] 0.5787969 0.5796582 0.5805158 0.5813693 0.5822190 0.5830646 0.5839063 [99] 0.5847439 0.5855775 0.5864070 0.5872325 0.5880538 0.5888709 0.5896839 [106] 0.5904927 0.5912974 0.5920977 0.5928939 0.5936857 0.5944733 0.5952565 [113] 0.5960354 0.5968100 0.5975802 0.5983459 0.5991073 0.5998643 0.6006168 [120] 0.6013648 0.6021084 0.6028475 0.6035820 0.6043120 0.6050375 0.6057584 [127] 0.6064747 0.6071865 0.6078936 0.6085961 0.6092940 0.6099872 0.6106758 [134] 0.6113597 0.6120389 0.6127134 0.6133831 0.6140482 0.6147086 0.6153641 [141] 0.6160150 0.6166611 0.6173024 0.6179389 0.6185706 0.6191975 0.6198196 [148] 0.6204369 0.6210493 0.6216570 0.6222598 0.6228577 0.6234508 0.6240390 [155] 0.6246223 0.6252008 0.6257744 0.6263431 0.6269069 0.6274659 0.6280199 [162] 0.6285690 0.6291132 0.6296526 0.6301870 0.6307164 0.6312410 0.6317607 [169] 0.6322754 0.6327852 0.6332901 0.6337900 0.6342851 0.6347752 0.6352603 [176] 0.6357406 0.6362159 0.6366863 0.6371518 0.6376123 0.6380679 0.6385186 [183] 0.6389644 0.6394053 0.6398412 0.6402722 0.6406984 0.6411196 0.6415359 [190] 0.6419473 0.6423538 0.6427554 0.6431521 0.6435439 0.6439309 0.6443130 [197] 0.6446902 0.6450625 0.6454300 0.6457926 0.6461504 0.6465033 0.6468514 [204] 0.6471947 0.6475331 0.6478667 0.6481956 0.6485196 0.6488388 0.6491532 [211] 0.6494628 0.6497677 0.6500678 0.6503632 0.6506537 0.6509396 0.6512207 [218] 0.6514971 0.6517688 0.6520358 0.6522981 0.6525557 0.6528087 0.6530569 [225] 0.6533006 0.6535395 0.6537739 0.6540036 0.6542287 0.6544492 0.6546651 [232] 0.6548764 0.6550831 0.6552853 0.6554830 0.6556761 0.6558647 0.6560488 [239] 0.6562283 0.6564034 0.6565740 0.6567402 0.6569019 0.6570591 0.6572120 [246] 0.6573604 0.6575044 0.6576440 0.6577793 0.6579102 0.6580367 0.6581589 [253] 0.6582768 0.6583904 0.6584996 0.6586046 0.6587054 0.6588018 0.6588941 [260] 0.6589821 0.6590659 0.6591455 0.6592209 0.6592922 0.6593593 0.6594222 [267] 0.6594810 0.6595358 0.6595864 0.6596329 0.6596754 0.6597138 0.6597482 [274] 0.6597785 0.6598049 0.6598273 0.6598456 0.6598601 0.6598705 0.6598771 [281] 0.6598797 0.6598784 0.6598733 0.6598643 0.6598514 0.6598347 0.6598141 [288] 0.6597898 0.6597616 0.6597297 0.6596940 0.6596546 0.6596115 0.6595646 [295] 0.6595141 0.6594598 0.6594019 0.6593404 0.6592752 0.6592064 0.6591340 [302] 0.6590580 0.6589785 0.6588954 0.6588087 0.6587186 0.6586249 0.6585278 [309] 0.6584271 0.6583231 0.6582156 0.6581046 0.6579903 0.6578726 0.6577514 [316] 0.6576270 0.6574992 0.6573681 0.6572336 0.6570959 0.6569549 0.6568107 [323] 0.6566632 0.6565124 0.6563585 0.6562014 0.6560411 0.6558776 0.6557110 [330] 0.6555413 0.6553684 0.6551925 0.6550135 0.6548314 0.6546463 0.6544581 [337] 0.6542669 0.6540728 0.6538756 0.6536755 0.6534724 0.6532665 0.6530575 [344] 0.6528457 0.6526311 0.6524135 0.6521931 0.6519698 0.6517438 0.6515149 [351] 0.6512833 0.6510488 0.6508117 0.6505718 0.6503291 0.6500838 0.6498358 [358] 0.6495851 0.6493317 0.6490757 0.6488171 0.6485558 0.6482920 0.6480256 [365] 0.6477566 0.6474851 0.6472110 0.6469345 0.6466554 0.6463739 0.6460898 [372] 0.6458034 0.6455145 0.6452231 0.6449294 0.6446333 0.6443348 0.6440339 [379] 0.6437307 0.6434252 0.6431173 0.6428072 0.6424947 0.6421800 0.6418631 [386] 0.6415439 0.6412225 0.6408989 0.6405731 0.6402451 0.6399149 0.6395826 [393] 0.6392482 0.6389117 0.6385730 0.6382323 0.6378895 0.6375446 0.6371977 [400] 0.6368487 0.6364978 > mx [1] 0.6598797 > mxli [1] 0.8 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > r<-lm(y~x) > se <- sqrt(var(r$residuals)) > r1 <- lm(y~x1) > se1 <- sqrt(var(r1$residuals)) > postscript(file="/var/www/html/rcomp/tmp/1xnk31258122535.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(l,c,main='Box-Cox Linearity Plot',xlab='Lambda',ylab='correlation') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/2eh0a1258122535.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x,y,main='Linear Fit of Original Data',xlab='x',ylab='y') > abline(r) > grid() > mtext(paste('Residual Standard Deviation = ',se)) > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/3l5jv1258122535.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x1,y,main='Linear Fit of Transformed Data',xlab='x',ylab='y') > abline(r1) > grid() > mtext(paste('Residual Standard Deviation = ',se1)) > dev.off() null device 1 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Box-Cox Linearity 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(x)',header=TRUE) > a<-table.element(a,mxli) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Residual SD (orginial)',header=TRUE) > a<-table.element(a,se) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Residual SD (transformed)',header=TRUE) > a<-table.element(a,se1) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/4rcqe1258122535.tab") > > system("convert tmp/1xnk31258122535.ps tmp/1xnk31258122535.png") > system("convert tmp/2eh0a1258122535.ps tmp/2eh0a1258122535.png") > system("convert tmp/3l5jv1258122535.ps tmp/3l5jv1258122535.png") > > > proc.time() user system elapsed 0.802 0.515 0.935