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(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) > x <- 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) > #'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.8703703 0.8704544 0.8705380 0.8706213 0.8707042 0.8707868 0.8708690 [8] 0.8709509 0.8710324 0.8711135 0.8711943 0.8712747 0.8713547 0.8714344 [15] 0.8715137 0.8715927 0.8716713 0.8717495 0.8718273 0.8719048 0.8719819 [22] 0.8720587 0.8721350 0.8722110 0.8722867 0.8723619 0.8724368 0.8725113 [29] 0.8725855 0.8726593 0.8727327 0.8728057 0.8728783 0.8729506 0.8730225 [36] 0.8730940 0.8731651 0.8732359 0.8733063 0.8733762 0.8734459 0.8735151 [43] 0.8735840 0.8736524 0.8737205 0.8737882 0.8738555 0.8739225 0.8739890 [50] 0.8740552 0.8741210 0.8741863 0.8742513 0.8743160 0.8743802 0.8744440 [57] 0.8745075 0.8745705 0.8746332 0.8746955 0.8747573 0.8748188 0.8748799 [64] 0.8749406 0.8750009 0.8750608 0.8751203 0.8751795 0.8752382 0.8752965 [71] 0.8753544 0.8754119 0.8754691 0.8755258 0.8755821 0.8756381 0.8756936 [78] 0.8757487 0.8758034 0.8758577 0.8759117 0.8759652 0.8760183 0.8760710 [85] 0.8761233 0.8761752 0.8762266 0.8762777 0.8763284 0.8763786 0.8764285 [92] 0.8764779 0.8765270 0.8765756 0.8766238 0.8766716 0.8767190 0.8767659 [99] 0.8768125 0.8768586 0.8769044 0.8769497 0.8769946 0.8770391 0.8770831 [106] 0.8771268 0.8771700 0.8772128 0.8772552 0.8772972 0.8773388 0.8773799 [113] 0.8774206 0.8774609 0.8775008 0.8775403 0.8775793 0.8776179 0.8776561 [120] 0.8776939 0.8777312 0.8777681 0.8778046 0.8778407 0.8778763 0.8779116 [127] 0.8779463 0.8779807 0.8780146 0.8780481 0.8780812 0.8781139 0.8781461 [134] 0.8781779 0.8782092 0.8782401 0.8782706 0.8783007 0.8783303 0.8783595 [141] 0.8783883 0.8784166 0.8784445 0.8784719 0.8784989 0.8785255 0.8785517 [148] 0.8785774 0.8786027 0.8786275 0.8786519 0.8786759 0.8786994 0.8787225 [155] 0.8787451 0.8787673 0.8787891 0.8788104 0.8788313 0.8788517 0.8788717 [162] 0.8788913 0.8789104 0.8789291 0.8789473 0.8789651 0.8789824 0.8789993 [169] 0.8790157 0.8790317 0.8790473 0.8790624 0.8790771 0.8790913 0.8791051 [176] 0.8791184 0.8791312 0.8791437 0.8791556 0.8791672 0.8791782 0.8791888 [183] 0.8791990 0.8792087 0.8792180 0.8792268 0.8792352 0.8792431 0.8792506 [190] 0.8792576 0.8792641 0.8792702 0.8792759 0.8792810 0.8792858 0.8792901 [197] 0.8792939 0.8792972 0.8793002 0.8793026 0.8793046 0.8793062 0.8793072 [204] 0.8793079 0.8793080 0.8793077 0.8793070 0.8793058 0.8793041 0.8793020 [211] 0.8792994 0.8792963 0.8792928 0.8792888 0.8792844 0.8792795 0.8792742 [218] 0.8792683 0.8792620 0.8792553 0.8792481 0.8792404 0.8792323 0.8792237 [225] 0.8792146 0.8792051 0.8791951 0.8791846 0.8791737 0.8791623 0.8791505 [232] 0.8791381 0.8791253 0.8791121 0.8790984 0.8790842 0.8790695 0.8790544 [239] 0.8790388 0.8790227 0.8790062 0.8789892 0.8789717 0.8789538 0.8789354 [246] 0.8789165 0.8788972 0.8788774 0.8788571 0.8788363 0.8788151 0.8787934 [253] 0.8787712 0.8787486 0.8787255 0.8787019 0.8786778 0.8786533 0.8786283 [260] 0.8786028 0.8785769 0.8785504 0.8785235 0.8784962 0.8784683 0.8784400 [267] 0.8784112 0.8783820 0.8783522 0.8783220 0.8782913 0.8782602 0.8782285 [274] 0.8781964 0.8781638 0.8781308 0.8780972 0.8780632 0.8780287 0.8779938 [281] 0.8779583 0.8779224 0.8778860 0.8778491 0.8778118 0.8777739 0.8777356 [288] 0.8776969 0.8776576 0.8776179 0.8775776 0.8775370 0.8774958 0.8774541 [295] 0.8774120 0.8773694 0.8773263 0.8772828 0.8772387 0.8771942 0.8771492 [302] 0.8771037 0.8770578 0.8770113 0.8769644 0.8769170 0.8768692 0.8768208 [309] 0.8767720 0.8767227 0.8766729 0.8766226 0.8765719 0.8765206 0.8764689 [316] 0.8764167 0.8763641 0.8763109 0.8762573 0.8762032 0.8761486 0.8760935 [323] 0.8760380 0.8759819 0.8759254 0.8758684 0.8758110 0.8757530 0.8756946 [330] 0.8756357 0.8755763 0.8755164 0.8754560 0.8753952 0.8753339 0.8752721 [337] 0.8752098 0.8751471 0.8750838 0.8750201 0.8749559 0.8748912 0.8748261 [344] 0.8747604 0.8746943 0.8746277 0.8745606 0.8744930 0.8744250 0.8743565 [351] 0.8742875 0.8742180 0.8741480 0.8740776 0.8740066 0.8739352 0.8738633 [358] 0.8737910 0.8737181 0.8736448 0.8735710 0.8734967 0.8734219 0.8733467 [365] 0.8732709 0.8731947 0.8731180 0.8730409 0.8729632 0.8728851 0.8728065 [372] 0.8727274 0.8726478 0.8725678 0.8724873 0.8724063 0.8723248 0.8722428 [379] 0.8721604 0.8720775 0.8719941 0.8719102 0.8718259 0.8717410 0.8716557 [386] 0.8715699 0.8714837 0.8713969 0.8713097 0.8712220 0.8711338 0.8710452 [393] 0.8709560 0.8708664 0.8707764 0.8706858 0.8705948 0.8705033 0.8704113 [400] 0.8703188 0.8702259 > mx [1] 0.879308 > mxli [1] 0.04 > 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/1pq5s1194263420.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/2aj4p1194263421.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/34u7i1194263421.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/4c5gi1194263421.tab") > > system("convert tmp/1pq5s1194263420.ps tmp/1pq5s1194263420.png") > system("convert tmp/2aj4p1194263421.ps tmp/2aj4p1194263421.png") > system("convert tmp/34u7i1194263421.ps tmp/34u7i1194263421.png") > > > proc.time() user system elapsed 1.072 0.524 1.209