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(8.7,8.5,8.2,8.3,8,8.1,8.7,9.3,8.9,8.8,8.4,8.4,7.3,7.2,7,7,6.9,6.9,7.1,7.5,7.4,8.9,8.3,8.3,9,8.9,8.8,7.8,7.8,7.8,9.2,9.3,9.2,8.6,8.5,8.5,9,9,8.8,8,7.9,8.1,9.3,9.4,9.4,9.3,9,9.1,9.7,9.7,9.6,8.3,8.2,8.4,10.6,10.9,10.9,9.6,9.3,9.3,9.6,9.5,9.5,9,8.9,9,10.1,10.2,10.2,9.5,9.3,9.3,9.4,9.3,9.1,9,8.9,9,9.8,10,9.8,9.4,9,8.9,9.3,9.1,8.8,8.9,8.7,8.6,9.1,9.3,8.9) > x <- c(7.4,7.2,7,6.6,6.4,6.4,6.8,7.3,7,7,6.7,6.7,6.3,6.2,6,6.3,6.2,6.1,6.2,6.6,6.6,7.8,7.4,7.4,7.5,7.4,7.4,7,6.9,6.9,7.6,7.7,7.6,8.2,8,8.1,8.3,8.2,8.1,7.7,7.6,7.7,8.2,8.4,8.4,8.6,8.4,8.5,8.7,8.7,8.6,7.4,7.3,7.4,9,9.2,9.2,8.5,8.3,8.3,8.6,8.6,8.5,8.1,8.1,8,8.6,8.7,8.7,8.6,8.4,8.4,8.7,8.7,8.5,8.3,8.3,8.3,8.1,8.2,8.1,8.1,7.9,7.7,8.1,8,7.7,7.8,7.6,7.4,7.7,7.9,7.6) > #'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.8684271 0.8684826 0.8685380 0.8685931 0.8686481 0.8687030 0.8687576 [8] 0.8688121 0.8688665 0.8689206 0.8689746 0.8690284 0.8690821 0.8691356 [15] 0.8691889 0.8692420 0.8692950 0.8693478 0.8694004 0.8694529 0.8695052 [22] 0.8695573 0.8696092 0.8696610 0.8697126 0.8697641 0.8698153 0.8698664 [29] 0.8699174 0.8699681 0.8700187 0.8700691 0.8701194 0.8701694 0.8702193 [36] 0.8702690 0.8703186 0.8703680 0.8704172 0.8704662 0.8705151 0.8705638 [43] 0.8706123 0.8706606 0.8707088 0.8707568 0.8708046 0.8708523 0.8708998 [50] 0.8709471 0.8709942 0.8710412 0.8710879 0.8711345 0.8711810 0.8712272 [57] 0.8712733 0.8713192 0.8713650 0.8714105 0.8714559 0.8715011 0.8715462 [64] 0.8715910 0.8716357 0.8716802 0.8717246 0.8717687 0.8718127 0.8718565 [71] 0.8719002 0.8719436 0.8719869 0.8720300 0.8720730 0.8721157 0.8721583 [78] 0.8722007 0.8722429 0.8722850 0.8723268 0.8723685 0.8724101 0.8724514 [85] 0.8724926 0.8725335 0.8725744 0.8726150 0.8726554 0.8726957 0.8727358 [92] 0.8727758 0.8728155 0.8728551 0.8728945 0.8729337 0.8729727 0.8730116 [99] 0.8730502 0.8730887 0.8731271 0.8731652 0.8732032 0.8732410 0.8732786 [106] 0.8733160 0.8733532 0.8733903 0.8734272 0.8734639 0.8735005 0.8735368 [113] 0.8735730 0.8736090 0.8736448 0.8736804 0.8737159 0.8737512 0.8737863 [120] 0.8738212 0.8738559 0.8738905 0.8739249 0.8739591 0.8739931 0.8740270 [127] 0.8740606 0.8740941 0.8741274 0.8741605 0.8741935 0.8742262 0.8742588 [134] 0.8742912 0.8743234 0.8743555 0.8743873 0.8744190 0.8744505 0.8744818 [141] 0.8745129 0.8745439 0.8745747 0.8746053 0.8746357 0.8746659 0.8746960 [148] 0.8747258 0.8747555 0.8747850 0.8748143 0.8748435 0.8748724 0.8749012 [155] 0.8749298 0.8749582 0.8749865 0.8750145 0.8750424 0.8750701 0.8750976 [162] 0.8751249 0.8751521 0.8751790 0.8752058 0.8752324 0.8752588 0.8752851 [169] 0.8753111 0.8753370 0.8753627 0.8753882 0.8754135 0.8754387 0.8754636 [176] 0.8754884 0.8755130 0.8755374 0.8755617 0.8755857 0.8756096 0.8756333 [183] 0.8756568 0.8756801 0.8757032 0.8757262 0.8757490 0.8757716 0.8757940 [190] 0.8758162 0.8758383 0.8758601 0.8758818 0.8759033 0.8759246 0.8759457 [197] 0.8759667 0.8759875 0.8760080 0.8760284 0.8760487 0.8760687 0.8760886 [204] 0.8761082 0.8761277 0.8761470 0.8761661 0.8761851 0.8762038 0.8762224 [211] 0.8762408 0.8762590 0.8762770 0.8762949 0.8763126 0.8763300 0.8763473 [218] 0.8763644 0.8763814 0.8763981 0.8764147 0.8764311 0.8764473 0.8764633 [225] 0.8764791 0.8764948 0.8765102 0.8765255 0.8765406 0.8765556 0.8765703 [232] 0.8765849 0.8765992 0.8766134 0.8766274 0.8766412 0.8766549 0.8766684 [239] 0.8766816 0.8766947 0.8767076 0.8767204 0.8767329 0.8767453 0.8767575 [246] 0.8767695 0.8767813 0.8767929 0.8768044 0.8768156 0.8768267 0.8768376 [253] 0.8768484 0.8768589 0.8768693 0.8768794 0.8768894 0.8768992 0.8769089 [260] 0.8769183 0.8769276 0.8769367 0.8769456 0.8769543 0.8769628 0.8769712 [267] 0.8769793 0.8769873 0.8769951 0.8770028 0.8770102 0.8770175 0.8770246 [274] 0.8770315 0.8770382 0.8770447 0.8770511 0.8770572 0.8770632 0.8770691 [281] 0.8770747 0.8770801 0.8770854 0.8770905 0.8770954 0.8771001 0.8771046 [288] 0.8771090 0.8771132 0.8771172 0.8771210 0.8771246 0.8771281 0.8771314 [295] 0.8771345 0.8771374 0.8771401 0.8771426 0.8771450 0.8771472 0.8771492 [302] 0.8771510 0.8771527 0.8771541 0.8771554 0.8771565 0.8771575 0.8771582 [309] 0.8771588 0.8771592 0.8771594 0.8771594 0.8771592 0.8771589 0.8771584 [316] 0.8771577 0.8771568 0.8771558 0.8771545 0.8771531 0.8771515 0.8771497 [323] 0.8771478 0.8771457 0.8771434 0.8771409 0.8771382 0.8771354 0.8771323 [330] 0.8771291 0.8771257 0.8771222 0.8771184 0.8771145 0.8771104 0.8771061 [337] 0.8771017 0.8770970 0.8770922 0.8770872 0.8770821 0.8770767 0.8770712 [344] 0.8770655 0.8770596 0.8770536 0.8770473 0.8770409 0.8770343 0.8770275 [351] 0.8770206 0.8770135 0.8770062 0.8769987 0.8769910 0.8769832 0.8769752 [358] 0.8769670 0.8769586 0.8769501 0.8769414 0.8769325 0.8769234 0.8769142 [365] 0.8769047 0.8768951 0.8768854 0.8768754 0.8768653 0.8768550 0.8768445 [372] 0.8768339 0.8768230 0.8768120 0.8768008 0.8767895 0.8767780 0.8767662 [379] 0.8767544 0.8767423 0.8767301 0.8767177 0.8767051 0.8766923 0.8766794 [386] 0.8766663 0.8766530 0.8766396 0.8766259 0.8766121 0.8765982 0.8765840 [393] 0.8765697 0.8765552 0.8765405 0.8765257 0.8765107 0.8764955 0.8764801 [400] 0.8764646 0.8764489 > mx [1] 0.8771594 > mxli [1] 1.11 > 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/1cltl1194263645.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/25j741194263645.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/3sen11194263646.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/432ls1194263646.tab") > > system("convert tmp/1cltl1194263645.ps tmp/1cltl1194263645.png") > system("convert tmp/25j741194263645.ps tmp/25j741194263645.png") > system("convert tmp/3sen11194263646.ps tmp/3sen11194263646.png") > > > proc.time() user system elapsed 1.064 0.516 1.185