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(326011,328282,317480,317539,313737,312276,309391,302950,300316,304035,333476,337698,335932,323931,313927,314485,313218,309664,302963,298989,298423,301631,329765,335083,327616,309119,295916,291413,291542,284678,276475,272566,264981,263290,296806,303598,286994,276427,266424,267153,268381,262522,255542,253158,243803,250741,280445,285257,270976,261076,255603,260376,263903,264291,263276,262572,256167,264221,293860,300713) > x <- c(286602,283042,276687,277915,277128,277103,275037,270150,267140,264993,287259,291186,292300,288186,281477,282656,280190,280408,276836,275216,274352,271311,289802,290726,292300,278506,269826,265861,269034,264176,255198,253353,246057,235372,258556,260993,254663,250643,243422,247105,248541,245039,237080,237085,225554,226839,247934,248333,246969,245098,246263,255765,264319,268347,273046,273963,267430,271993,292710,295881) > #'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.8175693 0.8176322 0.8176959 0.8177556 0.8178202 0.8178833 0.8179462 [8] 0.8180078 0.8180705 0.8181323 0.8181959 0.8182574 0.8183192 0.8183806 [15] 0.8184426 0.8185030 0.8185650 0.8186259 0.8186867 0.8187475 0.8188087 [22] 0.8188695 0.8189300 0.8189904 0.8190508 0.8191112 0.8191715 0.8192317 [29] 0.8192914 0.8193514 0.8194110 0.8194706 0.8195301 0.8195895 0.8196487 [36] 0.8197079 0.8197669 0.8198257 0.8198846 0.8199433 0.8200019 0.8200603 [43] 0.8201187 0.8201769 0.8202350 0.8202930 0.8203508 0.8204086 0.8204663 [50] 0.8205238 0.8205813 0.8206386 0.8206958 0.8207528 0.8208098 0.8208667 [57] 0.8209234 0.8209800 0.8210366 0.8210930 0.8211492 0.8212054 0.8212615 [64] 0.8213174 0.8213732 0.8214289 0.8214845 0.8215400 0.8215954 0.8216506 [71] 0.8217058 0.8217608 0.8218157 0.8218705 0.8219252 0.8219797 0.8220342 [78] 0.8220885 0.8221427 0.8221969 0.8222508 0.8223047 0.8223585 0.8224121 [85] 0.8224657 0.8225191 0.8225724 0.8226256 0.8226787 0.8227316 0.8227845 [92] 0.8228372 0.8228898 0.8229423 0.8229947 0.8230470 0.8230992 0.8231512 [99] 0.8232031 0.8232550 0.8233067 0.8233583 0.8234097 0.8234611 0.8235123 [106] 0.8235635 0.8236145 0.8236654 0.8237162 0.8237668 0.8238174 0.8238678 [113] 0.8239182 0.8239684 0.8240185 0.8240685 0.8241183 0.8241681 0.8242177 [120] 0.8242673 0.8243167 0.8243660 0.8244152 0.8244642 0.8245132 0.8245620 [127] 0.8246108 0.8246594 0.8247079 0.8247563 0.8248045 0.8248527 0.8249007 [134] 0.8249486 0.8249964 0.8250441 0.8250917 0.8251392 0.8251865 0.8252338 [141] 0.8252809 0.8253279 0.8253748 0.8254216 0.8254683 0.8255148 0.8255613 [148] 0.8256076 0.8256538 0.8256999 0.8257459 0.8257917 0.8258375 0.8258831 [155] 0.8259286 0.8259740 0.8260193 0.8260645 0.8261096 0.8261545 0.8261994 [162] 0.8262441 0.8262887 0.8263332 0.8263776 0.8264219 0.8264660 0.8265100 [169] 0.8265540 0.8265978 0.8266415 0.8266851 0.8267285 0.8267719 0.8268151 [176] 0.8268582 0.8269012 0.8269441 0.8269869 0.8270296 0.8270721 0.8271146 [183] 0.8271569 0.8271991 0.8272412 0.8272832 0.8273251 0.8273668 0.8274085 [190] 0.8274500 0.8274914 0.8275327 0.8275739 0.8276150 0.8276559 0.8276968 [197] 0.8277375 0.8277781 0.8278186 0.8278590 0.8278993 0.8279395 0.8279795 [204] 0.8280194 0.8280593 0.8280990 0.8281386 0.8281780 0.8282174 0.8282566 [211] 0.8282958 0.8283348 0.8283737 0.8284125 0.8284512 0.8284898 0.8285282 [218] 0.8285666 0.8286048 0.8286429 0.8286809 0.8287188 0.8287566 0.8287942 [225] 0.8288318 0.8288692 0.8289065 0.8289437 0.8289808 0.8290178 0.8290547 [232] 0.8290914 0.8291281 0.8291646 0.8292010 0.8292373 0.8292735 0.8293095 [239] 0.8293455 0.8293814 0.8294171 0.8294527 0.8294882 0.8295236 0.8295589 [246] 0.8295940 0.8296291 0.8296640 0.8296989 0.8297336 0.8297682 0.8298027 [253] 0.8298370 0.8298713 0.8299055 0.8299395 0.8299734 0.8300072 0.8300409 [260] 0.8300745 0.8301080 0.8301413 0.8301746 0.8302077 0.8302407 0.8302736 [267] 0.8303064 0.8303391 0.8303717 0.8304041 0.8304365 0.8304687 0.8305008 [274] 0.8305328 0.8305647 0.8305965 0.8306282 0.8306597 0.8306912 0.8307225 [281] 0.8307537 0.8307848 0.8308158 0.8308467 0.8308775 0.8309081 0.8309386 [288] 0.8309691 0.8309994 0.8310296 0.8310597 0.8310897 0.8311195 0.8311493 [295] 0.8311789 0.8312085 0.8312379 0.8312672 0.8312964 0.8313255 0.8313545 [302] 0.8313833 0.8314121 0.8314407 0.8314692 0.8314976 0.8315259 0.8315541 [309] 0.8315822 0.8316102 0.8316380 0.8316658 0.8316934 0.8317209 0.8317483 [316] 0.8317756 0.8318028 0.8318299 0.8318568 0.8318837 0.8319104 0.8319370 [323] 0.8319635 0.8319899 0.8320162 0.8320424 0.8320685 0.8320944 0.8321203 [330] 0.8321460 0.8321716 0.8321971 0.8322225 0.8322478 0.8322730 0.8322981 [337] 0.8323230 0.8323479 0.8323726 0.8323972 0.8324217 0.8324461 0.8324704 [344] 0.8324946 0.8325187 0.8325426 0.8325665 0.8325902 0.8326138 0.8326373 [351] 0.8326607 0.8326840 0.8327072 0.8327303 0.8327532 0.8327761 0.8327988 [358] 0.8328215 0.8328440 0.8328664 0.8328887 0.8329109 0.8329329 0.8329549 [365] 0.8329768 0.8329985 0.8330201 0.8330417 0.8330631 0.8330844 0.8331056 [372] 0.8331267 0.8331476 0.8331685 0.8331892 0.8332099 0.8332304 0.8332508 [379] 0.8332711 0.8332914 0.8333114 0.8333314 0.8333513 0.8333711 0.8333907 [386] 0.8334103 0.8334297 0.8334490 0.8334682 0.8334873 0.8335063 0.8335252 [393] 0.8335440 0.8335627 0.8335812 0.8335997 0.8336180 0.8336362 0.8336544 [400] 0.8336724 0.8336903 > mx [1] 0.8336903 > 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/15xjh1258559297.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/2jmjr1258559297.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/3m7yg1258559297.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/4yxd21258559297.tab") > > system("convert tmp/15xjh1258559297.ps tmp/15xjh1258559297.png") > system("convert tmp/2jmjr1258559297.ps tmp/2jmjr1258559297.png") > system("convert tmp/3m7yg1258559297.ps tmp/3m7yg1258559297.png") > > > proc.time() user system elapsed 0.773 0.506 0.912