R version 2.7.2 (2008-08-25) 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(110.4,112.9,109.4,111.9,108.9,113.8,114.5,113.2,111,114.6,113.1,113.2,115.1,117.6,117.8,115.7,115.7,118.3,117.9,117.3,119.4,117.1,119,120,118.9,116,115.6,119.7,119.7,120.8,120,120.2,121.7,116.9,122.4,122.6,123.7,120.9,124.2,122.6,125.7,123.1,122.2,126.2,124.4,127.8,124.2,126.7,126.1,128.2,130.4,130.2,129.2,129.7,131,129.2,131.1,132.9,135.2,132.3) > x <- c(101.5,101.3,99.3,100.6,101.2,99.8,100.6,101.1,101.2,101.5,102.2,102.5,101.4,103.8,105.2,105.3,104.4,104.9,106.9,107.6,106.7,106.1,106.3,105.8,104.4,103.8,102.4,103.3,103.5,104.5,103.5,103.9,103.1,102.2,104.7,105.9,106.6,106.6,107.5,107.2,109,108.4,107,108,110.8,110.9,109.7,111,111.5,111,111.8,111.4,110.8,111.9,112.9,111.8,111,112.3,112.4,111.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.9237424 0.9237567 0.9237709 0.9237852 0.9237994 0.9238136 0.9238277 [8] 0.9238419 0.9238560 0.9238701 0.9238842 0.9238983 0.9239123 0.9239263 [15] 0.9239403 0.9239543 0.9239682 0.9239821 0.9239960 0.9240099 0.9240238 [22] 0.9240376 0.9240514 0.9240652 0.9240789 0.9240927 0.9241064 0.9241201 [29] 0.9241338 0.9241474 0.9241611 0.9241747 0.9241883 0.9242018 0.9242154 [36] 0.9242289 0.9242424 0.9242558 0.9242693 0.9242827 0.9242961 0.9243095 [43] 0.9243229 0.9243362 0.9243495 0.9243628 0.9243761 0.9243893 0.9244026 [50] 0.9244158 0.9244289 0.9244421 0.9244552 0.9244683 0.9244814 0.9244945 [57] 0.9245075 0.9245206 0.9245336 0.9245466 0.9245595 0.9245724 0.9245854 [64] 0.9245982 0.9246111 0.9246239 0.9246368 0.9246496 0.9246623 0.9246751 [71] 0.9246878 0.9247005 0.9247132 0.9247259 0.9247385 0.9247512 0.9247637 [78] 0.9247763 0.9247889 0.9248014 0.9248139 0.9248264 0.9248389 0.9248513 [85] 0.9248637 0.9248761 0.9248885 0.9249008 0.9249132 0.9249255 0.9249377 [92] 0.9249500 0.9249622 0.9249745 0.9249867 0.9249988 0.9250110 0.9250231 [99] 0.9250352 0.9250473 0.9250593 0.9250714 0.9250834 0.9250954 0.9251074 [106] 0.9251193 0.9251312 0.9251431 0.9251550 0.9251669 0.9251787 0.9251905 [113] 0.9252023 0.9252141 0.9252258 0.9252375 0.9252492 0.9252609 0.9252726 [120] 0.9252842 0.9252958 0.9253074 0.9253190 0.9253305 0.9253420 0.9253535 [127] 0.9253650 0.9253765 0.9253879 0.9253993 0.9254107 0.9254221 0.9254334 [134] 0.9254447 0.9254560 0.9254673 0.9254786 0.9254898 0.9255010 0.9255122 [141] 0.9255234 0.9255345 0.9255456 0.9255567 0.9255678 0.9255788 0.9255899 [148] 0.9256009 0.9256119 0.9256228 0.9256338 0.9256447 0.9256556 0.9256665 [155] 0.9256773 0.9256881 0.9256990 0.9257097 0.9257205 0.9257312 0.9257420 [162] 0.9257527 0.9257633 0.9257740 0.9257846 0.9257952 0.9258058 0.9258164 [169] 0.9258269 0.9258374 0.9258479 0.9258584 0.9258688 0.9258793 0.9258897 [176] 0.9259001 0.9259104 0.9259208 0.9259311 0.9259414 0.9259517 0.9259619 [183] 0.9259721 0.9259823 0.9259925 0.9260027 0.9260128 0.9260229 0.9260330 [190] 0.9260431 0.9260532 0.9260632 0.9260732 0.9260832 0.9260931 0.9261031 [197] 0.9261130 0.9261229 0.9261328 0.9261426 0.9261525 0.9261623 0.9261720 [204] 0.9261818 0.9261915 0.9262013 0.9262110 0.9262206 0.9262303 0.9262399 [211] 0.9262495 0.9262591 0.9262687 0.9262782 0.9262877 0.9262972 0.9263067 [218] 0.9263161 0.9263256 0.9263350 0.9263444 0.9263537 0.9263631 0.9263724 [225] 0.9263817 0.9263910 0.9264002 0.9264095 0.9264187 0.9264278 0.9264370 [232] 0.9264462 0.9264553 0.9264644 0.9264734 0.9264825 0.9264915 0.9265005 [239] 0.9265095 0.9265185 0.9265274 0.9265364 0.9265453 0.9265541 0.9265630 [246] 0.9265718 0.9265806 0.9265894 0.9265982 0.9266069 0.9266157 0.9266244 [253] 0.9266330 0.9266417 0.9266503 0.9266589 0.9266675 0.9266761 0.9266846 [260] 0.9266932 0.9267017 0.9267101 0.9267186 0.9267270 0.9267355 0.9267438 [267] 0.9267522 0.9267606 0.9267689 0.9267772 0.9267855 0.9267937 0.9268020 [274] 0.9268102 0.9268184 0.9268266 0.9268347 0.9268428 0.9268509 0.9268590 [281] 0.9268671 0.9268751 0.9268831 0.9268911 0.9268991 0.9269071 0.9269150 [288] 0.9269229 0.9269308 0.9269387 0.9269465 0.9269543 0.9269621 0.9269699 [295] 0.9269777 0.9269854 0.9269931 0.9270008 0.9270085 0.9270161 0.9270237 [302] 0.9270313 0.9270389 0.9270465 0.9270540 0.9270615 0.9270690 0.9270765 [309] 0.9270839 0.9270913 0.9270987 0.9271061 0.9271135 0.9271208 0.9271281 [316] 0.9271354 0.9271427 0.9271500 0.9271572 0.9271644 0.9271716 0.9271788 [323] 0.9271859 0.9271930 0.9272001 0.9272072 0.9272142 0.9272213 0.9272283 [330] 0.9272353 0.9272423 0.9272492 0.9272561 0.9272630 0.9272699 0.9272768 [337] 0.9272836 0.9272904 0.9272972 0.9273040 0.9273107 0.9273175 0.9273242 [344] 0.9273308 0.9273375 0.9273442 0.9273508 0.9273574 0.9273639 0.9273705 [351] 0.9273770 0.9273835 0.9273900 0.9273965 0.9274029 0.9274094 0.9274158 [358] 0.9274222 0.9274285 0.9274348 0.9274412 0.9274475 0.9274537 0.9274600 [365] 0.9274662 0.9274724 0.9274786 0.9274848 0.9274909 0.9274970 0.9275031 [372] 0.9275092 0.9275153 0.9275213 0.9275273 0.9275333 0.9275393 0.9275452 [379] 0.9275511 0.9275570 0.9275629 0.9275688 0.9275746 0.9275804 0.9275862 [386] 0.9275920 0.9275978 0.9276035 0.9276092 0.9276149 0.9276206 0.9276262 [393] 0.9276318 0.9276374 0.9276430 0.9276486 0.9276541 0.9276596 0.9276651 [400] 0.9276706 0.9276760 > mx [1] 0.927676 > 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/11d1t1226432485.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/2rdbl1226432485.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/3sbtj1226432485.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/4yesp1226432485.tab") > > system("convert tmp/11d1t1226432485.ps tmp/11d1t1226432485.png") > system("convert tmp/2rdbl1226432485.ps tmp/2rdbl1226432485.png") > system("convert tmp/3sbtj1226432485.ps tmp/3sbtj1226432485.png") > > > proc.time() user system elapsed 1.052 0.518 1.210