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(96,86,82,92,99,101,102,100,101,100,99,97,97,97,96,92,91,87,82,89,91,90,87,89,95,85,94,94,97,99,97,96,94,100,96,98,98,94,93,94,94,97,98,95,89,89,89,90,86,92,91,95,99,98,95,96,94,98,98,98,98,102,101,92,99,101,99,102,102,101,99,98,98) > x <- c(87,75,74,91,101,103,106,102,105,105,100,95,96,98,99,92,84,81,72,89,96,91,88,90,98,87,100,100,104,107,105,102,98,106,97,101,100,93,94,96,96,98,102,95,85,84,82,87,77,90,90,94,97,96,93,93,93,97,100,95,97,103,102,93,99,100,97,104,102,103,100,90,90) > #'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.8667424 0.8668292 0.8669157 0.8670019 0.8670877 0.8671733 0.8672585 [8] 0.8673434 0.8674280 0.8675122 0.8675962 0.8676798 0.8677631 0.8678460 [15] 0.8679287 0.8680110 0.8680930 0.8681747 0.8682560 0.8683370 0.8684177 [22] 0.8684981 0.8685782 0.8686579 0.8687373 0.8688164 0.8688951 0.8689736 [29] 0.8690517 0.8691295 0.8692069 0.8692841 0.8693609 0.8694373 0.8695135 [36] 0.8695893 0.8696648 0.8697400 0.8698149 0.8698894 0.8699636 0.8700375 [43] 0.8701110 0.8701843 0.8702572 0.8703297 0.8704020 0.8704739 0.8705455 [50] 0.8706168 0.8706877 0.8707583 0.8708286 0.8708986 0.8709682 0.8710375 [57] 0.8711065 0.8711751 0.8712434 0.8713114 0.8713791 0.8714464 0.8715134 [64] 0.8715801 0.8716465 0.8717125 0.8717782 0.8718436 0.8719086 0.8719733 [71] 0.8720377 0.8721018 0.8721655 0.8722289 0.8722920 0.8723547 0.8724171 [78] 0.8724792 0.8725410 0.8726024 0.8726635 0.8727243 0.8727848 0.8728449 [85] 0.8729047 0.8729641 0.8730232 0.8730821 0.8731405 0.8731987 0.8732565 [92] 0.8733140 0.8733711 0.8734280 0.8734845 0.8735406 0.8735965 0.8736520 [99] 0.8737072 0.8737620 0.8738166 0.8738708 0.8739246 0.8739782 0.8740314 [106] 0.8740843 0.8741368 0.8741891 0.8742410 0.8742925 0.8743438 0.8743947 [113] 0.8744453 0.8744955 0.8745454 0.8745950 0.8746443 0.8746933 0.8747419 [120] 0.8747901 0.8748381 0.8748857 0.8749330 0.8749800 0.8750266 0.8750730 [127] 0.8751189 0.8751646 0.8752099 0.8752549 0.8752996 0.8753440 0.8753880 [134] 0.8754317 0.8754750 0.8755181 0.8755608 0.8756032 0.8756452 0.8756869 [141] 0.8757283 0.8757694 0.8758102 0.8758506 0.8758907 0.8759304 0.8759699 [148] 0.8760090 0.8760478 0.8760862 0.8761243 0.8761622 0.8761996 0.8762368 [155] 0.8762736 0.8763101 0.8763463 0.8763821 0.8764177 0.8764528 0.8764877 [162] 0.8765223 0.8765565 0.8765904 0.8766239 0.8766572 0.8766901 0.8767227 [169] 0.8767550 0.8767869 0.8768185 0.8768498 0.8768808 0.8769115 0.8769418 [176] 0.8769718 0.8770015 0.8770308 0.8770598 0.8770886 0.8771169 0.8771450 [183] 0.8771727 0.8772002 0.8772272 0.8772540 0.8772805 0.8773066 0.8773324 [190] 0.8773579 0.8773830 0.8774079 0.8774324 0.8774566 0.8774805 0.8775040 [197] 0.8775272 0.8775501 0.8775727 0.8775950 0.8776170 0.8776386 0.8776599 [204] 0.8776809 0.8777016 0.8777219 0.8777419 0.8777616 0.8777810 0.8778001 [211] 0.8778189 0.8778373 0.8778554 0.8778732 0.8778907 0.8779079 0.8779247 [218] 0.8779413 0.8779575 0.8779734 0.8779890 0.8780042 0.8780192 0.8780338 [225] 0.8780481 0.8780621 0.8780758 0.8780892 0.8781022 0.8781149 0.8781274 [232] 0.8781395 0.8781513 0.8781628 0.8781739 0.8781848 0.8781953 0.8782055 [239] 0.8782154 0.8782250 0.8782343 0.8782433 0.8782520 0.8782603 0.8782684 [246] 0.8782761 0.8782835 0.8782906 0.8782974 0.8783039 0.8783100 0.8783159 [253] 0.8783215 0.8783267 0.8783316 0.8783362 0.8783406 0.8783446 0.8783483 [260] 0.8783516 0.8783547 0.8783575 0.8783600 0.8783621 0.8783640 0.8783655 [267] 0.8783667 0.8783677 0.8783683 0.8783686 0.8783686 0.8783683 0.8783677 [274] 0.8783668 0.8783656 0.8783641 0.8783623 0.8783601 0.8783577 0.8783550 [281] 0.8783519 0.8783486 0.8783450 0.8783410 0.8783368 0.8783322 0.8783274 [288] 0.8783222 0.8783168 0.8783110 0.8783050 0.8782986 0.8782920 0.8782850 [295] 0.8782778 0.8782702 0.8782624 0.8782542 0.8782458 0.8782370 0.8782280 [302] 0.8782187 0.8782090 0.8781991 0.8781889 0.8781783 0.8781675 0.8781564 [309] 0.8781450 0.8781333 0.8781213 0.8781090 0.8780964 0.8780835 0.8780703 [316] 0.8780568 0.8780431 0.8780290 0.8780146 0.8780000 0.8779851 0.8779698 [323] 0.8779543 0.8779385 0.8779224 0.8779060 0.8778893 0.8778724 0.8778551 [330] 0.8778375 0.8778197 0.8778016 0.8777832 0.8777645 0.8777455 0.8777262 [337] 0.8777066 0.8776868 0.8776666 0.8776462 0.8776255 0.8776045 0.8775832 [344] 0.8775616 0.8775398 0.8775176 0.8774952 0.8774725 0.8774495 0.8774263 [351] 0.8774027 0.8773789 0.8773548 0.8773304 0.8773057 0.8772807 0.8772555 [358] 0.8772300 0.8772042 0.8771781 0.8771517 0.8771251 0.8770982 0.8770710 [365] 0.8770435 0.8770157 0.8769877 0.8769594 0.8769308 0.8769020 0.8768728 [372] 0.8768434 0.8768137 0.8767838 0.8767536 0.8767230 0.8766923 0.8766612 [379] 0.8766299 0.8765983 0.8765664 0.8765343 0.8765018 0.8764691 0.8764362 [386] 0.8764030 0.8763695 0.8763357 0.8763016 0.8762673 0.8762327 0.8761979 [393] 0.8761628 0.8761274 0.8760917 0.8760558 0.8760196 0.8759832 0.8759465 [400] 0.8759095 0.8758722 > mx [1] 0.8783686 > mxli [1] 0.7 > 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/1yg391194009325.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/218e11194009325.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/3m2cq1194009326.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/416gt1194009326.tab") > > system("convert tmp/1yg391194009325.ps tmp/1yg391194009325.png") > system("convert tmp/218e11194009325.ps tmp/218e11194009325.png") > system("convert tmp/3m2cq1194009326.ps tmp/3m2cq1194009326.png") > > > proc.time() user system elapsed 1.858 0.820 1.963