R version 2.8.0 (2008-10-20) 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(8.5,9.3,9.5,9.5,8.9,8.6,7.5,8.5,10.3,11.6,11.9,12.5,12.7,12.7,11.5,10,9.8,10.4,11.7,13.7,15.6,16.3,16.4,17.1,16.8) > x <- c(6.7,7.4,7.6,7.5,7.7,6.7,5.9,5.6,7.1,7.7,7.3,7.4,7.6,7.7,6.7,5.1,4.2,4,4.6,5.8,6.3,6.2,6.3,7.1,7.2) > #'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.15460454 0.15450534 0.15440576 0.15430580 0.15420546 0.15410473 [7] 0.15400362 0.15390213 0.15380026 0.15369801 0.15359538 0.15349236 [13] 0.15338896 0.15328519 0.15318102 0.15307648 0.15297156 0.15286625 [19] 0.15276056 0.15265449 0.15254804 0.15244121 0.15233399 0.15222640 [25] 0.15211842 0.15201006 0.15190132 0.15179220 0.15168269 0.15157281 [31] 0.15146254 0.15135190 0.15124087 0.15112946 0.15101767 0.15090550 [37] 0.15079295 0.15068002 0.15056671 0.15045302 0.15033895 0.15022450 [43] 0.15010967 0.14999447 0.14987888 0.14976291 0.14964657 0.14952984 [49] 0.14941274 0.14929526 0.14917740 0.14905916 0.14894055 0.14882156 [55] 0.14870219 0.14858244 0.14846232 0.14834182 0.14822095 0.14809970 [61] 0.14797807 0.14785607 0.14773369 0.14761094 0.14748782 0.14736432 [67] 0.14724044 0.14711620 0.14699158 0.14686658 0.14674122 0.14661548 [73] 0.14648937 0.14636288 0.14623603 0.14610881 0.14598121 0.14585325 [79] 0.14572491 0.14559621 0.14546714 0.14533769 0.14520788 0.14507771 [85] 0.14494716 0.14481625 0.14468497 0.14455333 0.14442131 0.14428894 [91] 0.14415620 0.14402309 0.14388962 0.14375579 0.14362160 0.14348704 [97] 0.14335212 0.14321684 0.14308119 0.14294519 0.14280883 0.14267211 [103] 0.14253502 0.14239758 0.14225979 0.14212163 0.14198312 0.14184425 [109] 0.14170502 0.14156544 0.14142551 0.14128522 0.14114458 0.14100358 [115] 0.14086224 0.14072054 0.14057849 0.14043609 0.14029333 0.14015023 [121] 0.14000678 0.13986299 0.13971884 0.13957435 0.13942951 0.13928433 [127] 0.13913880 0.13899293 0.13884671 0.13870015 0.13855325 0.13840600 [133] 0.13825842 0.13811049 0.13796223 0.13781363 0.13766468 0.13751541 [139] 0.13736579 0.13721584 0.13706555 0.13691493 0.13676398 0.13661269 [145] 0.13646107 0.13630911 0.13615683 0.13600422 0.13585127 0.13569800 [151] 0.13554441 0.13539048 0.13523623 0.13508165 0.13492675 0.13477152 [157] 0.13461597 0.13446010 0.13430391 0.13414740 0.13399056 0.13383341 [163] 0.13367594 0.13351816 0.13336005 0.13320163 0.13304290 0.13288385 [169] 0.13272449 0.13256482 0.13240484 0.13224454 0.13208394 0.13192303 [175] 0.13176181 0.13160028 0.13143845 0.13127631 0.13111387 0.13095113 [181] 0.13078808 0.13062473 0.13046108 0.13029713 0.13013289 0.12996834 [187] 0.12980350 0.12963836 0.12947293 0.12930721 0.12914119 0.12897488 [193] 0.12880828 0.12864138 0.12847420 0.12830673 0.12813898 0.12797094 [199] 0.12780261 0.12763400 0.12746511 0.12729593 0.12712647 0.12695674 [205] 0.12678672 0.12661642 0.12644585 0.12627501 0.12610388 0.12593249 [211] 0.12576082 0.12558888 0.12541666 0.12524418 0.12507143 0.12489841 [217] 0.12472513 0.12455157 0.12437776 0.12420368 0.12402934 0.12385473 [223] 0.12367987 0.12350475 0.12332937 0.12315373 0.12297784 0.12280169 [229] 0.12262528 0.12244863 0.12227172 0.12209456 0.12191716 0.12173950 [235] 0.12156160 0.12138345 0.12120505 0.12102641 0.12084753 0.12066841 [241] 0.12048905 0.12030944 0.12012960 0.11994952 0.11976921 0.11958866 [247] 0.11940788 0.11922686 0.11904561 0.11886414 0.11868243 0.11850049 [253] 0.11831833 0.11813594 0.11795333 0.11777049 0.11758743 0.11740415 [259] 0.11722065 0.11703693 0.11685300 0.11666884 0.11648448 0.11629989 [265] 0.11611510 0.11593009 0.11574487 0.11555944 0.11537380 0.11518796 [271] 0.11500191 0.11481565 0.11462919 0.11444253 0.11425567 0.11406861 [277] 0.11388135 0.11369389 0.11350623 0.11331838 0.11313033 0.11294210 [283] 0.11275367 0.11256504 0.11237623 0.11218723 0.11199805 0.11180868 [289] 0.11161912 0.11142938 0.11123946 0.11104936 0.11085907 0.11066861 [295] 0.11047797 0.11028716 0.11009617 0.10990500 0.10971367 0.10952216 [301] 0.10933048 0.10913864 0.10894662 0.10875444 0.10856209 0.10836958 [307] 0.10817691 0.10798407 0.10779108 0.10759792 0.10740461 0.10721114 [313] 0.10701751 0.10682373 0.10662980 0.10643571 0.10624147 0.10604709 [319] 0.10585255 0.10565787 0.10546304 0.10526807 0.10507295 0.10487769 [325] 0.10468229 0.10448675 0.10429107 0.10409526 0.10389931 0.10370322 [331] 0.10350700 0.10331064 0.10311416 0.10291754 0.10272079 0.10252392 [337] 0.10232692 0.10212980 0.10193255 0.10173517 0.10153768 0.10134006 [343] 0.10114233 0.10094448 0.10074651 0.10054842 0.10035022 0.10015191 [349] 0.09995348 0.09975494 0.09955630 0.09935754 0.09915868 0.09895971 [355] 0.09876063 0.09856145 0.09836217 0.09816279 0.09796330 0.09776372 [361] 0.09756404 0.09736426 0.09716439 0.09696442 0.09676436 0.09656421 [367] 0.09636396 0.09616363 0.09596321 0.09576270 0.09556210 0.09536142 [373] 0.09516065 0.09495981 0.09475888 0.09455787 0.09435678 0.09415561 [379] 0.09395436 0.09375304 0.09355165 0.09335018 0.09314864 0.09294703 [385] 0.09274534 0.09254359 0.09234177 0.09213989 0.09193794 0.09173592 [391] 0.09153384 0.09133170 0.09112950 0.09092724 0.09072492 0.09052254 [397] 0.09032010 0.09011761 0.08991507 0.08971247 0.08950982 > mx [1] 0.1546045 > 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/freestat/rcomp/tmp/1vnfj1226601242.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/freestat/rcomp/tmp/2fd8a1226601242.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/freestat/rcomp/tmp/3z7p11226601242.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/43lvh1226601242.tab") > > system("convert tmp/1vnfj1226601242.ps tmp/1vnfj1226601242.png") > system("convert tmp/2fd8a1226601242.ps tmp/2fd8a1226601242.png") > system("convert tmp/3z7p11226601242.ps tmp/3z7p11226601242.png") > > > proc.time() user system elapsed 1.180 0.773 1.283