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(153.4,145,137.7,148.3,152.2,169.4,168.6,161.1,174.1,179,190.6,190,181.6,174.8,180.5,196.8,193.8,197,216.3,221.4,217.9,229.7,227.4,204.2,196.6,198.8,207.5,190.7,201.6,210.5,223.5,223.8,231.2,244,234.7,250.2,265.7,287.6,283.3,295.4,312.3,333.8,347.7,383.2,407.1,413.6,362.7,321.9,239.4,191,159.7,163.4,157.6,166.2,176.7,198.3,226.2,216.2,235.9,226.9) > x <- c(98.84,99.505,100.17,100.83,101.51,102.16,102.39,102.54,102.85,103.47,103.57,103.69,103.5,103.47,103.45,103.48,103.93,103.89,104.4,104.79,104.77,105.13,105.26,104.96,104.75,105.01,105.15,105.2,105.77,105.78,106.26,106.13,106.12,106.57,106.44,106.54,107.1,108.1,108.4,108.84,109.62,110.42,110.67,111.66,112.28,112.87,112.18,112.36,112.16,111.49,111.25,111.36,111.74,111.1,111.33,111.25,111.04,110.97,111.31,111.02) > #'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.6084021 0.6083970 0.6083919 0.6083868 0.6083816 0.6083764 0.6083713 [8] 0.6083660 0.6083608 0.6083556 0.6083503 0.6083451 0.6083398 0.6083345 [15] 0.6083291 0.6083238 0.6083184 0.6083130 0.6083076 0.6083022 0.6082968 [22] 0.6082913 0.6082859 0.6082804 0.6082749 0.6082694 0.6082638 0.6082583 [29] 0.6082527 0.6082471 0.6082415 0.6082359 0.6082302 0.6082246 0.6082189 [36] 0.6082132 0.6082075 0.6082018 0.6081960 0.6081903 0.6081845 0.6081787 [43] 0.6081729 0.6081670 0.6081612 0.6081553 0.6081494 0.6081435 0.6081376 [50] 0.6081317 0.6081257 0.6081198 0.6081138 0.6081078 0.6081017 0.6080957 [57] 0.6080897 0.6080836 0.6080775 0.6080714 0.6080653 0.6080591 0.6080530 [64] 0.6080468 0.6080406 0.6080344 0.6080282 0.6080219 0.6080157 0.6080094 [71] 0.6080031 0.6079968 0.6079905 0.6079841 0.6079778 0.6079714 0.6079650 [78] 0.6079586 0.6079522 0.6079457 0.6079393 0.6079328 0.6079263 0.6079198 [85] 0.6079133 0.6079067 0.6079002 0.6078936 0.6078870 0.6078804 0.6078738 [92] 0.6078671 0.6078605 0.6078538 0.6078471 0.6078404 0.6078337 0.6078270 [99] 0.6078202 0.6078134 0.6078066 0.6077998 0.6077930 0.6077862 0.6077793 [106] 0.6077724 0.6077655 0.6077586 0.6077517 0.6077448 0.6077378 0.6077309 [113] 0.6077239 0.6077169 0.6077099 0.6077028 0.6076958 0.6076887 0.6076816 [120] 0.6076745 0.6076674 0.6076603 0.6076531 0.6076460 0.6076388 0.6076316 [127] 0.6076244 0.6076171 0.6076099 0.6076026 0.6075953 0.6075881 0.6075807 [134] 0.6075734 0.6075661 0.6075587 0.6075513 0.6075440 0.6075366 0.6075291 [141] 0.6075217 0.6075142 0.6075068 0.6074993 0.6074918 0.6074843 0.6074767 [148] 0.6074692 0.6074616 0.6074540 0.6074465 0.6074388 0.6074312 0.6074236 [155] 0.6074159 0.6074082 0.6074005 0.6073928 0.6073851 0.6073774 0.6073696 [162] 0.6073619 0.6073541 0.6073463 0.6073385 0.6073306 0.6073228 0.6073149 [169] 0.6073070 0.6072992 0.6072912 0.6072833 0.6072754 0.6072674 0.6072595 [176] 0.6072515 0.6072435 0.6072355 0.6072274 0.6072194 0.6072113 0.6072032 [183] 0.6071951 0.6071870 0.6071789 0.6071708 0.6071626 0.6071544 0.6071463 [190] 0.6071381 0.6071298 0.6071216 0.6071134 0.6071051 0.6070968 0.6070885 [197] 0.6070802 0.6070719 0.6070636 0.6070552 0.6070468 0.6070385 0.6070301 [204] 0.6070216 0.6070132 0.6070048 0.6069963 0.6069878 0.6069794 0.6069709 [211] 0.6069623 0.6069538 0.6069452 0.6069367 0.6069281 0.6069195 0.6069109 [218] 0.6069023 0.6068936 0.6068850 0.6068763 0.6068676 0.6068589 0.6068502 [225] 0.6068415 0.6068328 0.6068240 0.6068152 0.6068065 0.6067977 0.6067888 [232] 0.6067800 0.6067712 0.6067623 0.6067534 0.6067445 0.6067356 0.6067267 [239] 0.6067178 0.6067088 0.6066999 0.6066909 0.6066819 0.6066729 0.6066639 [246] 0.6066548 0.6066458 0.6066367 0.6066277 0.6066186 0.6066095 0.6066003 [253] 0.6065912 0.6065820 0.6065729 0.6065637 0.6065545 0.6065453 0.6065361 [260] 0.6065268 0.6065176 0.6065083 0.6064990 0.6064898 0.6064804 0.6064711 [267] 0.6064618 0.6064524 0.6064431 0.6064337 0.6064243 0.6064149 0.6064055 [274] 0.6063960 0.6063866 0.6063771 0.6063676 0.6063581 0.6063486 0.6063391 [281] 0.6063296 0.6063200 0.6063105 0.6063009 0.6062913 0.6062817 0.6062721 [288] 0.6062625 0.6062528 0.6062431 0.6062335 0.6062238 0.6062141 0.6062044 [295] 0.6061946 0.6061849 0.6061751 0.6061654 0.6061556 0.6061458 0.6061360 [302] 0.6061261 0.6061163 0.6061064 0.6060966 0.6060867 0.6060768 0.6060669 [309] 0.6060570 0.6060470 0.6060371 0.6060271 0.6060171 0.6060072 0.6059972 [316] 0.6059871 0.6059771 0.6059671 0.6059570 0.6059469 0.6059368 0.6059267 [323] 0.6059166 0.6059065 0.6058964 0.6058862 0.6058760 0.6058659 0.6058557 [330] 0.6058455 0.6058352 0.6058250 0.6058148 0.6058045 0.6057942 0.6057839 [337] 0.6057736 0.6057633 0.6057530 0.6057427 0.6057323 0.6057219 0.6057116 [344] 0.6057012 0.6056908 0.6056803 0.6056699 0.6056595 0.6056490 0.6056385 [351] 0.6056281 0.6056176 0.6056070 0.6055965 0.6055860 0.6055754 0.6055649 [358] 0.6055543 0.6055437 0.6055331 0.6055225 0.6055119 0.6055012 0.6054906 [365] 0.6054799 0.6054692 0.6054585 0.6054478 0.6054371 0.6054264 0.6054156 [372] 0.6054049 0.6053941 0.6053833 0.6053725 0.6053617 0.6053509 0.6053401 [379] 0.6053292 0.6053184 0.6053075 0.6052966 0.6052857 0.6052748 0.6052639 [386] 0.6052529 0.6052420 0.6052310 0.6052201 0.6052091 0.6051981 0.6051871 [393] 0.6051760 0.6051650 0.6051540 0.6051429 0.6051318 0.6051207 0.6051096 [400] 0.6050985 0.6050874 > mx [1] 0.6084021 > 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/1hbq41258123078.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/22oob1258123078.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/3agjt1258123078.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/48dj91258123078.tab") > > system("convert tmp/1hbq41258123078.ps tmp/1hbq41258123078.png") > system("convert tmp/22oob1258123078.ps tmp/22oob1258123078.png") > system("convert tmp/3agjt1258123078.ps tmp/3agjt1258123078.png") > > > proc.time() user system elapsed 0.781 0.509 0.933