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(107.37,107.37,107.37,107.37,107.37,107.37,108.96,108.96,108.96,108.96,108.96,108.96,113.23,113.23,113.23,113.23,113.23,113.23,114.28,114.28,114.28,114.28,114.28,114.28,116.2,116.2,116.2,116.2,116.2,116.2,120.92,120.92,120.92,120.92,120.92,120.92,121.44,122.78,122.78,122.78,122.78,122.78,120.84,120.84,120.84,120.84) > x <- c(105.86,105.86,105.86,105.86,105.86,105.86,108.42,108.42,108.42,108.42,108.42,108.42,108.42,108.42,108.42,108.42,108.84,108.84,108.84,108.84,108.84,108.84,110.51,110.51,110.51,110.51,110.51,110.51,110.51,110.51,110.51,110.51,110.51,110.51,110.51,110.51,112.43,112.43,112.43,112.43,112.43,113.68,113.68,113.68,113.68,113.68) > #'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.9042615 0.9042576 0.9042537 0.9042497 0.9042458 0.9042418 0.9042378 [8] 0.9042338 0.9042297 0.9042257 0.9042216 0.9042175 0.9042134 0.9042093 [15] 0.9042052 0.9042010 0.9041969 0.9041927 0.9041885 0.9041843 0.9041800 [22] 0.9041758 0.9041715 0.9041672 0.9041629 0.9041586 0.9041543 0.9041499 [29] 0.9041456 0.9041412 0.9041368 0.9041324 0.9041279 0.9041235 0.9041190 [36] 0.9041145 0.9041100 0.9041055 0.9041010 0.9040964 0.9040919 0.9040873 [43] 0.9040827 0.9040781 0.9040734 0.9040688 0.9040641 0.9040594 0.9040547 [50] 0.9040500 0.9040453 0.9040405 0.9040358 0.9040310 0.9040262 0.9040214 [57] 0.9040165 0.9040117 0.9040068 0.9040019 0.9039970 0.9039921 0.9039872 [64] 0.9039822 0.9039773 0.9039723 0.9039673 0.9039623 0.9039572 0.9039522 [71] 0.9039471 0.9039420 0.9039369 0.9039318 0.9039267 0.9039215 0.9039164 [78] 0.9039112 0.9039060 0.9039008 0.9038955 0.9038903 0.9038850 0.9038797 [85] 0.9038744 0.9038691 0.9038638 0.9038584 0.9038531 0.9038477 0.9038423 [92] 0.9038369 0.9038314 0.9038260 0.9038205 0.9038150 0.9038095 0.9038040 [99] 0.9037985 0.9037930 0.9037874 0.9037818 0.9037762 0.9037706 0.9037650 [106] 0.9037593 0.9037536 0.9037480 0.9037423 0.9037366 0.9037308 0.9037251 [113] 0.9037193 0.9037135 0.9037077 0.9037019 0.9036961 0.9036902 0.9036844 [120] 0.9036785 0.9036726 0.9036667 0.9036608 0.9036548 0.9036488 0.9036429 [127] 0.9036369 0.9036309 0.9036248 0.9036188 0.9036127 0.9036066 0.9036005 [134] 0.9035944 0.9035883 0.9035821 0.9035760 0.9035698 0.9035636 0.9035574 [141] 0.9035512 0.9035449 0.9035387 0.9035324 0.9035261 0.9035198 0.9035134 [148] 0.9035071 0.9035007 0.9034944 0.9034880 0.9034816 0.9034751 0.9034687 [155] 0.9034622 0.9034557 0.9034493 0.9034427 0.9034362 0.9034297 0.9034231 [162] 0.9034165 0.9034099 0.9034033 0.9033967 0.9033901 0.9033834 0.9033767 [169] 0.9033700 0.9033633 0.9033566 0.9033499 0.9033431 0.9033363 0.9033295 [176] 0.9033227 0.9033159 0.9033091 0.9033022 0.9032953 0.9032884 0.9032815 [183] 0.9032746 0.9032677 0.9032607 0.9032537 0.9032467 0.9032397 0.9032327 [190] 0.9032257 0.9032186 0.9032115 0.9032044 0.9031973 0.9031902 0.9031831 [197] 0.9031759 0.9031687 0.9031616 0.9031544 0.9031471 0.9031399 0.9031326 [204] 0.9031254 0.9031181 0.9031108 0.9031035 0.9030961 0.9030888 0.9030814 [211] 0.9030740 0.9030666 0.9030592 0.9030517 0.9030443 0.9030368 0.9030293 [218] 0.9030218 0.9030143 0.9030068 0.9029992 0.9029917 0.9029841 0.9029765 [225] 0.9029689 0.9029612 0.9029536 0.9029459 0.9029382 0.9029305 0.9029228 [232] 0.9029151 0.9029073 0.9028996 0.9028918 0.9028840 0.9028762 0.9028683 [239] 0.9028605 0.9028526 0.9028447 0.9028368 0.9028289 0.9028210 0.9028131 [246] 0.9028051 0.9027971 0.9027891 0.9027811 0.9027731 0.9027650 0.9027570 [253] 0.9027489 0.9027408 0.9027327 0.9027245 0.9027164 0.9027082 0.9027001 [260] 0.9026919 0.9026837 0.9026754 0.9026672 0.9026589 0.9026507 0.9026424 [267] 0.9026341 0.9026257 0.9026174 0.9026090 0.9026007 0.9025923 0.9025839 [274] 0.9025754 0.9025670 0.9025585 0.9025501 0.9025416 0.9025331 0.9025246 [281] 0.9025160 0.9025075 0.9024989 0.9024903 0.9024817 0.9024731 0.9024644 [288] 0.9024558 0.9024471 0.9024384 0.9024297 0.9024210 0.9024123 0.9024035 [295] 0.9023948 0.9023860 0.9023772 0.9023684 0.9023595 0.9023507 0.9023418 [302] 0.9023329 0.9023240 0.9023151 0.9023062 0.9022972 0.9022883 0.9022793 [309] 0.9022703 0.9022613 0.9022522 0.9022432 0.9022341 0.9022251 0.9022160 [316] 0.9022068 0.9021977 0.9021886 0.9021794 0.9021702 0.9021610 0.9021518 [323] 0.9021426 0.9021334 0.9021241 0.9021148 0.9021055 0.9020962 0.9020869 [330] 0.9020776 0.9020682 0.9020588 0.9020495 0.9020400 0.9020306 0.9020212 [337] 0.9020117 0.9020023 0.9019928 0.9019833 0.9019738 0.9019642 0.9019547 [344] 0.9019451 0.9019355 0.9019259 0.9019163 0.9019067 0.9018970 0.9018873 [351] 0.9018777 0.9018680 0.9018582 0.9018485 0.9018388 0.9018290 0.9018192 [358] 0.9018094 0.9017996 0.9017898 0.9017799 0.9017701 0.9017602 0.9017503 [365] 0.9017404 0.9017305 0.9017205 0.9017106 0.9017006 0.9016906 0.9016806 [372] 0.9016706 0.9016605 0.9016505 0.9016404 0.9016303 0.9016202 0.9016101 [379] 0.9015999 0.9015898 0.9015796 0.9015694 0.9015592 0.9015490 0.9015388 [386] 0.9015285 0.9015182 0.9015080 0.9014977 0.9014873 0.9014770 0.9014667 [393] 0.9014563 0.9014459 0.9014355 0.9014251 0.9014147 0.9014042 0.9013938 [400] 0.9013833 0.9013728 > mx [1] 0.9042615 > 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/1doms1257758902.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/2mxhf1257758902.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/30ip91257758902.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/4o9yd1257758902.tab") > > system("convert tmp/1doms1257758902.ps tmp/1doms1257758902.png") > system("convert tmp/2mxhf1257758902.ps tmp/2mxhf1257758902.png") > system("convert tmp/30ip91257758902.ps tmp/30ip91257758902.png") > > > proc.time() user system elapsed 0.850 0.770 1.508