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(10068,10101,10131,10143,10170,10192,10214,10239,10263,10310,10355,10396,10446,10511,10585,10667) > x <- c(4923,4940,4956,4959,4972,4983,4994,5007,5018,5042,5068,5087,5112,5144,5182,5224) > #'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.9997579 0.9997593 0.9997607 0.9997622 0.9997636 0.9997650 0.9997664 [8] 0.9997678 0.9997692 0.9997706 0.9997719 0.9997733 0.9997747 0.9997760 [15] 0.9997774 0.9997787 0.9997801 0.9997814 0.9997827 0.9997841 0.9997854 [22] 0.9997867 0.9997880 0.9997893 0.9997906 0.9997918 0.9997931 0.9997944 [29] 0.9997956 0.9997969 0.9997981 0.9997994 0.9998006 0.9998018 0.9998031 [36] 0.9998043 0.9998055 0.9998067 0.9998079 0.9998091 0.9998102 0.9998114 [43] 0.9998126 0.9998138 0.9998149 0.9998161 0.9998172 0.9998183 0.9998195 [50] 0.9998206 0.9998217 0.9998228 0.9998239 0.9998250 0.9998261 0.9998272 [57] 0.9998283 0.9998293 0.9998304 0.9998315 0.9998325 0.9998335 0.9998346 [64] 0.9998356 0.9998366 0.9998377 0.9998387 0.9998397 0.9998407 0.9998417 [71] 0.9998426 0.9998436 0.9998446 0.9998456 0.9998465 0.9998475 0.9998484 [78] 0.9998494 0.9998503 0.9998512 0.9998521 0.9998530 0.9998539 0.9998548 [85] 0.9998557 0.9998566 0.9998575 0.9998584 0.9998592 0.9998601 0.9998610 [92] 0.9998618 0.9998626 0.9998635 0.9998643 0.9998651 0.9998659 0.9998667 [99] 0.9998675 0.9998683 0.9998691 0.9998699 0.9998707 0.9998714 0.9998722 [106] 0.9998730 0.9998737 0.9998744 0.9998752 0.9998759 0.9998766 0.9998773 [113] 0.9998781 0.9998788 0.9998795 0.9998801 0.9998808 0.9998815 0.9998822 [120] 0.9998828 0.9998835 0.9998841 0.9998848 0.9998854 0.9998860 0.9998867 [127] 0.9998873 0.9998879 0.9998885 0.9998891 0.9998897 0.9998903 0.9998908 [134] 0.9998914 0.9998920 0.9998925 0.9998931 0.9998936 0.9998941 0.9998947 [141] 0.9998952 0.9998957 0.9998962 0.9998967 0.9998972 0.9998977 0.9998982 [148] 0.9998987 0.9998992 0.9998996 0.9999001 0.9999005 0.9999010 0.9999014 [155] 0.9999018 0.9999023 0.9999027 0.9999031 0.9999035 0.9999039 0.9999043 [162] 0.9999047 0.9999050 0.9999054 0.9999058 0.9999061 0.9999065 0.9999068 [169] 0.9999072 0.9999075 0.9999078 0.9999082 0.9999085 0.9999088 0.9999091 [176] 0.9999094 0.9999096 0.9999099 0.9999102 0.9999105 0.9999107 0.9999110 [183] 0.9999112 0.9999115 0.9999117 0.9999119 0.9999121 0.9999124 0.9999126 [190] 0.9999128 0.9999129 0.9999131 0.9999133 0.9999135 0.9999137 0.9999138 [197] 0.9999140 0.9999141 0.9999143 0.9999144 0.9999145 0.9999146 0.9999147 [204] 0.9999149 0.9999150 0.9999150 0.9999151 0.9999152 0.9999153 0.9999154 [211] 0.9999154 0.9999155 0.9999155 0.9999156 0.9999156 0.9999156 0.9999156 [218] 0.9999157 0.9999157 0.9999157 0.9999157 0.9999156 0.9999156 0.9999156 [225] 0.9999156 0.9999155 0.9999155 0.9999154 0.9999154 0.9999153 0.9999152 [232] 0.9999152 0.9999151 0.9999150 0.9999149 0.9999148 0.9999147 0.9999145 [239] 0.9999144 0.9999143 0.9999142 0.9999140 0.9999139 0.9999137 0.9999135 [246] 0.9999134 0.9999132 0.9999130 0.9999128 0.9999126 0.9999124 0.9999122 [253] 0.9999120 0.9999118 0.9999115 0.9999113 0.9999110 0.9999108 0.9999105 [260] 0.9999103 0.9999100 0.9999097 0.9999094 0.9999091 0.9999088 0.9999085 [267] 0.9999082 0.9999079 0.9999076 0.9999073 0.9999069 0.9999066 0.9999062 [274] 0.9999059 0.9999055 0.9999051 0.9999048 0.9999044 0.9999040 0.9999036 [281] 0.9999032 0.9999028 0.9999024 0.9999019 0.9999015 0.9999011 0.9999006 [288] 0.9999002 0.9998997 0.9998993 0.9998988 0.9998983 0.9998978 0.9998973 [295] 0.9998968 0.9998963 0.9998958 0.9998953 0.9998948 0.9998943 0.9998937 [302] 0.9998932 0.9998926 0.9998921 0.9998915 0.9998909 0.9998904 0.9998898 [309] 0.9998892 0.9998886 0.9998880 0.9998874 0.9998868 0.9998861 0.9998855 [316] 0.9998849 0.9998842 0.9998836 0.9998829 0.9998823 0.9998816 0.9998809 [323] 0.9998802 0.9998795 0.9998788 0.9998781 0.9998774 0.9998767 0.9998760 [330] 0.9998753 0.9998745 0.9998738 0.9998730 0.9998723 0.9998715 0.9998707 [337] 0.9998700 0.9998692 0.9998684 0.9998676 0.9998668 0.9998660 0.9998652 [344] 0.9998643 0.9998635 0.9998627 0.9998618 0.9998610 0.9998601 0.9998593 [351] 0.9998584 0.9998575 0.9998566 0.9998558 0.9998549 0.9998540 0.9998530 [358] 0.9998521 0.9998512 0.9998503 0.9998493 0.9998484 0.9998475 0.9998465 [365] 0.9998455 0.9998446 0.9998436 0.9998426 0.9998416 0.9998406 0.9998396 [372] 0.9998386 0.9998376 0.9998366 0.9998355 0.9998345 0.9998335 0.9998324 [379] 0.9998314 0.9998303 0.9998292 0.9998282 0.9998271 0.9998260 0.9998249 [386] 0.9998238 0.9998227 0.9998216 0.9998204 0.9998193 0.9998182 0.9998170 [393] 0.9998159 0.9998147 0.9998136 0.9998124 0.9998112 0.9998100 0.9998088 [400] 0.9998077 0.9998064 > mx [1] 0.9999157 > mxli [1] 0.19 > 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/115a21226416507.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/2sq111226416507.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/359u21226416507.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/4tr9n1226416507.tab") > > system("convert tmp/115a21226416507.ps tmp/115a21226416507.png") > system("convert tmp/2sq111226416507.ps tmp/2sq111226416507.png") > system("convert tmp/359u21226416507.ps tmp/359u21226416507.png") > > > proc.time() user system elapsed 1.089 0.548 2.003