R version 2.7.2 (2008-08-25) 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(104.0,107.9,113.8,113.8,123.1,125.1,137.6,134.0,140.3,152.1,150.6,167.3,153.2,142.0,154.4,158.5,180.9,181.3,172.4,192.0,199.3,215.4,214.3,201.5,190.5,196.0,215.7,209.4,214.1,237.8,239.0,237.8,251.5,248.8,215.4,201.2,203.1,214.2,188.9,203.0,213.3,228.5,228.2,240.9,258.8,248.5,269.2,289.6,323.4,317.2,322.8,340.9,368.2,388.5,441.2,474.3,483.9,417.9,365.9,263.0) > x <- c(118.4,121.4,128.8,131.7,141.7,142.9,139.4,134.7,125.0,113.6,111.5,108.5,112.3,116.6,115.5,120.1,132.9,128.1,129.3,132.5,131.0,124.9,120.8,122.0,122.1,127.4,135.2,137.3,135.0,136.0,138.4,134.7,138.4,133.9,133.6,141.2,151.8,155.4,156.6,161.6,160.7,156.0,159.5,168.7,169.9,169.9,185.9,190.8,195.8,211.9,227.1,251.3,256.7,251.9,251.2,270.3,267.2,243.0,229.9,187.2) > #'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.8374430 0.8378501 0.8382564 0.8386621 0.8390671 0.8394713 0.8398749 [8] 0.8402778 0.8406799 0.8410813 0.8414820 0.8418820 0.8422813 0.8426798 [15] 0.8430776 0.8434746 0.8438709 0.8442665 0.8446613 0.8450553 0.8454486 [22] 0.8458411 0.8462328 0.8466238 0.8470140 0.8474034 0.8477921 0.8481799 [29] 0.8485670 0.8489532 0.8493387 0.8497234 0.8501072 0.8504903 0.8508725 [36] 0.8512540 0.8516346 0.8520143 0.8523933 0.8527714 0.8531487 0.8535251 [43] 0.8539007 0.8542755 0.8546494 0.8550224 0.8553946 0.8557660 0.8561364 [50] 0.8565060 0.8568748 0.8572426 0.8576096 0.8579757 0.8583409 0.8587052 [57] 0.8590686 0.8594311 0.8597928 0.8601535 0.8605133 0.8608722 0.8612302 [64] 0.8615873 0.8619434 0.8622987 0.8626530 0.8630063 0.8633588 0.8637103 [71] 0.8640608 0.8644104 0.8647591 0.8651068 0.8654536 0.8657994 0.8661442 [78] 0.8664881 0.8668310 0.8671729 0.8675139 0.8678539 0.8681929 0.8685309 [85] 0.8688679 0.8692040 0.8695390 0.8698731 0.8702061 0.8705382 0.8708693 [92] 0.8711993 0.8715283 0.8718563 0.8721833 0.8725093 0.8728343 0.8731582 [99] 0.8734811 0.8738030 0.8741238 0.8744436 0.8747624 0.8750801 0.8753968 [106] 0.8757124 0.8760270 0.8763405 0.8766529 0.8769643 0.8772747 0.8775839 [113] 0.8778921 0.8781993 0.8785053 0.8788103 0.8791142 0.8794171 0.8797188 [120] 0.8800195 0.8803190 0.8806175 0.8809149 0.8812112 0.8815064 0.8818005 [127] 0.8820935 0.8823854 0.8826761 0.8829658 0.8832544 0.8835418 0.8838281 [134] 0.8841134 0.8843974 0.8846804 0.8849622 0.8852430 0.8855225 0.8858010 [141] 0.8860783 0.8863545 0.8866296 0.8869035 0.8871762 0.8874479 0.8877183 [148] 0.8879877 0.8882559 0.8885229 0.8887888 0.8890535 0.8893171 0.8895795 [155] 0.8898407 0.8901008 0.8903598 0.8906175 0.8908741 0.8911296 0.8913838 [162] 0.8916369 0.8918888 0.8921396 0.8923891 0.8926375 0.8928848 0.8931308 [169] 0.8933757 0.8936193 0.8938618 0.8941031 0.8943432 0.8945822 0.8948199 [176] 0.8950565 0.8952918 0.8955260 0.8957590 0.8959908 0.8962213 0.8964507 [183] 0.8966789 0.8969059 0.8971317 0.8973563 0.8975797 0.8978019 0.8980229 [190] 0.8982427 0.8984612 0.8986786 0.8988948 0.8991097 0.8993235 0.8995360 [197] 0.8997474 0.8999575 0.9001664 0.9003741 0.9005806 0.9007859 0.9009900 [204] 0.9011928 0.9013945 0.9015949 0.9017941 0.9019921 0.9021889 0.9023845 [211] 0.9025788 0.9027720 0.9029639 0.9031546 0.9033441 0.9035324 0.9037194 [218] 0.9039053 0.9040899 0.9042733 0.9044555 0.9046364 0.9048162 0.9049947 [225] 0.9051721 0.9053482 0.9055231 0.9056967 0.9058692 0.9060404 0.9062105 [232] 0.9063793 0.9065469 0.9067132 0.9068784 0.9070423 0.9072051 0.9073666 [239] 0.9075269 0.9076860 0.9078439 0.9080006 0.9081560 0.9083103 0.9084633 [246] 0.9086152 0.9087658 0.9089152 0.9090634 0.9092104 0.9093562 0.9095008 [253] 0.9096442 0.9097864 0.9099273 0.9100671 0.9102057 0.9103431 0.9104793 [260] 0.9106142 0.9107480 0.9108806 0.9110120 0.9111422 0.9112712 0.9113990 [267] 0.9115256 0.9116511 0.9117753 0.9118983 0.9120202 0.9121409 0.9122604 [274] 0.9123787 0.9124958 0.9126118 0.9127266 0.9128402 0.9129526 0.9130639 [281] 0.9131739 0.9132828 0.9133906 0.9134971 0.9136025 0.9137068 0.9138098 [288] 0.9139118 0.9140125 0.9141121 0.9142105 0.9143078 0.9144039 0.9144989 [295] 0.9145927 0.9146854 0.9147769 0.9148673 0.9149565 0.9150446 0.9151316 [302] 0.9152174 0.9153020 0.9153856 0.9154680 0.9155493 0.9156294 0.9157085 [309] 0.9157864 0.9158631 0.9159388 0.9160133 0.9160868 0.9161591 0.9162303 [316] 0.9163004 0.9163693 0.9164372 0.9165040 0.9165697 0.9166342 0.9166977 [323] 0.9167601 0.9168214 0.9168816 0.9169407 0.9169987 0.9170557 0.9171115 [330] 0.9171663 0.9172200 0.9172727 0.9173242 0.9173747 0.9174241 0.9174725 [337] 0.9175198 0.9175661 0.9176113 0.9176554 0.9176985 0.9177405 0.9177815 [344] 0.9178214 0.9178604 0.9178982 0.9179351 0.9179708 0.9180056 0.9180394 [351] 0.9180721 0.9181038 0.9181344 0.9181641 0.9181927 0.9182204 0.9182470 [358] 0.9182726 0.9182972 0.9183208 0.9183434 0.9183650 0.9183857 0.9184053 [365] 0.9184239 0.9184416 0.9184583 0.9184740 0.9184887 0.9185025 0.9185153 [372] 0.9185271 0.9185380 0.9185479 0.9185568 0.9185648 0.9185718 0.9185779 [379] 0.9185830 0.9185872 0.9185905 0.9185928 0.9185942 0.9185946 0.9185942 [386] 0.9185928 0.9185904 0.9185872 0.9185830 0.9185780 0.9185720 0.9185651 [393] 0.9185573 0.9185486 0.9185390 0.9185285 0.9185172 0.9185049 0.9184918 [400] 0.9184777 0.9184628 > mx [1] 0.9185946 > mxli [1] 1.83 > 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/1yg0v1226568933.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/21qem1226568933.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/3vqy41226568933.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/4aln71226568933.tab") > > system("convert tmp/1yg0v1226568933.ps tmp/1yg0v1226568933.png") > system("convert tmp/21qem1226568933.ps tmp/21qem1226568933.png") > system("convert tmp/3vqy41226568933.ps tmp/3vqy41226568933.png") > > > proc.time() user system elapsed 1.004 0.533 1.200