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(124.9,132,151.4,108.9,121.3,123.4,90.3,79.3,117.2,116.9,120.8,96.1,100.8,105.3,116.1,112.8,114.5,117.2,77.1,80.1,120.3,133.4,109.4,93.2,91.2,99.2,108.2,101.5,106.9,104.4,77.9,60,99.5,95,105.6,102.5,93.3,97.3,127,111.7,96.4,133,72.2,95.8,124.1,127.6,110.7,104.6,112.7,115.3,139.4,119,97.4,154,81.5,88.8,127.7,105.1,114.9,106.4,104.5,121.6,141.4,99,126.7,134.1,81.3,88.6,132.7,132.9,134.4,103.7,119.7,115,132.9,108.5,113.9,142.9,95.2,93) > x <- c(106.7,110.2,125.9,100.1,106.4,114.8,81.3,87,104.2,108,105,94.5,92,95.9,108.8,103.4,102.1,110.1,83.2,82.7,106.8,113.7,102.5,96.6,92.1,95.6,102.3,98.6,98.2,104.5,84,73.8,103.9,106,97.2,102.6,89,93.8,116.7,106.8,98.5,118.7,90,91.9,113.3,113.1,104.1,108.7,96.7,101,116.9,105.8,99,129.4,83,88.9,115.9,104.2,113.4,112.2,100.8,107.3,126.6,102.9,117.9,128.8,87.5,93.8,122.7,126.2,124.6,116.7,115.2,111.1,129.9,113.3,118.5,133.5,102.1,102.4) > #'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.8870703 0.8872094 0.8873480 0.8874859 0.8876232 0.8877600 0.8878961 [8] 0.8880316 0.8881664 0.8883007 0.8884344 0.8885674 0.8886999 0.8888317 [15] 0.8889629 0.8890935 0.8892235 0.8893528 0.8894816 0.8896098 0.8897373 [22] 0.8898642 0.8899905 0.8901162 0.8902413 0.8903657 0.8904896 0.8906128 [29] 0.8907354 0.8908574 0.8909788 0.8910996 0.8912197 0.8913393 0.8914582 [36] 0.8915765 0.8916942 0.8918112 0.8919277 0.8920435 0.8921587 0.8922733 [43] 0.8923873 0.8925007 0.8926134 0.8927255 0.8928370 0.8929479 0.8930582 [50] 0.8931678 0.8932769 0.8933853 0.8934931 0.8936002 0.8937068 0.8938127 [57] 0.8939180 0.8940227 0.8941268 0.8942302 0.8943331 0.8944353 0.8945369 [64] 0.8946378 0.8947382 0.8948379 0.8949370 0.8950355 0.8951334 0.8952306 [71] 0.8953272 0.8954232 0.8955186 0.8956134 0.8957075 0.8958010 0.8958939 [78] 0.8959862 0.8960778 0.8961689 0.8962593 0.8963490 0.8964382 0.8965268 [85] 0.8966147 0.8967020 0.8967887 0.8968747 0.8969601 0.8970450 0.8971292 [92] 0.8972127 0.8972957 0.8973780 0.8974597 0.8975408 0.8976213 0.8977011 [99] 0.8977803 0.8978589 0.8979369 0.8980143 0.8980910 0.8981671 0.8982426 [106] 0.8983175 0.8983917 0.8984654 0.8985384 0.8986108 0.8986825 0.8987537 [113] 0.8988242 0.8988941 0.8989634 0.8990321 0.8991001 0.8991676 0.8992344 [120] 0.8993006 0.8993662 0.8994311 0.8994954 0.8995592 0.8996223 0.8996847 [127] 0.8997466 0.8998078 0.8998685 0.8999285 0.8999878 0.9000466 0.9001048 [134] 0.9001623 0.9002192 0.9002755 0.9003312 0.9003863 0.9004407 0.9004945 [141] 0.9005478 0.9006004 0.9006523 0.9007037 0.9007545 0.9008046 0.9008541 [148] 0.9009030 0.9009513 0.9009990 0.9010461 0.9010925 0.9011384 0.9011836 [155] 0.9012282 0.9012722 0.9013156 0.9013584 0.9014005 0.9014421 0.9014830 [162] 0.9015233 0.9015631 0.9016022 0.9016407 0.9016785 0.9017158 0.9017525 [169] 0.9017885 0.9018240 0.9018588 0.9018931 0.9019267 0.9019597 0.9019921 [176] 0.9020239 0.9020551 0.9020857 0.9021156 0.9021450 0.9021738 0.9022020 [183] 0.9022295 0.9022565 0.9022828 0.9023086 0.9023337 0.9023582 0.9023822 [190] 0.9024055 0.9024282 0.9024504 0.9024719 0.9024928 0.9025131 0.9025329 [197] 0.9025520 0.9025705 0.9025884 0.9026058 0.9026225 0.9026386 0.9026542 [204] 0.9026691 0.9026834 0.9026972 0.9027103 0.9027229 0.9027348 0.9027462 [211] 0.9027570 0.9027671 0.9027767 0.9027857 0.9027941 0.9028019 0.9028091 [218] 0.9028157 0.9028218 0.9028272 0.9028321 0.9028363 0.9028400 0.9028431 [225] 0.9028456 0.9028475 0.9028488 0.9028495 0.9028497 0.9028492 0.9028482 [232] 0.9028466 0.9028444 0.9028416 0.9028383 0.9028343 0.9028298 0.9028247 [239] 0.9028190 0.9028128 0.9028059 0.9027985 0.9027905 0.9027819 0.9027727 [246] 0.9027630 0.9027527 0.9027418 0.9027303 0.9027183 0.9027057 0.9026925 [253] 0.9026787 0.9026644 0.9026495 0.9026340 0.9026179 0.9026013 0.9025841 [260] 0.9025663 0.9025480 0.9025291 0.9025096 0.9024896 0.9024690 0.9024478 [267] 0.9024261 0.9024038 0.9023809 0.9023575 0.9023335 0.9023089 0.9022838 [274] 0.9022581 0.9022319 0.9022051 0.9021777 0.9021498 0.9021213 0.9020923 [281] 0.9020627 0.9020325 0.9020018 0.9019706 0.9019388 0.9019064 0.9018735 [288] 0.9018400 0.9018060 0.9017714 0.9017362 0.9017006 0.9016643 0.9016276 [295] 0.9015902 0.9015524 0.9015139 0.9014750 0.9014354 0.9013954 0.9013548 [302] 0.9013136 0.9012720 0.9012297 0.9011869 0.9011436 0.9010998 0.9010554 [309] 0.9010105 0.9009650 0.9009190 0.9008724 0.9008254 0.9007777 0.9007296 [316] 0.9006809 0.9006317 0.9005819 0.9005317 0.9004808 0.9004295 0.9003776 [323] 0.9003252 0.9002723 0.9002188 0.9001649 0.9001104 0.9000553 0.8999998 [330] 0.8999437 0.8998871 0.8998300 0.8997723 0.8997141 0.8996554 0.8995962 [337] 0.8995365 0.8994763 0.8994155 0.8993542 0.8992924 0.8992301 0.8991673 [344] 0.8991040 0.8990401 0.8989758 0.8989109 0.8988455 0.8987796 0.8987132 [351] 0.8986463 0.8985789 0.8985110 0.8984425 0.8983736 0.8983042 0.8982342 [358] 0.8981638 0.8980929 0.8980214 0.8979495 0.8978770 0.8978041 0.8977307 [365] 0.8976567 0.8975823 0.8975074 0.8974320 0.8973560 0.8972796 0.8972027 [372] 0.8971254 0.8970475 0.8969691 0.8968903 0.8968109 0.8967311 0.8966508 [379] 0.8965700 0.8964887 0.8964069 0.8963246 0.8962419 0.8961587 0.8960750 [386] 0.8959908 0.8959062 0.8958210 0.8957354 0.8956493 0.8955628 0.8954757 [393] 0.8953882 0.8953002 0.8952118 0.8951229 0.8950335 0.8949436 0.8948533 [400] 0.8947625 0.8946712 > mx [1] 0.9028497 > mxli [1] 0.28 > 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/16ab81194296123.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/242o31194296123.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/3qasg1194296123.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/4vhil1194296123.tab") > > system("convert tmp/16ab81194296123.ps tmp/16ab81194296123.png") > system("convert tmp/242o31194296123.ps tmp/242o31194296123.png") > system("convert tmp/3qasg1194296123.ps tmp/3qasg1194296123.png") > > > proc.time() user system elapsed 1.050 0.497 1.402