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(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) > x <- 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) > #'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.6245425 0.6245409 0.6245389 0.6245367 0.6245341 0.6245311 0.6245279 [8] 0.6245243 0.6245204 0.6245161 0.6245116 0.6245067 0.6245014 0.6244959 [15] 0.6244900 0.6244837 0.6244772 0.6244703 0.6244631 0.6244556 0.6244477 [22] 0.6244395 0.6244310 0.6244221 0.6244129 0.6244034 0.6243935 0.6243833 [29] 0.6243728 0.6243620 0.6243508 0.6243393 0.6243274 0.6243152 0.6243027 [36] 0.6242899 0.6242767 0.6242632 0.6242494 0.6242352 0.6242207 0.6242059 [43] 0.6241907 0.6241752 0.6241594 0.6241432 0.6241267 0.6241099 0.6240927 [50] 0.6240752 0.6240573 0.6240392 0.6240207 0.6240018 0.6239827 0.6239632 [57] 0.6239433 0.6239231 0.6239026 0.6238818 0.6238606 0.6238391 0.6238173 [64] 0.6237951 0.6237726 0.6237497 0.6237265 0.6237030 0.6236792 0.6236550 [71] 0.6236304 0.6236056 0.6235804 0.6235549 0.6235290 0.6235028 0.6234762 [78] 0.6234494 0.6234222 0.6233946 0.6233667 0.6233385 0.6233100 0.6232811 [85] 0.6232519 0.6232223 0.6231924 0.6231622 0.6231316 0.6231007 0.6230694 [92] 0.6230379 0.6230060 0.6229737 0.6229411 0.6229082 0.6228749 0.6228413 [99] 0.6228074 0.6227731 0.6227385 0.6227036 0.6226683 0.6226327 0.6225968 [106] 0.6225605 0.6225238 0.6224869 0.6224496 0.6224119 0.6223740 0.6223357 [113] 0.6222970 0.6222580 0.6222187 0.6221791 0.6221391 0.6220987 0.6220581 [120] 0.6220171 0.6219757 0.6219341 0.6218921 0.6218497 0.6218070 0.6217640 [127] 0.6217206 0.6216769 0.6216329 0.6215885 0.6215438 0.6214988 0.6214534 [134] 0.6214077 0.6213616 0.6213152 0.6212685 0.6212215 0.6211741 0.6211263 [141] 0.6210783 0.6210298 0.6209811 0.6209320 0.6208826 0.6208328 0.6207828 [148] 0.6207323 0.6206816 0.6206305 0.6205790 0.6205273 0.6204752 0.6204227 [155] 0.6203699 0.6203168 0.6202634 0.6202096 0.6201555 0.6201010 0.6200462 [162] 0.6199911 0.6199356 0.6198798 0.6198237 0.6197672 0.6197104 0.6196533 [169] 0.6195958 0.6195380 0.6194798 0.6194214 0.6193625 0.6193034 0.6192439 [176] 0.6191841 0.6191239 0.6190634 0.6190026 0.6189415 0.6188800 0.6188181 [183] 0.6187560 0.6186935 0.6186307 0.6185675 0.6185040 0.6184402 0.6183760 [190] 0.6183115 0.6182467 0.6181815 0.6181160 0.6180502 0.6179840 0.6179175 [197] 0.6178507 0.6177836 0.6177161 0.6176482 0.6175801 0.6175116 0.6174428 [204] 0.6173736 0.6173041 0.6172343 0.6171642 0.6170937 0.6170229 0.6169517 [211] 0.6168802 0.6168084 0.6167363 0.6166638 0.6165910 0.6165179 0.6164444 [218] 0.6163706 0.6162965 0.6162221 0.6161473 0.6160722 0.6159967 0.6159210 [225] 0.6158449 0.6157684 0.6156917 0.6156146 0.6155372 0.6154594 0.6153814 [232] 0.6153030 0.6152242 0.6151452 0.6150658 0.6149861 0.6149060 0.6148257 [239] 0.6147450 0.6146640 0.6145826 0.6145009 0.6144189 0.6143366 0.6142539 [246] 0.6141710 0.6140877 0.6140040 0.6139201 0.6138358 0.6137512 0.6136662 [253] 0.6135810 0.6134954 0.6134095 0.6133232 0.6132367 0.6131498 0.6130626 [260] 0.6129751 0.6128872 0.6127990 0.6127105 0.6126217 0.6125326 0.6124431 [267] 0.6123533 0.6122632 0.6121728 0.6120820 0.6119909 0.6118995 0.6118078 [274] 0.6117158 0.6116234 0.6115307 0.6114377 0.6113444 0.6112508 0.6111568 [281] 0.6110625 0.6109679 0.6108730 0.6107777 0.6106822 0.6105863 0.6104901 [288] 0.6103936 0.6102968 0.6101996 0.6101022 0.6100044 0.6099063 0.6098079 [295] 0.6097091 0.6096101 0.6095107 0.6094110 0.6093110 0.6092107 0.6091101 [302] 0.6090091 0.6089079 0.6088063 0.6087044 0.6086022 0.6084997 0.6083969 [309] 0.6082938 0.6081903 0.6080865 0.6079825 0.6078781 0.6077734 0.6076684 [316] 0.6075630 0.6074574 0.6073515 0.6072452 0.6071386 0.6070318 0.6069246 [323] 0.6068171 0.6067093 0.6066012 0.6064927 0.6063840 0.6062750 0.6061656 [330] 0.6060560 0.6059460 0.6058357 0.6057252 0.6056143 0.6055031 0.6053916 [337] 0.6052798 0.6051677 0.6050553 0.6049426 0.6048295 0.6047162 0.6046026 [344] 0.6044886 0.6043744 0.6042599 0.6041450 0.6040299 0.6039144 0.6037987 [351] 0.6036826 0.6035663 0.6034496 0.6033327 0.6032154 0.6030979 0.6029800 [358] 0.6028619 0.6027434 0.6026247 0.6025056 0.6023863 0.6022666 0.6021467 [365] 0.6020264 0.6019059 0.6017851 0.6016639 0.6015425 0.6014208 0.6012988 [372] 0.6011764 0.6010538 0.6009309 0.6008077 0.6006842 0.6005605 0.6004364 [379] 0.6003120 0.6001873 0.6000624 0.5999371 0.5998116 0.5996858 0.5995597 [386] 0.5994332 0.5993065 0.5991795 0.5990523 0.5989247 0.5987968 0.5986687 [393] 0.5985403 0.5984115 0.5982825 0.5981532 0.5980236 0.5978938 0.5977636 [400] 0.5976332 0.5975025 > mx [1] 0.6245425 > 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/1aa0f1257259144.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/2d1bk1257259144.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/3xbu51257259144.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/4xv3z1257259144.tab") > > system("convert tmp/1aa0f1257259144.ps tmp/1aa0f1257259144.png") > system("convert tmp/2d1bk1257259144.ps tmp/2d1bk1257259144.png") > system("convert tmp/3xbu51257259144.ps tmp/3xbu51257259144.png") > > > proc.time() user system elapsed 0.775 0.487 0.941