R version 2.8.1 (2008-12-22) Copyright (C) 2008 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(116.2,111.2,105.8,122.7,99.5,107.9,124.6,115.0,110.3,132.7,99.7,96.5,118.7,112.9,130.5,137.9,115.0,116.8,140.9,120.7,134.2,147.3,112.4,107.1,128.4,137.7,135.0,151.0,137.4,132.4,161.3,139.8,146.0,166.5,143.3,121.0,152.6,154.4,154.6,158.0,142.6,153.4,163.4,167.3,154.8,165.7,144.7,120.9,152.8,160.2,128.3,150.5,117.0,116.0,133.3,116.4,104.0,126.6,92.9,83.6) > x <- c(121.6,118.8,114.0,111.5,97.2,102.5,113.4,109.8,104.9,126.1,80.0,96.8,117.2,112.3,117.3,111.1,102.2,104.3,122.9,107.6,121.3,131.5,89.0,104.4,128.9,135.9,133.3,121.3,120.5,120.4,137.9,126.1,133.2,151.1,105.0,119.0,140.4,156.6,137.1,122.7,125.8,139.3,134.9,149.2,132.3,149.0,117.2,119.6,152.0,149.4,127.3,114.1,102.1,107.7,104.4,102.1,96.0,109.3,90.0,83.9) > #'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.8244989 0.8247282 0.8249567 0.8251843 0.8254110 0.8256369 0.8258618 [8] 0.8260860 0.8263092 0.8265316 0.8267531 0.8269737 0.8271935 0.8274124 [15] 0.8276304 0.8278475 0.8280638 0.8282792 0.8284937 0.8287073 0.8289200 [22] 0.8291319 0.8293429 0.8295529 0.8297621 0.8299704 0.8301779 0.8303844 [29] 0.8305900 0.8307948 0.8309987 0.8312016 0.8314037 0.8316049 0.8318052 [36] 0.8320046 0.8322031 0.8324006 0.8325973 0.8327931 0.8329880 0.8331820 [43] 0.8333751 0.8335673 0.8337586 0.8339490 0.8341385 0.8343271 0.8345147 [50] 0.8347015 0.8348873 0.8350723 0.8352563 0.8354395 0.8356217 0.8358030 [57] 0.8359834 0.8361629 0.8363414 0.8365191 0.8366958 0.8368717 0.8370466 [64] 0.8372206 0.8373937 0.8375658 0.8377371 0.8379074 0.8380768 0.8382453 [71] 0.8384129 0.8385795 0.8387453 0.8389101 0.8390740 0.8392369 0.8393990 [78] 0.8395601 0.8397203 0.8398796 0.8400379 0.8401954 0.8403519 0.8405074 [85] 0.8406621 0.8408158 0.8409686 0.8411205 0.8412715 0.8414215 0.8415706 [92] 0.8417188 0.8418660 0.8420123 0.8421577 0.8423022 0.8424457 0.8425883 [99] 0.8427300 0.8428707 0.8430105 0.8431494 0.8432874 0.8434244 0.8435605 [106] 0.8436957 0.8438299 0.8439632 0.8440956 0.8442270 0.8443575 0.8444871 [113] 0.8446158 0.8447435 0.8448703 0.8449961 0.8451211 0.8452451 0.8453681 [120] 0.8454903 0.8456115 0.8457317 0.8458511 0.8459695 0.8460870 0.8462035 [127] 0.8463192 0.8464339 0.8465476 0.8466605 0.8467724 0.8468833 0.8469934 [134] 0.8471025 0.8472107 0.8473179 0.8474242 0.8475296 0.8476341 0.8477376 [141] 0.8478403 0.8479419 0.8480427 0.8481425 0.8482414 0.8483394 0.8484364 [148] 0.8485326 0.8486277 0.8487220 0.8488154 0.8489078 0.8489993 0.8490898 [155] 0.8491795 0.8492682 0.8493560 0.8494429 0.8495288 0.8496138 0.8496979 [162] 0.8497811 0.8498634 0.8499447 0.8500251 0.8501046 0.8501832 0.8502609 [169] 0.8503376 0.8504135 0.8504884 0.8505624 0.8506354 0.8507076 0.8507788 [176] 0.8508492 0.8509186 0.8509871 0.8510547 0.8511213 0.8511871 0.8512519 [183] 0.8513159 0.8513789 0.8514410 0.8515022 0.8515625 0.8516219 0.8516804 [190] 0.8517380 0.8517947 0.8518505 0.8519053 0.8519593 0.8520123 0.8520645 [197] 0.8521157 0.8521661 0.8522156 0.8522641 0.8523118 0.8523585 0.8524044 [204] 0.8524493 0.8524934 0.8525366 0.8525789 0.8526202 0.8526607 0.8527003 [211] 0.8527390 0.8527769 0.8528138 0.8528498 0.8528850 0.8529193 0.8529526 [218] 0.8529851 0.8530167 0.8530475 0.8530773 0.8531063 0.8531344 0.8531616 [225] 0.8531879 0.8532133 0.8532379 0.8532616 0.8532844 0.8533064 0.8533275 [232] 0.8533477 0.8533670 0.8533854 0.8534030 0.8534198 0.8534356 0.8534506 [239] 0.8534647 0.8534780 0.8534904 0.8535019 0.8535126 0.8535224 0.8535314 [246] 0.8535395 0.8535467 0.8535531 0.8535586 0.8535633 0.8535671 0.8535701 [253] 0.8535722 0.8535735 0.8535739 0.8535735 0.8535723 0.8535702 0.8535672 [260] 0.8535634 0.8535588 0.8535533 0.8535470 0.8535398 0.8535318 0.8535230 [267] 0.8535134 0.8535029 0.8534916 0.8534794 0.8534664 0.8534526 0.8534380 [274] 0.8534225 0.8534062 0.8533891 0.8533712 0.8533524 0.8533329 0.8533125 [281] 0.8532913 0.8532693 0.8532464 0.8532228 0.8531983 0.8531730 0.8531470 [288] 0.8531201 0.8530924 0.8530639 0.8530346 0.8530045 0.8529736 0.8529419 [295] 0.8529094 0.8528761 0.8528420 0.8528071 0.8527714 0.8527349 0.8526976 [302] 0.8526596 0.8526207 0.8525811 0.8525407 0.8524995 0.8524575 0.8524147 [309] 0.8523712 0.8523269 0.8522818 0.8522359 0.8521893 0.8521418 0.8520937 [316] 0.8520447 0.8519950 0.8519445 0.8518932 0.8518412 0.8517884 0.8517349 [323] 0.8516805 0.8516255 0.8515697 0.8515131 0.8514558 0.8513977 0.8513388 [330] 0.8512793 0.8512189 0.8511578 0.8510960 0.8510335 0.8509701 0.8509061 [337] 0.8508413 0.8507758 0.8507095 0.8506425 0.8505748 0.8505063 0.8504372 [344] 0.8503672 0.8502966 0.8502252 0.8501531 0.8500803 0.8500068 0.8499325 [351] 0.8498575 0.8497818 0.8497054 0.8496283 0.8495505 0.8494719 0.8493927 [358] 0.8493127 0.8492321 0.8491507 0.8490686 0.8489859 0.8489024 0.8488182 [365] 0.8487334 0.8486478 0.8485616 0.8484746 0.8483870 0.8482987 0.8482097 [372] 0.8481200 0.8480296 0.8479385 0.8478468 0.8477544 0.8476613 0.8475675 [379] 0.8474731 0.8473780 0.8472822 0.8471857 0.8470886 0.8469908 0.8468924 [386] 0.8467932 0.8466935 0.8465930 0.8464919 0.8463902 0.8462878 0.8461847 [393] 0.8460810 0.8459766 0.8458716 0.8457660 0.8456597 0.8455527 0.8454451 [400] 0.8453369 0.8452280 > mx [1] 0.853574 > mxli [1] 0.54 > 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/rcomp/tmp/1o8251258036061.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/rcomp/tmp/2e4fn1258036061.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/rcomp/tmp/3eury1258036061.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/4cg3d1258036061.tab") > > system("convert tmp/1o8251258036061.ps tmp/1o8251258036061.png") > system("convert tmp/2e4fn1258036061.ps tmp/2e4fn1258036061.png") > system("convert tmp/3eury1258036061.ps tmp/3eury1258036061.png") > > > proc.time() user system elapsed 0.910 0.780 1.573