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(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) > x <- c(97.3,101,113.2,101,105.7,113.9,86.4,96.5,103.3,114.9,105.8,94.2,98.4,99.4,108.8,112.6,104.4,112.2,81.1,97.1,112.6,113.8,107.8,103.2,103.3,101.2,107.7,110.4,101.9,115.9,89.9,88.6,117.2,123.9,100,103.6,94.1,98.7,119.5,112.7,104.4,124.7,89.1,97,121.6,118.8,114,111.5,97.2,102.5,113.4,109.8,104.9,126.1,80,96.8,117.2,112.3,117.3,111.1,102.2,104.3,122.9,107.6,121.3,131.5,89,104.4,128.9,135.9,133.3,121.3,120.5,120.4,137.9,126.1,133.2,146.6,103.4,117.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.8838623 0.8840293 0.8841957 0.8843614 0.8845264 0.8846908 0.8848545 [8] 0.8850175 0.8851799 0.8853416 0.8855027 0.8856631 0.8858228 0.8859818 [15] 0.8861402 0.8862980 0.8864550 0.8866114 0.8867672 0.8869222 0.8870766 [22] 0.8872303 0.8873834 0.8875357 0.8876874 0.8878385 0.8879888 0.8881385 [29] 0.8882875 0.8884359 0.8885836 0.8887305 0.8888769 0.8890225 0.8891675 [36] 0.8893118 0.8894554 0.8895983 0.8897406 0.8898822 0.8900231 0.8901633 [43] 0.8903028 0.8904417 0.8905799 0.8907174 0.8908542 0.8909903 0.8911258 [50] 0.8912606 0.8913947 0.8915281 0.8916608 0.8917928 0.8919242 0.8920549 [57] 0.8921849 0.8923142 0.8924428 0.8925707 0.8926980 0.8928245 0.8929504 [64] 0.8930756 0.8932001 0.8933239 0.8934470 0.8935694 0.8936912 0.8938122 [71] 0.8939326 0.8940523 0.8941713 0.8942896 0.8944072 0.8945241 0.8946403 [78] 0.8947558 0.8948707 0.8949848 0.8950983 0.8952110 0.8953231 0.8954345 [85] 0.8955452 0.8956552 0.8957644 0.8958730 0.8959810 0.8960882 0.8961947 [92] 0.8963005 0.8964056 0.8965101 0.8966138 0.8967168 0.8968192 0.8969208 [99] 0.8970218 0.8971220 0.8972216 0.8973204 0.8974186 0.8975161 0.8976128 [106] 0.8977089 0.8978043 0.8978989 0.8979929 0.8980862 0.8981788 0.8982707 [113] 0.8983618 0.8984523 0.8985421 0.8986312 0.8987196 0.8988072 0.8988942 [120] 0.8989805 0.8990661 0.8991510 0.8992352 0.8993187 0.8994014 0.8994835 [127] 0.8995649 0.8996456 0.8997256 0.8998049 0.8998834 0.8999613 0.9000385 [134] 0.9001150 0.9001908 0.9002658 0.9003402 0.9004139 0.9004869 0.9005592 [141] 0.9006307 0.9007016 0.9007718 0.9008412 0.9009100 0.9009781 0.9010454 [148] 0.9011121 0.9011781 0.9012433 0.9013079 0.9013718 0.9014349 0.9014974 [155] 0.9015591 0.9016202 0.9016805 0.9017402 0.9017991 0.9018574 0.9019149 [162] 0.9019718 0.9020279 0.9020834 0.9021381 0.9021922 0.9022455 0.9022982 [169] 0.9023501 0.9024014 0.9024519 0.9025018 0.9025509 0.9025993 0.9026471 [176] 0.9026941 0.9027405 0.9027861 0.9028311 0.9028753 0.9029189 0.9029617 [183] 0.9030039 0.9030453 0.9030861 0.9031261 0.9031655 0.9032041 0.9032421 [190] 0.9032793 0.9033159 0.9033518 0.9033869 0.9034214 0.9034552 0.9034882 [197] 0.9035206 0.9035523 0.9035833 0.9036136 0.9036432 0.9036721 0.9037003 [204] 0.9037278 0.9037546 0.9037807 0.9038061 0.9038308 0.9038549 0.9038782 [211] 0.9039008 0.9039228 0.9039440 0.9039646 0.9039845 0.9040036 0.9040221 [218] 0.9040399 0.9040570 0.9040734 0.9040891 0.9041041 0.9041185 0.9041321 [225] 0.9041451 0.9041573 0.9041689 0.9041798 0.9041899 0.9041994 0.9042083 [232] 0.9042164 0.9042238 0.9042306 0.9042366 0.9042420 0.9042467 0.9042507 [239] 0.9042540 0.9042566 0.9042585 0.9042598 0.9042604 0.9042602 0.9042594 [246] 0.9042579 0.9042558 0.9042529 0.9042494 0.9042452 0.9042402 0.9042347 [253] 0.9042284 0.9042214 0.9042138 0.9042055 0.9041965 0.9041868 0.9041765 [260] 0.9041655 0.9041537 0.9041414 0.9041283 0.9041145 0.9041001 0.9040850 [267] 0.9040692 0.9040528 0.9040357 0.9040179 0.9039994 0.9039802 0.9039604 [274] 0.9039399 0.9039187 0.9038969 0.9038744 0.9038512 0.9038273 0.9038028 [281] 0.9037776 0.9037517 0.9037251 0.9036979 0.9036700 0.9036415 0.9036123 [288] 0.9035824 0.9035518 0.9035206 0.9034887 0.9034562 0.9034230 0.9033891 [295] 0.9033545 0.9033193 0.9032834 0.9032469 0.9032097 0.9031718 0.9031333 [302] 0.9030941 0.9030543 0.9030138 0.9029726 0.9029308 0.9028883 0.9028452 [309] 0.9028014 0.9027569 0.9027118 0.9026660 0.9026196 0.9025725 0.9025248 [316] 0.9024764 0.9024274 0.9023777 0.9023273 0.9022763 0.9022247 0.9021724 [323] 0.9021195 0.9020659 0.9020116 0.9019567 0.9019012 0.9018450 0.9017882 [330] 0.9017307 0.9016726 0.9016138 0.9015544 0.9014943 0.9014336 0.9013723 [337] 0.9013103 0.9012476 0.9011844 0.9011205 0.9010559 0.9009907 0.9009249 [344] 0.9008584 0.9007913 0.9007236 0.9006552 0.9005862 0.9005165 0.9004463 [351] 0.9003753 0.9003038 0.9002316 0.9001588 0.9000854 0.9000113 0.8999366 [358] 0.8998612 0.8997853 0.8997087 0.8996315 0.8995536 0.8994751 0.8993961 [365] 0.8993163 0.8992360 0.8991550 0.8990734 0.8989912 0.8989084 0.8988249 [372] 0.8987408 0.8986561 0.8985708 0.8984849 0.8983983 0.8983111 0.8982233 [379] 0.8981349 0.8980459 0.8979563 0.8978660 0.8977752 0.8976837 0.8975916 [386] 0.8974989 0.8974056 0.8973117 0.8972172 0.8971220 0.8970263 0.8969300 [393] 0.8968330 0.8967354 0.8966373 0.8965385 0.8964391 0.8963392 0.8962386 [400] 0.8961374 0.8960356 > mx [1] 0.9042604 > mxli [1] 0.42 > 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/1trwz1194287934.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/2gai11194287934.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/3sfw41194287934.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/404hv1194287935.tab") > > system("convert tmp/1trwz1194287934.ps tmp/1trwz1194287934.png") > system("convert tmp/2gai11194287934.ps tmp/2gai11194287934.png") > system("convert tmp/3sfw41194287934.ps tmp/3sfw41194287934.png") > > > proc.time() user system elapsed 1.061 0.525 1.210