R version 2.8.1 (2008-12-22) 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(4090,4173,4231,4226,4230,4270,4331,4384,4456,4538) > x <- c(6715,6724,6743,6774,6805,6835,6879,6942,7012,7070) > #'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.9778470 0.9778481 0.9778491 0.9778502 0.9778512 0.9778523 0.9778533 [8] 0.9778544 0.9778554 0.9778564 0.9778575 0.9778585 0.9778595 0.9778605 [15] 0.9778615 0.9778625 0.9778635 0.9778645 0.9778655 0.9778665 0.9778675 [22] 0.9778684 0.9778694 0.9778704 0.9778713 0.9778723 0.9778732 0.9778742 [29] 0.9778751 0.9778761 0.9778770 0.9778779 0.9778789 0.9778798 0.9778807 [36] 0.9778816 0.9778825 0.9778834 0.9778844 0.9778852 0.9778861 0.9778870 [43] 0.9778879 0.9778888 0.9778897 0.9778905 0.9778914 0.9778923 0.9778931 [50] 0.9778940 0.9778948 0.9778957 0.9778965 0.9778973 0.9778982 0.9778990 [57] 0.9778998 0.9779006 0.9779015 0.9779023 0.9779031 0.9779039 0.9779047 [64] 0.9779055 0.9779062 0.9779070 0.9779078 0.9779086 0.9779093 0.9779101 [71] 0.9779109 0.9779116 0.9779124 0.9779131 0.9779139 0.9779146 0.9779153 [78] 0.9779161 0.9779168 0.9779175 0.9779182 0.9779189 0.9779197 0.9779204 [85] 0.9779211 0.9779217 0.9779224 0.9779231 0.9779238 0.9779245 0.9779252 [92] 0.9779258 0.9779265 0.9779271 0.9779278 0.9779285 0.9779291 0.9779297 [99] 0.9779304 0.9779310 0.9779316 0.9779323 0.9779329 0.9779335 0.9779341 [106] 0.9779347 0.9779353 0.9779359 0.9779365 0.9779371 0.9779377 0.9779383 [113] 0.9779388 0.9779394 0.9779400 0.9779405 0.9779411 0.9779416 0.9779422 [120] 0.9779427 0.9779433 0.9779438 0.9779443 0.9779449 0.9779454 0.9779459 [127] 0.9779464 0.9779469 0.9779474 0.9779479 0.9779484 0.9779489 0.9779494 [134] 0.9779499 0.9779504 0.9779508 0.9779513 0.9779518 0.9779522 0.9779527 [141] 0.9779532 0.9779536 0.9779540 0.9779545 0.9779549 0.9779553 0.9779558 [148] 0.9779562 0.9779566 0.9779570 0.9779574 0.9779578 0.9779582 0.9779586 [155] 0.9779590 0.9779594 0.9779598 0.9779602 0.9779605 0.9779609 0.9779613 [162] 0.9779616 0.9779620 0.9779623 0.9779627 0.9779630 0.9779633 0.9779637 [169] 0.9779640 0.9779643 0.9779647 0.9779650 0.9779653 0.9779656 0.9779659 [176] 0.9779662 0.9779665 0.9779668 0.9779670 0.9779673 0.9779676 0.9779679 [183] 0.9779681 0.9779684 0.9779687 0.9779689 0.9779692 0.9779694 0.9779696 [190] 0.9779699 0.9779701 0.9779703 0.9779706 0.9779708 0.9779710 0.9779712 [197] 0.9779714 0.9779716 0.9779718 0.9779720 0.9779722 0.9779724 0.9779725 [204] 0.9779727 0.9779729 0.9779730 0.9779732 0.9779734 0.9779735 0.9779737 [211] 0.9779738 0.9779739 0.9779741 0.9779742 0.9779743 0.9779744 0.9779746 [218] 0.9779747 0.9779748 0.9779749 0.9779750 0.9779751 0.9779752 0.9779752 [225] 0.9779753 0.9779754 0.9779755 0.9779755 0.9779756 0.9779757 0.9779757 [232] 0.9779758 0.9779758 0.9779758 0.9779759 0.9779759 0.9779759 0.9779760 [239] 0.9779760 0.9779760 0.9779760 0.9779760 0.9779760 0.9779760 0.9779760 [246] 0.9779760 0.9779760 0.9779760 0.9779759 0.9779759 0.9779759 0.9779758 [253] 0.9779758 0.9779757 0.9779757 0.9779756 0.9779756 0.9779755 0.9779754 [260] 0.9779754 0.9779753 0.9779752 0.9779751 0.9779750 0.9779749 0.9779748 [267] 0.9779747 0.9779746 0.9779745 0.9779744 0.9779742 0.9779741 0.9779740 [274] 0.9779738 0.9779737 0.9779736 0.9779734 0.9779733 0.9779731 0.9779729 [281] 0.9779728 0.9779726 0.9779724 0.9779722 0.9779720 0.9779719 0.9779717 [288] 0.9779715 0.9779713 0.9779711 0.9779708 0.9779706 0.9779704 0.9779702 [295] 0.9779699 0.9779697 0.9779695 0.9779692 0.9779690 0.9779687 0.9779685 [302] 0.9779682 0.9779680 0.9779677 0.9779674 0.9779671 0.9779668 0.9779666 [309] 0.9779663 0.9779660 0.9779657 0.9779654 0.9779651 0.9779647 0.9779644 [316] 0.9779641 0.9779638 0.9779634 0.9779631 0.9779628 0.9779624 0.9779621 [323] 0.9779617 0.9779614 0.9779610 0.9779606 0.9779603 0.9779599 0.9779595 [330] 0.9779591 0.9779587 0.9779583 0.9779579 0.9779575 0.9779571 0.9779567 [337] 0.9779563 0.9779559 0.9779555 0.9779550 0.9779546 0.9779542 0.9779537 [344] 0.9779533 0.9779528 0.9779524 0.9779519 0.9779514 0.9779510 0.9779505 [351] 0.9779500 0.9779495 0.9779490 0.9779486 0.9779481 0.9779476 0.9779471 [358] 0.9779465 0.9779460 0.9779455 0.9779450 0.9779445 0.9779439 0.9779434 [365] 0.9779429 0.9779423 0.9779418 0.9779412 0.9779406 0.9779401 0.9779395 [372] 0.9779389 0.9779384 0.9779378 0.9779372 0.9779366 0.9779360 0.9779354 [379] 0.9779348 0.9779342 0.9779336 0.9779330 0.9779324 0.9779317 0.9779311 [386] 0.9779305 0.9779298 0.9779292 0.9779286 0.9779279 0.9779273 0.9779266 [393] 0.9779259 0.9779253 0.9779246 0.9779239 0.9779232 0.9779225 0.9779219 [400] 0.9779212 0.9779205 > mx [1] 0.977976 > mxli [1] 0.42 > 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/rcomp/tmp/1qm8m1258054997.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/rcomp/tmp/2gvcf1258054997.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/rcomp/tmp/3jq0c1258054997.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/4nb401258054997.tab") > > system("convert tmp/1qm8m1258054997.ps tmp/1qm8m1258054997.png") > system("convert tmp/2gvcf1258054997.ps tmp/2gvcf1258054997.png") > system("convert tmp/3jq0c1258054997.ps tmp/3jq0c1258054997.png") > > > proc.time() user system elapsed 0.97 0.76 1.33