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. > y <- c(140,132,117,114,113,110,107,103,98,98,137,148,147,139,130,128,127,123,118,114,108,111,151,159,158,148,138,137,136,133,126,120,114,116,153,162,161,149,139,135,130,127,122,117,112,113,149,157,157,147,137,132,125,123,117,114,111,112,144,150,149,134,123,116,117,111,105,102,95,93,124,130,124) > x <- c(513,503,471,471,476,475,470,461,455,456,517,525,523,519,509,512,519,517,510,509,501,507,569,580,578,565,547,555,562,561,555,544,537,543,594,611,613,611,594,595,591,589,584,573,567,569,621,629,628,612,595,597,593,590,580,574,573,573,620,626,620,588,566,557,561,549,532,526,511,499,555,565,542) > #'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 Linearity Plot (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxlin.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(x1,y) + if (mx < abs(c[i])) + { + mx <- abs(c[i]) + mxli <- l[i] + } + } > c [1] 0.6341856 0.6342577 0.6343297 0.6344017 0.6344736 0.6345454 0.6346172 [8] 0.6346889 0.6347605 0.6348320 0.6349035 0.6349749 0.6350462 0.6351175 [15] 0.6351887 0.6352598 0.6353309 0.6354018 0.6354728 0.6355436 0.6356144 [22] 0.6356851 0.6357557 0.6358263 0.6358968 0.6359672 0.6360375 0.6361078 [29] 0.6361780 0.6362482 0.6363182 0.6363882 0.6364581 0.6365280 0.6365978 [36] 0.6366675 0.6367371 0.6368067 0.6368762 0.6369456 0.6370150 0.6370842 [43] 0.6371535 0.6372226 0.6372917 0.6373606 0.6374296 0.6374984 0.6375672 [50] 0.6376359 0.6377045 0.6377731 0.6378416 0.6379100 0.6379783 0.6380466 [57] 0.6381148 0.6381829 0.6382510 0.6383189 0.6383868 0.6384547 0.6385224 [64] 0.6385901 0.6386577 0.6387253 0.6387927 0.6388601 0.6389274 0.6389947 [71] 0.6390619 0.6391289 0.6391960 0.6392629 0.6393298 0.6393966 0.6394633 [78] 0.6395300 0.6395966 0.6396631 0.6397295 0.6397958 0.6398621 0.6399283 [85] 0.6399945 0.6400605 0.6401265 0.6401924 0.6402583 0.6403240 0.6403897 [92] 0.6404553 0.6405208 0.6405863 0.6406517 0.6407170 0.6407822 0.6408474 [99] 0.6409125 0.6409775 0.6410424 0.6411073 0.6411721 0.6412368 0.6413014 [106] 0.6413660 0.6414304 0.6414948 0.6415592 0.6416234 0.6416876 0.6417517 [113] 0.6418157 0.6418797 0.6419435 0.6420073 0.6420711 0.6421347 0.6421983 [120] 0.6422618 0.6423252 0.6423885 0.6424518 0.6425150 0.6425781 0.6426411 [127] 0.6427041 0.6427669 0.6428297 0.6428925 0.6429551 0.6430177 0.6430802 [134] 0.6431426 0.6432049 0.6432672 0.6433294 0.6433915 0.6434535 0.6435155 [141] 0.6435773 0.6436391 0.6437008 0.6437625 0.6438241 0.6438855 0.6439469 [148] 0.6440083 0.6440695 0.6441307 0.6441918 0.6442528 0.6443138 0.6443746 [155] 0.6444354 0.6444961 0.6445568 0.6446173 0.6446778 0.6447382 0.6447985 [162] 0.6448587 0.6449189 0.6449790 0.6450390 0.6450989 0.6451587 0.6452185 [169] 0.6452782 0.6453378 0.6453973 0.6454568 0.6455162 0.6455755 0.6456347 [176] 0.6456938 0.6457529 0.6458118 0.6458707 0.6459296 0.6459883 0.6460470 [183] 0.6461055 0.6461640 0.6462225 0.6462808 0.6463391 0.6463973 0.6464554 [190] 0.6465134 0.6465713 0.6466292 0.6466870 0.6467447 0.6468023 0.6468599 [197] 0.6469174 0.6469747 0.6470321 0.6470893 0.6471464 0.6472035 0.6472605 [204] 0.6473174 0.6473742 0.6474310 0.6474877 0.6475442 0.6476007 0.6476572 [211] 0.6477135 0.6477698 0.6478260 0.6478821 0.6479381 0.6479941 0.6480499 [218] 0.6481057 0.6481614 0.6482171 0.6482726 0.6483281 0.6483834 0.6484387 [225] 0.6484940 0.6485491 0.6486042 0.6486592 0.6487141 0.6487689 0.6488236 [232] 0.6488783 0.6489328 0.6489873 0.6490417 0.6490961 0.6491503 0.6492045 [239] 0.6492586 0.6493126 0.6493665 0.6494204 0.6494741 0.6495278 0.6495814 [246] 0.6496349 0.6496884 0.6497417 0.6497950 0.6498482 0.6499013 0.6499544 [253] 0.6500073 0.6500602 0.6501130 0.6501657 0.6502183 0.6502709 0.6503233 [260] 0.6503757 0.6504280 0.6504802 0.6505324 0.6505844 0.6506364 0.6506883 [267] 0.6507401 0.6507918 0.6508435 0.6508950 0.6509465 0.6509979 0.6510492 [274] 0.6511005 0.6511516 0.6512027 0.6512537 0.6513046 0.6513554 0.6514062 [281] 0.6514568 0.6515074 0.6515579 0.6516083 0.6516586 0.6517089 0.6517591 [288] 0.6518092 0.6518592 0.6519091 0.6519589 0.6520087 0.6520584 0.6521080 [295] 0.6521575 0.6522069 0.6522562 0.6523055 0.6523547 0.6524038 0.6524528 [302] 0.6525018 0.6525506 0.6525994 0.6526481 0.6526967 0.6527452 0.6527936 [309] 0.6528420 0.6528903 0.6529385 0.6529866 0.6530346 0.6530826 0.6531304 [316] 0.6531782 0.6532259 0.6532735 0.6533210 0.6533685 0.6534159 0.6534631 [323] 0.6535103 0.6535575 0.6536045 0.6536515 0.6536983 0.6537451 0.6537918 [330] 0.6538385 0.6538850 0.6539315 0.6539778 0.6540241 0.6540703 0.6541165 [337] 0.6541625 0.6542085 0.6542543 0.6543001 0.6543459 0.6543915 0.6544370 [344] 0.6544825 0.6545279 0.6545732 0.6546184 0.6546635 0.6547086 0.6547535 [351] 0.6547984 0.6548432 0.6548879 0.6549326 0.6549771 0.6550216 0.6550660 [358] 0.6551103 0.6551545 0.6551987 0.6552427 0.6552867 0.6553306 0.6553744 [365] 0.6554181 0.6554617 0.6555053 0.6555488 0.6555922 0.6556355 0.6556787 [372] 0.6557219 0.6557649 0.6558079 0.6558508 0.6558936 0.6559363 0.6559790 [379] 0.6560215 0.6560640 0.6561064 0.6561487 0.6561910 0.6562331 0.6562752 [386] 0.6563171 0.6563590 0.6564009 0.6564426 0.6564842 0.6565258 0.6565673 [393] 0.6566087 0.6566500 0.6566913 0.6567324 0.6567735 0.6568145 0.6568554 [400] 0.6568962 0.6569369 > mx [1] 0.6569369 > mxli [1] 2 > 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/1bxcf1194257120.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/2trw71194257120.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/3xj3v1194257120.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 > 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/4ykps1194257121.tab") > > system("convert tmp/1bxcf1194257120.ps tmp/1bxcf1194257120.png") > system("convert tmp/2trw71194257120.ps tmp/2trw71194257120.png") > system("convert tmp/3xj3v1194257120.ps tmp/3xj3v1194257120.png") > > > proc.time() user system elapsed 1.057 0.519 1.203