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(108.01,101.21,119.93,94.76,95.26,117.96,115.86,111.44,108.16,108.77,109.45,124.83,115.31,109.49,124.24,92.85,98.42,120.88,111.72,116.1,109.37,111.65,114.29,133.68,114.27,126.49,131,104,108.88,128.48,132.44,128.04,116.35,120.93,118.59,133.1,121.05,127.62,135.44,114.88,114.34,128.85,138.9,129.44,114.96,127.98,127.03,128.75,137.91,128.37,135.9,122.19,113.08,136.2,138,115.24,110.95,99.23,102.39,112.67) > x <- c(102.9,97.4,111.4,87.4,96.8,114.1,110.3,103.9,101.6,94.6,95.9,104.7,102.8,98.1,113.9,80.9,95.7,113.2,105.9,108.8,102.3,99,100.7,115.5,100.7,109.9,114.6,85.4,100.5,114.8,116.5,112.9,102,106,105.3,118.8,106.1,109.3,117.2,92.5,104.2,112.5,122.4,113.3,100,110.7,112.8,109.8,117.3,109.1,115.9,96,99.8,116.8,115.7,99.4,94.3,91,93.2,103.1) > #'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.8598265 0.8599753 0.8601237 0.8602719 0.8604197 0.8605672 0.8607143 [8] 0.8608611 0.8610076 0.8611538 0.8612996 0.8614451 0.8615902 0.8617351 [15] 0.8618796 0.8620237 0.8621675 0.8623110 0.8624542 0.8625970 0.8627396 [22] 0.8628817 0.8630236 0.8631651 0.8633063 0.8634471 0.8635876 0.8637278 [29] 0.8638677 0.8640072 0.8641464 0.8642852 0.8644238 0.8645620 0.8646998 [36] 0.8648374 0.8649746 0.8651115 0.8652480 0.8653842 0.8655201 0.8656557 [43] 0.8657909 0.8659258 0.8660604 0.8661946 0.8663285 0.8664621 0.8665954 [50] 0.8667283 0.8668609 0.8669931 0.8671251 0.8672567 0.8673879 0.8675189 [57] 0.8676495 0.8677798 0.8679098 0.8680394 0.8681687 0.8682977 0.8684263 [64] 0.8685546 0.8686826 0.8688103 0.8689376 0.8690646 0.8691913 0.8693177 [71] 0.8694437 0.8695694 0.8696948 0.8698198 0.8699445 0.8700689 0.8701930 [78] 0.8703167 0.8704402 0.8705632 0.8706860 0.8708084 0.8709305 0.8710523 [85] 0.8711738 0.8712949 0.8714157 0.8715362 0.8716564 0.8717762 0.8718957 [92] 0.8720149 0.8721338 0.8722523 0.8723705 0.8724884 0.8726059 0.8727232 [99] 0.8728401 0.8729567 0.8730730 0.8731889 0.8733045 0.8734198 0.8735348 [106] 0.8736495 0.8737638 0.8738778 0.8739915 0.8741049 0.8742179 0.8743306 [113] 0.8744431 0.8745551 0.8746669 0.8747783 0.8748895 0.8750003 0.8751107 [120] 0.8752209 0.8753307 0.8754403 0.8755495 0.8756583 0.8757669 0.8758751 [127] 0.8759831 0.8760907 0.8761980 0.8763049 0.8764116 0.8765179 0.8766239 [134] 0.8767296 0.8768350 0.8769401 0.8770448 0.8771492 0.8772533 0.8773571 [141] 0.8774606 0.8775638 0.8776666 0.8777692 0.8778714 0.8779733 0.8780749 [148] 0.8781761 0.8782771 0.8783777 0.8784781 0.8785781 0.8786778 0.8787772 [155] 0.8788762 0.8789750 0.8790734 0.8791716 0.8792694 0.8793669 0.8794641 [162] 0.8795610 0.8796576 0.8797538 0.8798498 0.8799454 0.8800407 0.8801358 [169] 0.8802305 0.8803249 0.8804189 0.8805127 0.8806062 0.8806994 0.8807922 [176] 0.8808847 0.8809770 0.8810689 0.8811605 0.8812518 0.8813428 0.8814335 [183] 0.8815239 0.8816140 0.8817037 0.8817932 0.8818824 0.8819712 0.8820598 [190] 0.8821480 0.8822359 0.8823236 0.8824109 0.8824979 0.8825846 0.8826710 [197] 0.8827572 0.8828430 0.8829285 0.8830137 0.8830985 0.8831831 0.8832674 [204] 0.8833514 0.8834351 0.8835185 0.8836016 0.8836843 0.8837668 0.8838490 [211] 0.8839309 0.8840125 0.8840937 0.8841747 0.8842554 0.8843358 0.8844159 [218] 0.8844956 0.8845751 0.8846543 0.8847332 0.8848118 0.8848901 0.8849681 [225] 0.8850458 0.8851232 0.8852003 0.8852771 0.8853536 0.8854298 0.8855057 [232] 0.8855814 0.8856567 0.8857317 0.8858065 0.8858809 0.8859551 0.8860289 [239] 0.8861025 0.8861758 0.8862488 0.8863214 0.8863938 0.8864660 0.8865378 [246] 0.8866093 0.8866805 0.8867515 0.8868221 0.8868925 0.8869625 0.8870323 [253] 0.8871018 0.8871710 0.8872399 0.8873086 0.8873769 0.8874449 0.8875127 [260] 0.8875802 0.8876474 0.8877143 0.8877809 0.8878472 0.8879132 0.8879790 [267] 0.8880445 0.8881097 0.8881746 0.8882392 0.8883035 0.8883675 0.8884313 [274] 0.8884948 0.8885580 0.8886209 0.8886835 0.8887459 0.8888079 0.8888697 [281] 0.8889312 0.8889924 0.8890534 0.8891140 0.8891744 0.8892345 0.8892943 [288] 0.8893539 0.8894131 0.8894721 0.8895308 0.8895892 0.8896474 0.8897052 [295] 0.8897628 0.8898201 0.8898772 0.8899339 0.8899904 0.8900466 0.8901026 [302] 0.8901582 0.8902136 0.8902687 0.8903235 0.8903781 0.8904324 0.8904864 [309] 0.8905401 0.8905936 0.8906468 0.8906997 0.8907523 0.8908047 0.8908568 [316] 0.8909087 0.8909602 0.8910115 0.8910625 0.8911133 0.8911638 0.8912140 [323] 0.8912639 0.8913136 0.8913630 0.8914121 0.8914610 0.8915096 0.8915579 [330] 0.8916060 0.8916538 0.8917013 0.8917486 0.8917956 0.8918423 0.8918888 [337] 0.8919350 0.8919809 0.8920266 0.8920720 0.8921172 0.8921621 0.8922067 [344] 0.8922510 0.8922951 0.8923390 0.8923825 0.8924259 0.8924689 0.8925117 [351] 0.8925542 0.8925965 0.8926385 0.8926803 0.8927217 0.8927630 0.8928039 [358] 0.8928447 0.8928851 0.8929253 0.8929652 0.8930049 0.8930443 0.8930835 [365] 0.8931224 0.8931611 0.8931995 0.8932376 0.8932755 0.8933131 0.8933505 [372] 0.8933877 0.8934245 0.8934611 0.8934975 0.8935336 0.8935695 0.8936051 [379] 0.8936404 0.8936755 0.8937104 0.8937450 0.8937793 0.8938134 0.8938473 [386] 0.8938809 0.8939142 0.8939473 0.8939802 0.8940128 0.8940452 0.8940773 [393] 0.8941091 0.8941407 0.8941721 0.8942032 0.8942341 0.8942647 0.8942951 [400] 0.8943252 0.8943551 > mx [1] 0.8943551 > 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/rcomp/tmp/1i9hf1257758411.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/2h4pc1257758411.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/3k4rl1257758411.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/4jp4m1257758411.tab") > > system("convert tmp/1i9hf1257758411.ps tmp/1i9hf1257758411.png") > system("convert tmp/2h4pc1257758411.ps tmp/2h4pc1257758411.png") > system("convert tmp/3k4rl1257758411.ps tmp/3k4rl1257758411.png") > > > proc.time() user system elapsed 0.990 0.720 1.545