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(114971,105531,104919,104782,101281,94545,93248,84031,87486,115867,120327,117008,108811) > x <- c(527070,509846,514258,516922,507561,492622,490243,469357,477580,528379,533590,517945,506174) > #'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.9568489 0.9568583 0.9568806 0.9568828 0.9569130 0.9569139 0.9569355 [8] 0.9569690 0.9569802 0.9569861 0.9570087 0.9570186 0.9570415 0.9570651 [15] 0.9570799 0.9570943 0.9571145 0.9571318 0.9571477 0.9571645 0.9571823 [22] 0.9572007 0.9572157 0.9572328 0.9572519 0.9572683 0.9572846 0.9573017 [29] 0.9573190 0.9573352 0.9573522 0.9573692 0.9573863 0.9574032 0.9574194 [36] 0.9574361 0.9574528 0.9574697 0.9574864 0.9575027 0.9575192 0.9575358 [43] 0.9575524 0.9575688 0.9575851 0.9576015 0.9576179 0.9576343 0.9576505 [50] 0.9576668 0.9576829 0.9576991 0.9577152 0.9577313 0.9577474 0.9577635 [57] 0.9577795 0.9577954 0.9578114 0.9578272 0.9578431 0.9578590 0.9578747 [64] 0.9578905 0.9579062 0.9579220 0.9579376 0.9579533 0.9579688 0.9579844 [71] 0.9579999 0.9580154 0.9580309 0.9580463 0.9580617 0.9580771 0.9580924 [78] 0.9581077 0.9581230 0.9581382 0.9581534 0.9581685 0.9581837 0.9581987 [85] 0.9582138 0.9582288 0.9582438 0.9582588 0.9582737 0.9582886 0.9583034 [92] 0.9583182 0.9583330 0.9583478 0.9583625 0.9583771 0.9583918 0.9584064 [99] 0.9584210 0.9584355 0.9584500 0.9584645 0.9584790 0.9584934 0.9585077 [106] 0.9585221 0.9585364 0.9585507 0.9585649 0.9585791 0.9585933 0.9586074 [113] 0.9586215 0.9586356 0.9586496 0.9586636 0.9586776 0.9586915 0.9587054 [120] 0.9587192 0.9587331 0.9587469 0.9587606 0.9587744 0.9587880 0.9588017 [127] 0.9588153 0.9588289 0.9588425 0.9588560 0.9588695 0.9588829 0.9588963 [134] 0.9589097 0.9589231 0.9589364 0.9589497 0.9589629 0.9589761 0.9589893 [141] 0.9590024 0.9590155 0.9590286 0.9590417 0.9590547 0.9590676 0.9590806 [148] 0.9590935 0.9591063 0.9591192 0.9591320 0.9591447 0.9591575 0.9591702 [155] 0.9591828 0.9591955 0.9592081 0.9592206 0.9592331 0.9592456 0.9592581 [162] 0.9592705 0.9592829 0.9592952 0.9593076 0.9593198 0.9593321 0.9593443 [169] 0.9593565 0.9593686 0.9593807 0.9593928 0.9594049 0.9594169 0.9594289 [176] 0.9594408 0.9594527 0.9594646 0.9594764 0.9594882 0.9595000 0.9595117 [183] 0.9595234 0.9595351 0.9595467 0.9595583 0.9595699 0.9595814 0.9595929 [190] 0.9596043 0.9596158 0.9596271 0.9596385 0.9596498 0.9596611 0.9596724 [197] 0.9596836 0.9596947 0.9597059 0.9597170 0.9597281 0.9597391 0.9597501 [204] 0.9597611 0.9597720 0.9597830 0.9597938 0.9598047 0.9598155 0.9598262 [211] 0.9598370 0.9598477 0.9598583 0.9598689 0.9598795 0.9598901 0.9599006 [218] 0.9599111 0.9599216 0.9599320 0.9599424 0.9599527 0.9599630 0.9599733 [225] 0.9599836 0.9599938 0.9600040 0.9600141 0.9600242 0.9600343 0.9600443 [232] 0.9600543 0.9600643 0.9600742 0.9600841 0.9600940 0.9601038 0.9601136 [239] 0.9601234 0.9601331 0.9601428 0.9601525 0.9601621 0.9601717 0.9601812 [246] 0.9601908 0.9602002 0.9602097 0.9602191 0.9602285 0.9602378 0.9602471 [253] 0.9602564 0.9602657 0.9602749 0.9602840 0.9602932 0.9603023 0.9603113 [260] 0.9603204 0.9603294 0.9603383 0.9603473 0.9603562 0.9603650 0.9603738 [267] 0.9603826 0.9603914 0.9604001 0.9604088 0.9604174 0.9604261 0.9604346 [274] 0.9604432 0.9604517 0.9604602 0.9604686 0.9604770 0.9604854 0.9604937 [281] 0.9605020 0.9605103 0.9605185 0.9605267 0.9605349 0.9605430 0.9605511 [288] 0.9605592 0.9605672 0.9605752 0.9605831 0.9605911 0.9605990 0.9606068 [295] 0.9606146 0.9606224 0.9606301 0.9606379 0.9606455 0.9606532 0.9606608 [302] 0.9606684 0.9606759 0.9606834 0.9606909 0.9606983 0.9607057 0.9607130 [309] 0.9607204 0.9607277 0.9607349 0.9607422 0.9607493 0.9607565 0.9607636 [316] 0.9607707 0.9607777 0.9607848 0.9607917 0.9607987 0.9608056 0.9608125 [323] 0.9608193 0.9608261 0.9608329 0.9608396 0.9608463 0.9608530 0.9608596 [330] 0.9608662 0.9608728 0.9608793 0.9608858 0.9608922 0.9608987 0.9609050 [337] 0.9609114 0.9609177 0.9609240 0.9609302 0.9609364 0.9609426 0.9609488 [344] 0.9609549 0.9609609 0.9609670 0.9609730 0.9609790 0.9609849 0.9609908 [351] 0.9609966 0.9610025 0.9610083 0.9610140 0.9610197 0.9610254 0.9610311 [358] 0.9610367 0.9610423 0.9610478 0.9610533 0.9610588 0.9610643 0.9610697 [365] 0.9610750 0.9610804 0.9610857 0.9610910 0.9610962 0.9611014 0.9611066 [372] 0.9611117 0.9611168 0.9611218 0.9611269 0.9611318 0.9611368 0.9611417 [379] 0.9611466 0.9611515 0.9611563 0.9611610 0.9611658 0.9611705 0.9611752 [386] 0.9611798 0.9611844 0.9611890 0.9611935 0.9611980 0.9612025 0.9612069 [393] 0.9612113 0.9612157 0.9612200 0.9612243 0.9612285 0.9612328 0.9612370 [400] 0.9612411 0.9612452 > mx [1] 0.9612452 > 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/1r1mz1227192875.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/2ub7j1227192875.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/3oom61227192875.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/49tig1227192875.tab") > > system("convert tmp/1r1mz1227192875.ps tmp/1r1mz1227192875.png") > system("convert tmp/2ub7j1227192875.ps tmp/2ub7j1227192875.png") > system("convert tmp/3oom61227192875.ps tmp/3oom61227192875.png") > > > proc.time() user system elapsed 0.754 0.476 1.638