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(11.1,10.9,10,9.2,9.2,9.5,9.6,9.5,9.1,8.9,9,10.1,10.3,10.2,9.6,9.2,9.3,9.4,9.4,9.2,9,9,9,9.8,10,9.8,9.3,9,9,9.1,9.1,9.1,9.2,8.8,8.3,8.4,8.1,7.7,7.9,7.9,8,7.9,7.6,7.1,6.8,6.5,6.9,8.2,8.7,8.3,7.9,7.5,7.8,8.3,8.4,8.2,7.7,7.2,7.3,8.1) > x <- c(8,8.1,7.7,7.5,7.6,7.8,7.8,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.2,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,7.9,7.7,7.4,7.5,8) > #'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.6304579 0.6304053 0.6303526 0.6302998 0.6302468 0.6301937 0.6301404 [8] 0.6300870 0.6300335 0.6299798 0.6299260 0.6298721 0.6298180 0.6297638 [15] 0.6297094 0.6296550 0.6296003 0.6295456 0.6294907 0.6294357 0.6293805 [22] 0.6293252 0.6292698 0.6292142 0.6291585 0.6291027 0.6290467 0.6289906 [29] 0.6289344 0.6288780 0.6288215 0.6287649 0.6287081 0.6286512 0.6285942 [36] 0.6285370 0.6284797 0.6284223 0.6283647 0.6283070 0.6282492 0.6281912 [43] 0.6281331 0.6280749 0.6280165 0.6279580 0.6278994 0.6278406 0.6277817 [50] 0.6277227 0.6276636 0.6276043 0.6275449 0.6274853 0.6274256 0.6273658 [57] 0.6273059 0.6272458 0.6271856 0.6271253 0.6270648 0.6270042 0.6269435 [64] 0.6268826 0.6268217 0.6267605 0.6266993 0.6266379 0.6265764 0.6265148 [71] 0.6264530 0.6263911 0.6263291 0.6262670 0.6262047 0.6261423 0.6260798 [78] 0.6260171 0.6259543 0.6258914 0.6258284 0.6257652 0.6257019 0.6256385 [85] 0.6255749 0.6255112 0.6254474 0.6253835 0.6253194 0.6252552 0.6251909 [92] 0.6251265 0.6250619 0.6249972 0.6249324 0.6248675 0.6248024 0.6247372 [99] 0.6246719 0.6246064 0.6245409 0.6244752 0.6244093 0.6243434 0.6242773 [106] 0.6242111 0.6241448 0.6240784 0.6240118 0.6239451 0.6238783 0.6238114 [113] 0.6237443 0.6236771 0.6236098 0.6235424 0.6234748 0.6234071 0.6233393 [120] 0.6232714 0.6232034 0.6231352 0.6230669 0.6229985 0.6229300 0.6228613 [127] 0.6227925 0.6227236 0.6226546 0.6225855 0.6225162 0.6224468 0.6223773 [134] 0.6223077 0.6222380 0.6221681 0.6220981 0.6220280 0.6219578 0.6218874 [141] 0.6218170 0.6217464 0.6216757 0.6216049 0.6215339 0.6214629 0.6213917 [148] 0.6213204 0.6212490 0.6211774 0.6211058 0.6210340 0.6209621 0.6208901 [155] 0.6208180 0.6207458 0.6206734 0.6206009 0.6205284 0.6204556 0.6203828 [162] 0.6203099 0.6202368 0.6201637 0.6200904 0.6200170 0.6199434 0.6198698 [169] 0.6197961 0.6197222 0.6196482 0.6195741 0.6194999 0.6194256 0.6193511 [176] 0.6192766 0.6192019 0.6191271 0.6190522 0.6189772 0.6189021 0.6188269 [183] 0.6187515 0.6186761 0.6186005 0.6185248 0.6184490 0.6183731 0.6182970 [190] 0.6182209 0.6181447 0.6180683 0.6179918 0.6179152 0.6178385 0.6177617 [197] 0.6176848 0.6176078 0.6175306 0.6174534 0.6173760 0.6172986 0.6172210 [204] 0.6171433 0.6170655 0.6169876 0.6169096 0.6168314 0.6167532 0.6166748 [211] 0.6165964 0.6165178 0.6164391 0.6163604 0.6162815 0.6162025 0.6161234 [218] 0.6160441 0.6159648 0.6158854 0.6158059 0.6157262 0.6156465 0.6155666 [225] 0.6154866 0.6154066 0.6153264 0.6152461 0.6151657 0.6150852 0.6150046 [232] 0.6149239 0.6148431 0.6147622 0.6146812 0.6146001 0.6145188 0.6144375 [239] 0.6143561 0.6142745 0.6141929 0.6141111 0.6140293 0.6139473 0.6138652 [246] 0.6137831 0.6137008 0.6136184 0.6135360 0.6134534 0.6133707 0.6132879 [253] 0.6132050 0.6131221 0.6130390 0.6129558 0.6128725 0.6127891 0.6127056 [260] 0.6126220 0.6125383 0.6124546 0.6123707 0.6122867 0.6122026 0.6121184 [267] 0.6120341 0.6119497 0.6118652 0.6117806 0.6116959 0.6116111 0.6115263 [274] 0.6114413 0.6113562 0.6112710 0.6111857 0.6111004 0.6110149 0.6109293 [281] 0.6108436 0.6107579 0.6106720 0.6105860 0.6105000 0.6104138 0.6103276 [288] 0.6102412 0.6101548 0.6100683 0.6099816 0.6098949 0.6098081 0.6097212 [295] 0.6096341 0.6095470 0.6094598 0.6093725 0.6092851 0.6091977 0.6091101 [302] 0.6090224 0.6089346 0.6088468 0.6087588 0.6086708 0.6085826 0.6084944 [309] 0.6084061 0.6083177 0.6082292 0.6081406 0.6080519 0.6079631 0.6078742 [316] 0.6077853 0.6076962 0.6076070 0.6075178 0.6074285 0.6073391 0.6072495 [323] 0.6071599 0.6070703 0.6069805 0.6068906 0.6068006 0.6067106 0.6066205 [330] 0.6065302 0.6064399 0.6063495 0.6062590 0.6061684 0.6060778 0.6059870 [337] 0.6058962 0.6058052 0.6057142 0.6056231 0.6055319 0.6054407 0.6053493 [344] 0.6052578 0.6051663 0.6050747 0.6049830 0.6048912 0.6047993 0.6047073 [351] 0.6046153 0.6045231 0.6044309 0.6043386 0.6042462 0.6041537 0.6040612 [358] 0.6039685 0.6038758 0.6037830 0.6036901 0.6035971 0.6035041 0.6034109 [365] 0.6033177 0.6032244 0.6031310 0.6030375 0.6029440 0.6028503 0.6027566 [372] 0.6026628 0.6025689 0.6024750 0.6023809 0.6022868 0.6021926 0.6020983 [379] 0.6020039 0.6019095 0.6018150 0.6017204 0.6016257 0.6015309 0.6014361 [386] 0.6013411 0.6012461 0.6011511 0.6010559 0.6009607 0.6008653 0.6007700 [393] 0.6006745 0.6005789 0.6004833 0.6003876 0.6002918 0.6001960 0.6001000 [400] 0.6000040 0.5999079 > mx [1] 0.6304579 > 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/1yett1257258964.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/29hpl1257258964.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/3doo91257258964.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/4d0xv1257258964.tab") > > system("convert tmp/1yett1257258964.ps tmp/1yett1257258964.png") > system("convert tmp/29hpl1257258964.ps tmp/29hpl1257258964.png") > system("convert tmp/3doo91257258964.ps tmp/3doo91257258964.png") > > > proc.time() user system elapsed 0.762 0.497 0.940