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(20,16,10,12,10,12,12,13,17,12,15,12,14,19,16,17,16,19,17,17,20,18,16,19,18,23,20,20,15,17,16,15,10,13,10,19,21,17,16,17,14,18,17,14,15,16,11,15,13,17,16,9,17,15,12,12,12,12,4,7,4,3,3,0,5,3,4,3,10,4,1,1) > x <- c(22,22,20,21,20,21,21,21,19,21,21,22,19,24,22,22,22,24,22,23,24,21,20,22,23,23,22,20,21,21,20,20,17,18,19,19,20,21,20,21,19,22,20,18,16,17,18,19,18,20,21,18,19,19,19,21,19,19,17,16,16,17,16,15,16,16,16,18,19,16,16,16) > #'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.8091589 0.8091132 0.8090673 0.8090210 0.8089745 0.8089277 0.8088806 [8] 0.8088333 0.8087857 0.8087378 0.8086896 0.8086412 0.8085925 0.8085435 [15] 0.8084942 0.8084447 0.8083949 0.8083448 0.8082944 0.8082438 0.8081929 [22] 0.8081417 0.8080902 0.8080384 0.8079864 0.8079341 0.8078815 0.8078286 [29] 0.8077755 0.8077221 0.8076684 0.8076144 0.8075602 0.8075056 0.8074508 [36] 0.8073958 0.8073404 0.8072847 0.8072288 0.8071726 0.8071161 0.8070594 [43] 0.8070023 0.8069450 0.8068874 0.8068295 0.8067714 0.8067129 0.8066542 [50] 0.8065952 0.8065359 0.8064763 0.8064165 0.8063564 0.8062960 0.8062353 [57] 0.8061743 0.8061131 0.8060515 0.8059897 0.8059276 0.8058652 0.8058026 [64] 0.8057396 0.8056764 0.8056129 0.8055491 0.8054850 0.8054207 0.8053560 [71] 0.8052911 0.8052259 0.8051604 0.8050946 0.8050286 0.8049622 0.8048956 [78] 0.8048287 0.8047615 0.8046940 0.8046263 0.8045582 0.8044899 0.8044213 [85] 0.8043524 0.8042832 0.8042138 0.8041440 0.8040740 0.8040037 0.8039330 [92] 0.8038622 0.8037910 0.8037195 0.8036478 0.8035758 0.8035034 0.8034308 [99] 0.8033580 0.8032848 0.8032113 0.8031376 0.8030636 0.8029892 0.8029146 [106] 0.8028398 0.8027646 0.8026891 0.8026134 0.8025373 0.8024610 0.8023844 [113] 0.8023075 0.8022304 0.8021529 0.8020751 0.8019971 0.8019188 0.8018402 [120] 0.8017613 0.8016821 0.8016026 0.8015229 0.8014428 0.8013625 0.8012819 [127] 0.8012010 0.8011198 0.8010383 0.8009565 0.8008745 0.8007921 0.8007095 [134] 0.8006266 0.8005434 0.8004599 0.8003761 0.8002921 0.8002077 0.8001231 [141] 0.8000381 0.7999529 0.7998674 0.7997816 0.7996956 0.7996092 0.7995226 [148] 0.7994356 0.7993484 0.7992609 0.7991731 0.7990850 0.7989966 0.7989079 [155] 0.7988190 0.7987297 0.7986402 0.7985504 0.7984603 0.7983699 0.7982792 [162] 0.7981883 0.7980970 0.7980055 0.7979136 0.7978215 0.7977291 0.7976364 [169] 0.7975434 0.7974502 0.7973566 0.7972628 0.7971686 0.7970742 0.7969795 [176] 0.7968845 0.7967892 0.7966937 0.7965978 0.7965017 0.7964053 0.7963085 [183] 0.7962115 0.7961142 0.7960167 0.7959188 0.7958207 0.7957222 0.7956235 [190] 0.7955245 0.7954252 0.7953256 0.7952257 0.7951256 0.7950251 0.7949244 [197] 0.7948234 0.7947220 0.7946205 0.7945186 0.7944164 0.7943140 0.7942112 [204] 0.7941082 0.7940049 0.7939013 0.7937974 0.7936932 0.7935888 0.7934840 [211] 0.7933790 0.7932737 0.7931681 0.7930622 0.7929560 0.7928496 0.7927429 [218] 0.7926358 0.7925285 0.7924209 0.7923130 0.7922049 0.7920964 0.7919877 [225] 0.7918787 0.7917694 0.7916598 0.7915499 0.7914398 0.7913293 0.7912186 [232] 0.7911076 0.7909963 0.7908847 0.7907729 0.7906607 0.7905483 0.7904356 [239] 0.7903226 0.7902093 0.7900957 0.7899819 0.7898678 0.7897534 0.7896387 [246] 0.7895237 0.7894084 0.7892929 0.7891771 0.7890610 0.7889446 0.7888279 [253] 0.7887110 0.7885938 0.7884763 0.7883585 0.7882404 0.7881220 0.7880034 [260] 0.7878845 0.7877653 0.7876458 0.7875261 0.7874060 0.7872857 0.7871651 [267] 0.7870442 0.7869231 0.7868017 0.7866799 0.7865580 0.7864357 0.7863131 [274] 0.7861903 0.7860672 0.7859438 0.7858202 0.7856962 0.7855720 0.7854475 [281] 0.7853227 0.7851977 0.7850723 0.7849467 0.7848209 0.7846947 0.7845683 [288] 0.7844415 0.7843146 0.7841873 0.7840598 0.7839319 0.7838039 0.7836755 [295] 0.7835468 0.7834179 0.7832887 0.7831593 0.7830295 0.7828995 0.7827692 [302] 0.7826387 0.7825078 0.7823767 0.7822454 0.7821137 0.7819818 0.7818496 [309] 0.7817171 0.7815844 0.7814513 0.7813181 0.7811845 0.7810507 0.7809166 [316] 0.7807822 0.7806476 0.7805126 0.7803775 0.7802420 0.7801063 0.7799703 [323] 0.7798340 0.7796975 0.7795607 0.7794236 0.7792863 0.7791487 0.7790108 [330] 0.7788727 0.7787343 0.7785956 0.7784567 0.7783174 0.7781780 0.7780382 [337] 0.7778982 0.7777579 0.7776174 0.7774766 0.7773355 0.7771942 0.7770526 [344] 0.7769107 0.7767686 0.7766262 0.7764835 0.7763406 0.7761974 0.7760540 [351] 0.7759103 0.7757663 0.7756221 0.7754776 0.7753328 0.7751878 0.7750425 [358] 0.7748970 0.7747512 0.7746051 0.7744588 0.7743122 0.7741654 0.7740183 [365] 0.7738709 0.7737233 0.7735754 0.7734273 0.7732789 0.7731303 0.7729814 [372] 0.7728322 0.7726828 0.7725331 0.7723832 0.7722330 0.7720825 0.7719318 [379] 0.7717809 0.7716297 0.7714782 0.7713265 0.7711745 0.7710223 0.7708698 [386] 0.7707171 0.7705641 0.7704108 0.7702573 0.7701036 0.7699496 0.7697954 [393] 0.7696409 0.7694861 0.7693311 0.7691759 0.7690204 0.7688646 0.7687087 [400] 0.7685524 0.7683959 > mx [1] 0.809159 > 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/17k231257943032.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/2papb1257943032.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/3dirn1257943032.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/4aff61257943032.tab") > > system("convert tmp/17k231257943032.ps tmp/17k231257943032.png") > system("convert tmp/2papb1257943032.ps tmp/2papb1257943032.png") > system("convert tmp/3dirn1257943032.ps tmp/3dirn1257943032.png") > > > proc.time() user system elapsed 0.792 0.507 0.969