R version 2.7.0 (2008-04-22) 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(15044.5,14944.2,16754.8,14254,15454.9,15644.8,14568.3,12520.2,14803,15873.2,14755.3,12875.1,14291.1,14205.3,15859.4,15258.9,15498.6,15106.5,15023.6,12083,15761.3,16943,15070.3,13659.6,14768.9,14725.1,15998.1,15370.6,14956.9,15469.7,15101.8,11703.7,16283.6,16726.5,14968.9,14861,14583.3,15305.8,17903.9,16379.4,15420.3,17870.5,15912.8,13866.5,17823.2,17872,17420.4,16704.4,15991.2,16583.6,19123.5,17838.7,17209.4,18586.5,16258.1,15141.6,19202.1,17746.5,19090.1,18040.3,17515.5,17751.8,21072.4,17170,19439.5,19795.4,17574.9,16165.4,19464.6,19932.1,19961.2,17343.4,18924.2,18574.1,21350.6,18594.6,19823.1,20844.4,19640.2,17735.4,19813.6,22160,20664.3,17877.4,21211.2,21423.1,21688.7,23243.2,21490.2,22925.8,23184.8,18562.2) > x <- c(101.5,100.7,110.6,96.8,100.0,104.8,86.8,92.0,100.2,106.6,102.1,93.7,97.6,96.9,105.6,102.8,101.7,104.2,92.7,91.9,106.5,112.3,102.8,96.5,101.0,98.9,105.1,103.0,99.0,104.3,94.6,90.4,108.9,111.4,100.8,102.5,98.2,98.7,113.3,104.6,99.3,111.8,97.3,97.7,115.6,111.9,107.0,107.1,100.6,99.2,108.4,103.0,99.8,115.0,90.8,95.9,114.4,108.2,112.6,109.1,105.0,105.0,118.5,103.7,112.5,116.6,96.6,101.9,116.5,119.3,115.4,108.5,111.5,108.8,121.8,109.6,112.2,119.6,104.1,105.3,115.0,124.1,116.8,107.5,115.6,116.2,116.3,119.0,111.9,118.6,106.9,103.2) > #'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.8244327 0.8245381 0.8246433 0.8247483 0.8248531 0.8249577 0.8250622 [8] 0.8251664 0.8252704 0.8253742 0.8254778 0.8255812 0.8256844 0.8257874 [15] 0.8258903 0.8259929 0.8260953 0.8261975 0.8262995 0.8264013 0.8265029 [22] 0.8266043 0.8267055 0.8268065 0.8269073 0.8270079 0.8271084 0.8272086 [29] 0.8273086 0.8274084 0.8275080 0.8276074 0.8277066 0.8278056 0.8279044 [36] 0.8280030 0.8281014 0.8281996 0.8282976 0.8283954 0.8284930 0.8285903 [43] 0.8286875 0.8287845 0.8288813 0.8289779 0.8290743 0.8291705 0.8292665 [50] 0.8293623 0.8294579 0.8295532 0.8296484 0.8297434 0.8298382 0.8299328 [57] 0.8300272 0.8301214 0.8302153 0.8303091 0.8304027 0.8304961 0.8305893 [64] 0.8306822 0.8307750 0.8308676 0.8309600 0.8310521 0.8311441 0.8312359 [71] 0.8313274 0.8314188 0.8315100 0.8316010 0.8316917 0.8317823 0.8318727 [78] 0.8319628 0.8320528 0.8321426 0.8322321 0.8323215 0.8324106 0.8324996 [85] 0.8325884 0.8326769 0.8327653 0.8328534 0.8329414 0.8330292 0.8331167 [92] 0.8332041 0.8332912 0.8333782 0.8334649 0.8335515 0.8336379 0.8337240 [99] 0.8338100 0.8338957 0.8339813 0.8340666 0.8341518 0.8342367 0.8343215 [106] 0.8344060 0.8344904 0.8345745 0.8346585 0.8347422 0.8348258 0.8349091 [113] 0.8349922 0.8350752 0.8351579 0.8352405 0.8353228 0.8354050 0.8354869 [120] 0.8355687 0.8356502 0.8357316 0.8358127 0.8358937 0.8359744 0.8360549 [127] 0.8361353 0.8362154 0.8362954 0.8363751 0.8364547 0.8365340 0.8366132 [134] 0.8366921 0.8367709 0.8368494 0.8369277 0.8370059 0.8370838 0.8371616 [141] 0.8372391 0.8373165 0.8373936 0.8374706 0.8375473 0.8376239 0.8377002 [148] 0.8377764 0.8378523 0.8379281 0.8380036 0.8380790 0.8381542 0.8382291 [155] 0.8383039 0.8383784 0.8384528 0.8385269 0.8386009 0.8386747 0.8387482 [162] 0.8388216 0.8388947 0.8389677 0.8390405 0.8391130 0.8391854 0.8392576 [169] 0.8393296 0.8394013 0.8394729 0.8395443 0.8396155 0.8396864 0.8397572 [176] 0.8398278 0.8398982 0.8399684 0.8400384 0.8401081 0.8401777 0.8402471 [183] 0.8403163 0.8403853 0.8404541 0.8405227 0.8405911 0.8406593 0.8407273 [190] 0.8407951 0.8408628 0.8409302 0.8409974 0.8410644 0.8411312 0.8411978 [197] 0.8412643 0.8413305 0.8413965 0.8414624 0.8415280 0.8415934 0.8416587 [204] 0.8417237 0.8417886 0.8418532 0.8419177 0.8419819 0.8420460 0.8421098 [211] 0.8421735 0.8422370 0.8423002 0.8423633 0.8424262 0.8424889 0.8425514 [218] 0.8426137 0.8426758 0.8427376 0.8427993 0.8428609 0.8429222 0.8429833 [225] 0.8430442 0.8431049 0.8431654 0.8432258 0.8432859 0.8433458 0.8434056 [232] 0.8434651 0.8435245 0.8435836 0.8436426 0.8437013 0.8437599 0.8438183 [239] 0.8438764 0.8439344 0.8439922 0.8440498 0.8441072 0.8441644 0.8442214 [246] 0.8442782 0.8443348 0.8443913 0.8444475 0.8445035 0.8445594 0.8446150 [253] 0.8446704 0.8447257 0.8447808 0.8448356 0.8448903 0.8449448 0.8449991 [260] 0.8450531 0.8451070 0.8451607 0.8452143 0.8452676 0.8453207 0.8453736 [267] 0.8454263 0.8454789 0.8455312 0.8455834 0.8456354 0.8456871 0.8457387 [274] 0.8457901 0.8458413 0.8458923 0.8459431 0.8459937 0.8460441 0.8460943 [281] 0.8461443 0.8461942 0.8462438 0.8462933 0.8463425 0.8463916 0.8464405 [288] 0.8464892 0.8465377 0.8465860 0.8466341 0.8466820 0.8467297 0.8467773 [295] 0.8468246 0.8468717 0.8469187 0.8469655 0.8470121 0.8470584 0.8471046 [302] 0.8471506 0.8471964 0.8472421 0.8472875 0.8473327 0.8473778 0.8474227 [309] 0.8474673 0.8475118 0.8475561 0.8476002 0.8476441 0.8476878 0.8477313 [316] 0.8477747 0.8478178 0.8478608 0.8479035 0.8479461 0.8479885 0.8480307 [323] 0.8480727 0.8481145 0.8481562 0.8481976 0.8482389 0.8482799 0.8483208 [330] 0.8483615 0.8484020 0.8484423 0.8484824 0.8485223 0.8485621 0.8486016 [337] 0.8486410 0.8486802 0.8487192 0.8487580 0.8487966 0.8488350 0.8488733 [344] 0.8489113 0.8489492 0.8489868 0.8490243 0.8490616 0.8490987 0.8491357 [351] 0.8491724 0.8492090 0.8492453 0.8492815 0.8493175 0.8493533 0.8493889 [358] 0.8494243 0.8494596 0.8494946 0.8495295 0.8495642 0.8495987 0.8496330 [365] 0.8496671 0.8497011 0.8497348 0.8497684 0.8498018 0.8498350 0.8498680 [372] 0.8499008 0.8499335 0.8499660 0.8499982 0.8500303 0.8500622 0.8500939 [379] 0.8501255 0.8501568 0.8501880 0.8502190 0.8502498 0.8502804 0.8503108 [386] 0.8503411 0.8503711 0.8504010 0.8504307 0.8504602 0.8504895 0.8505187 [393] 0.8505476 0.8505764 0.8506050 0.8506334 0.8506616 0.8506897 0.8507175 [400] 0.8507452 0.8507727 > mx [1] 0.8507727 > 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/1ozte1229606362.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/2ixer1229606362.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/3bj951229606362.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/4t9xz1229606362.tab") > > system("convert tmp/1ozte1229606362.ps tmp/1ozte1229606362.png") > system("convert tmp/2ixer1229606362.ps tmp/2ixer1229606362.png") > system("convert tmp/3bj951229606362.ps tmp/3bj951229606362.png") > > > proc.time() user system elapsed 1.884 0.859 2.002