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(102.1,102.86,102.99,103.73,105.02,104.43,104.63,104.93,105.87,105.66,106.76,106,107.22,107.33,107.11,108.86,107.72,107.88,108.38,107.72,108.41,109.9,111.45,112.18,113.34,113.46,114.06,115.54,116.39,115.94,116.97,115.94,115.91,116.43,116.26,116.35,117.9,117.7,117.53,117.86,117.65,116.51,115.93,115.31,115) > x <- c(100.35,100.35,100.36,100.39,100.34,100.34,100.35,100.43,100.47,100.67,100.75,100.78,100.79,100.67,100.64,100.64,100.76,100.79,100.79,100.9,100.98,101.11,101.18,101.22,101.23,101.09,101.26,101.28,101.43,101.53,101.54,101.54,101.79,102.18,102.37,102.46,102.46,102.03,102.26,102.33,102.44,102.5,102.52,102.66,102.72) > #'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.9056461 0.9056360 0.9056258 0.9056157 0.9056055 0.9055953 0.9055852 [8] 0.9055750 0.9055649 0.9055547 0.9055446 0.9055344 0.9055242 0.9055141 [15] 0.9055039 0.9054937 0.9054836 0.9054734 0.9054632 0.9054531 0.9054429 [22] 0.9054327 0.9054226 0.9054124 0.9054022 0.9053920 0.9053819 0.9053717 [29] 0.9053615 0.9053513 0.9053412 0.9053310 0.9053208 0.9053106 0.9053004 [36] 0.9052903 0.9052801 0.9052699 0.9052597 0.9052495 0.9052393 0.9052292 [43] 0.9052190 0.9052088 0.9051986 0.9051884 0.9051782 0.9051680 0.9051578 [50] 0.9051476 0.9051374 0.9051272 0.9051170 0.9051068 0.9050966 0.9050864 [57] 0.9050762 0.9050660 0.9050558 0.9050456 0.9050354 0.9050252 0.9050150 [64] 0.9050048 0.9049946 0.9049844 0.9049742 0.9049640 0.9049538 0.9049436 [71] 0.9049334 0.9049231 0.9049129 0.9049027 0.9048925 0.9048823 0.9048721 [78] 0.9048619 0.9048516 0.9048414 0.9048312 0.9048210 0.9048107 0.9048005 [85] 0.9047903 0.9047801 0.9047699 0.9047596 0.9047494 0.9047392 0.9047289 [92] 0.9047187 0.9047085 0.9046982 0.9046880 0.9046778 0.9046676 0.9046573 [99] 0.9046471 0.9046368 0.9046266 0.9046164 0.9046061 0.9045959 0.9045856 [106] 0.9045754 0.9045652 0.9045549 0.9045447 0.9045344 0.9045242 0.9045139 [113] 0.9045037 0.9044934 0.9044832 0.9044729 0.9044627 0.9044524 0.9044422 [120] 0.9044319 0.9044217 0.9044114 0.9044012 0.9043909 0.9043807 0.9043704 [127] 0.9043601 0.9043499 0.9043396 0.9043294 0.9043191 0.9043088 0.9042986 [134] 0.9042883 0.9042780 0.9042678 0.9042575 0.9042472 0.9042370 0.9042267 [141] 0.9042164 0.9042061 0.9041959 0.9041856 0.9041753 0.9041650 0.9041548 [148] 0.9041445 0.9041342 0.9041239 0.9041137 0.9041034 0.9040931 0.9040828 [155] 0.9040725 0.9040622 0.9040520 0.9040417 0.9040314 0.9040211 0.9040108 [162] 0.9040005 0.9039902 0.9039799 0.9039696 0.9039594 0.9039491 0.9039388 [169] 0.9039285 0.9039182 0.9039079 0.9038976 0.9038873 0.9038770 0.9038667 [176] 0.9038564 0.9038461 0.9038358 0.9038255 0.9038152 0.9038049 0.9037946 [183] 0.9037842 0.9037739 0.9037636 0.9037533 0.9037430 0.9037327 0.9037224 [190] 0.9037121 0.9037018 0.9036914 0.9036811 0.9036708 0.9036605 0.9036502 [197] 0.9036399 0.9036295 0.9036192 0.9036089 0.9035986 0.9035883 0.9035779 [204] 0.9035676 0.9035573 0.9035470 0.9035366 0.9035263 0.9035160 0.9035056 [211] 0.9034953 0.9034850 0.9034746 0.9034643 0.9034540 0.9034436 0.9034333 [218] 0.9034230 0.9034126 0.9034023 0.9033920 0.9033816 0.9033713 0.9033609 [225] 0.9033506 0.9033403 0.9033299 0.9033196 0.9033092 0.9032989 0.9032885 [232] 0.9032782 0.9032678 0.9032575 0.9032471 0.9032368 0.9032264 0.9032161 [239] 0.9032057 0.9031954 0.9031850 0.9031746 0.9031643 0.9031539 0.9031436 [246] 0.9031332 0.9031228 0.9031125 0.9031021 0.9030918 0.9030814 0.9030710 [253] 0.9030607 0.9030503 0.9030399 0.9030296 0.9030192 0.9030088 0.9029985 [260] 0.9029881 0.9029777 0.9029673 0.9029570 0.9029466 0.9029362 0.9029258 [267] 0.9029155 0.9029051 0.9028947 0.9028843 0.9028739 0.9028636 0.9028532 [274] 0.9028428 0.9028324 0.9028220 0.9028116 0.9028012 0.9027909 0.9027805 [281] 0.9027701 0.9027597 0.9027493 0.9027389 0.9027285 0.9027181 0.9027077 [288] 0.9026973 0.9026869 0.9026765 0.9026661 0.9026557 0.9026453 0.9026349 [295] 0.9026245 0.9026141 0.9026037 0.9025933 0.9025829 0.9025725 0.9025621 [302] 0.9025517 0.9025413 0.9025309 0.9025205 0.9025101 0.9024997 0.9024893 [309] 0.9024788 0.9024684 0.9024580 0.9024476 0.9024372 0.9024268 0.9024163 [316] 0.9024059 0.9023955 0.9023851 0.9023747 0.9023642 0.9023538 0.9023434 [323] 0.9023330 0.9023225 0.9023121 0.9023017 0.9022913 0.9022808 0.9022704 [330] 0.9022600 0.9022495 0.9022391 0.9022287 0.9022182 0.9022078 0.9021974 [337] 0.9021869 0.9021765 0.9021661 0.9021556 0.9021452 0.9021348 0.9021243 [344] 0.9021139 0.9021034 0.9020930 0.9020825 0.9020721 0.9020616 0.9020512 [351] 0.9020408 0.9020303 0.9020199 0.9020094 0.9019990 0.9019885 0.9019780 [358] 0.9019676 0.9019571 0.9019467 0.9019362 0.9019258 0.9019153 0.9019049 [365] 0.9018944 0.9018839 0.9018735 0.9018630 0.9018526 0.9018421 0.9018316 [372] 0.9018212 0.9018107 0.9018002 0.9017898 0.9017793 0.9017688 0.9017584 [379] 0.9017479 0.9017374 0.9017269 0.9017165 0.9017060 0.9016955 0.9016850 [386] 0.9016746 0.9016641 0.9016536 0.9016431 0.9016326 0.9016222 0.9016117 [393] 0.9016012 0.9015907 0.9015802 0.9015697 0.9015593 0.9015488 0.9015383 [400] 0.9015278 0.9015173 > mx [1] 0.9056461 > 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/1lg911257428600.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/25ri91257428600.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/32dhh1257428600.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/4pkoi1257428600.tab") > > system("convert tmp/1lg911257428600.ps tmp/1lg911257428600.png") > system("convert tmp/25ri91257428600.ps tmp/25ri91257428600.png") > system("convert tmp/32dhh1257428600.ps tmp/32dhh1257428600.png") > > > proc.time() user system elapsed 0.753 0.481 1.125