R version 2.6.0 (2007-10-03) Copyright (C) 2007 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(373,371,354,357,363,364,363,358,357,357,380,378,376,380,379,384,392,394,392,396,392,396,419,421,420,418,410,418,426,428,430,424,423,427,441,449,452,462,455,461,461,463,462,456,455,456,472,472,471,465,459,465,468,467,463,460,462,461,476,476,471,453,443,442,444,438,427,424,416,406,431,434,418) > x <- c(513,503,471,471,476,475,470,461,455,456,517,525,523,519,509,512,519,517,510,509,501,507,569,580,578,565,547,555,562,561,555,544,537,543,594,611,613,611,594,595,591,589,584,573,567,569,621,629,628,612,595,597,593,590,580,574,573,573,620,626,620,588,566,557,561,549,532,526,511,499,555,565,542) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2007), Box-Cox Linearity Plot (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxlin.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description > 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.9322370 0.9322800 0.9323228 0.9323654 0.9324078 0.9324499 0.9324918 [8] 0.9325335 0.9325749 0.9326161 0.9326572 0.9326979 0.9327385 0.9327788 [15] 0.9328190 0.9328588 0.9328985 0.9329380 0.9329772 0.9330162 0.9330549 [22] 0.9330935 0.9331318 0.9331699 0.9332078 0.9332454 0.9332828 0.9333200 [29] 0.9333570 0.9333938 0.9334303 0.9334666 0.9335027 0.9335385 0.9335742 [36] 0.9336096 0.9336447 0.9336797 0.9337144 0.9337489 0.9337832 0.9338172 [43] 0.9338511 0.9338847 0.9339180 0.9339512 0.9339841 0.9340168 0.9340493 [50] 0.9340815 0.9341135 0.9341453 0.9341769 0.9342082 0.9342394 0.9342702 [57] 0.9343009 0.9343313 0.9343616 0.9343915 0.9344213 0.9344508 0.9344801 [64] 0.9345092 0.9345381 0.9345667 0.9345951 0.9346233 0.9346512 0.9346790 [71] 0.9347065 0.9347337 0.9347608 0.9347876 0.9348142 0.9348405 0.9348667 [78] 0.9348926 0.9349183 0.9349437 0.9349690 0.9349940 0.9350187 0.9350433 [85] 0.9350676 0.9350917 0.9351156 0.9351392 0.9351626 0.9351858 0.9352088 [92] 0.9352315 0.9352540 0.9352763 0.9352983 0.9353202 0.9353418 0.9353631 [99] 0.9353843 0.9354052 0.9354259 0.9354463 0.9354666 0.9354866 0.9355064 [106] 0.9355259 0.9355452 0.9355643 0.9355832 0.9356019 0.9356203 0.9356385 [113] 0.9356564 0.9356742 0.9356917 0.9357089 0.9357260 0.9357428 0.9357594 [120] 0.9357758 0.9357919 0.9358078 0.9358235 0.9358390 0.9358542 0.9358692 [127] 0.9358840 0.9358986 0.9359129 0.9359270 0.9359409 0.9359545 0.9359679 [134] 0.9359811 0.9359941 0.9360068 0.9360193 0.9360316 0.9360436 0.9360555 [141] 0.9360671 0.9360784 0.9360896 0.9361005 0.9361112 0.9361216 0.9361319 [148] 0.9361419 0.9361516 0.9361612 0.9361705 0.9361796 0.9361885 0.9361971 [155] 0.9362055 0.9362137 0.9362217 0.9362294 0.9362369 0.9362442 0.9362513 [162] 0.9362581 0.9362647 0.9362711 0.9362772 0.9362832 0.9362888 0.9362943 [169] 0.9362996 0.9363046 0.9363094 0.9363139 0.9363182 0.9363224 0.9363262 [176] 0.9363299 0.9363333 0.9363365 0.9363395 0.9363422 0.9363448 0.9363471 [183] 0.9363491 0.9363510 0.9363526 0.9363540 0.9363551 0.9363561 0.9363568 [190] 0.9363573 0.9363575 0.9363576 0.9363574 0.9363570 0.9363563 0.9363555 [197] 0.9363544 0.9363530 0.9363515 0.9363497 0.9363477 0.9363455 0.9363431 [204] 0.9363404 0.9363375 0.9363344 0.9363310 0.9363275 0.9363237 0.9363196 [211] 0.9363154 0.9363109 0.9363062 0.9363013 0.9362961 0.9362908 0.9362852 [218] 0.9362793 0.9362733 0.9362670 0.9362605 0.9362538 0.9362469 0.9362397 [225] 0.9362323 0.9362247 0.9362168 0.9362088 0.9362005 0.9361920 0.9361832 [232] 0.9361743 0.9361651 0.9361557 0.9361460 0.9361362 0.9361261 0.9361158 [239] 0.9361053 0.9360945 0.9360836 0.9360724 0.9360609 0.9360493 0.9360374 [246] 0.9360254 0.9360130 0.9360005 0.9359878 0.9359748 0.9359616 0.9359482 [253] 0.9359345 0.9359206 0.9359066 0.9358922 0.9358777 0.9358629 0.9358480 [260] 0.9358328 0.9358174 0.9358017 0.9357858 0.9357698 0.9357535 0.9357369 [267] 0.9357202 0.9357032 0.9356860 0.9356686 0.9356510 0.9356331 0.9356150 [274] 0.9355967 0.9355782 0.9355595 0.9355405 0.9355214 0.9355020 0.9354823 [281] 0.9354625 0.9354424 0.9354222 0.9354017 0.9353809 0.9353600 0.9353389 [288] 0.9353175 0.9352959 0.9352741 0.9352520 0.9352298 0.9352073 0.9351846 [295] 0.9351617 0.9351386 0.9351153 0.9350917 0.9350679 0.9350439 0.9350197 [302] 0.9349953 0.9349706 0.9349457 0.9349206 0.9348953 0.9348698 0.9348441 [309] 0.9348181 0.9347919 0.9347655 0.9347389 0.9347121 0.9346851 0.9346578 [316] 0.9346303 0.9346026 0.9345747 0.9345466 0.9345183 0.9344897 0.9344609 [323] 0.9344319 0.9344027 0.9343733 0.9343437 0.9343138 0.9342838 0.9342535 [330] 0.9342230 0.9341923 0.9341613 0.9341302 0.9340989 0.9340673 0.9340355 [337] 0.9340035 0.9339713 0.9339389 0.9339062 0.9338734 0.9338403 0.9338070 [344] 0.9337735 0.9337398 0.9337059 0.9336718 0.9336374 0.9336029 0.9335681 [351] 0.9335331 0.9334979 0.9334625 0.9334269 0.9333911 0.9333550 0.9333188 [358] 0.9332823 0.9332456 0.9332088 0.9331717 0.9331343 0.9330968 0.9330591 [365] 0.9330211 0.9329830 0.9329446 0.9329061 0.9328673 0.9328283 0.9327891 [372] 0.9327497 0.9327100 0.9326702 0.9326302 0.9325899 0.9325495 0.9325088 [379] 0.9324679 0.9324268 0.9323855 0.9323440 0.9323023 0.9322604 0.9322183 [386] 0.9321759 0.9321334 0.9320907 0.9320477 0.9320045 0.9319612 0.9319176 [393] 0.9318738 0.9318298 0.9317856 0.9317412 0.9316966 0.9316518 0.9316068 [400] 0.9315615 0.9315161 > mx [1] 0.9363576 > mxli [1] -0.09 > 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/1u7ld1194257726.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/2n94q1194257726.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/3do4p1194257726.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 > 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/4pqmu1194257727.tab") > > system("convert tmp/1u7ld1194257726.ps tmp/1u7ld1194257726.png") > system("convert tmp/2n94q1194257726.ps tmp/2n94q1194257726.png") > system("convert tmp/3do4p1194257726.ps tmp/3do4p1194257726.png") > > > proc.time() user system elapsed 1.065 0.525 1.300