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(93.5,94.7,112.9,99.2,105.6,113,83.1,81.1,96.9,104.3,97.7,102.6,89.9,96,112.7,107.1,106.2,121,101.2,83.2,105.1,113.3,99.1,100.3,93.5,98.8,106.2,98.3,102.1,117.1,101.5,80.5,105.9,109.5,97.2,114.5,93.5,100.9,121.1,116.5,109.3,118.1,108.3,105.4,116.2,111.2,105.8,122.7,99.5,107.9,124.6,115,110.3,132.7,99.7,96.5,118.7,112.9,130.5,137.9,115,116.8,140.9,120.7,134.2,147.3,112.4,107.1,128.4,137.7,135,151,137.4,132.4,161.3,139.8,146,154.6,142.1,120.5) > #'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.7975381 0.7976615 0.7977842 0.7979061 0.7980273 0.7981477 0.7982674 [8] 0.7983863 0.7985044 0.7986218 0.7987384 0.7988542 0.7989693 0.7990836 [15] 0.7991971 0.7993099 0.7994219 0.7995332 0.7996437 0.7997534 0.7998623 [22] 0.7999705 0.8000779 0.8001845 0.8002904 0.8003955 0.8004998 0.8006033 [29] 0.8007061 0.8008081 0.8009093 0.8010097 0.8011094 0.8012083 0.8013064 [36] 0.8014037 0.8015003 0.8015960 0.8016910 0.8017853 0.8018787 0.8019713 [43] 0.8020632 0.8021543 0.8022446 0.8023341 0.8024228 0.8025108 0.8025980 [50] 0.8026843 0.8027699 0.8028548 0.8029388 0.8030220 0.8031045 0.8031861 [57] 0.8032670 0.8033471 0.8034264 0.8035049 0.8035826 0.8036596 0.8037357 [64] 0.8038111 0.8038856 0.8039594 0.8040324 0.8041046 0.8041760 0.8042466 [71] 0.8043164 0.8043855 0.8044537 0.8045211 0.8045878 0.8046537 0.8047187 [78] 0.8047830 0.8048465 0.8049092 0.8049711 0.8050322 0.8050925 0.8051520 [85] 0.8052107 0.8052686 0.8053257 0.8053821 0.8054376 0.8054924 0.8055463 [92] 0.8055995 0.8056518 0.8057034 0.8057542 0.8058042 0.8058533 0.8059017 [99] 0.8059493 0.8059961 0.8060421 0.8060873 0.8061317 0.8061754 0.8062182 [106] 0.8062602 0.8063015 0.8063419 0.8063816 0.8064204 0.8064585 0.8064957 [113] 0.8065322 0.8065679 0.8066028 0.8066369 0.8066702 0.8067027 0.8067344 [120] 0.8067653 0.8067954 0.8068248 0.8068533 0.8068810 0.8069080 0.8069342 [127] 0.8069595 0.8069841 0.8070079 0.8070309 0.8070531 0.8070746 0.8070952 [134] 0.8071150 0.8071341 0.8071523 0.8071698 0.8071865 0.8072024 0.8072175 [141] 0.8072318 0.8072454 0.8072581 0.8072701 0.8072813 0.8072917 0.8073013 [148] 0.8073101 0.8073181 0.8073254 0.8073318 0.8073375 0.8073424 0.8073466 [155] 0.8073499 0.8073524 0.8073542 0.8073552 0.8073554 0.8073549 0.8073535 [162] 0.8073514 0.8073485 0.8073448 0.8073404 0.8073352 0.8073292 0.8073224 [169] 0.8073148 0.8073065 0.8072974 0.8072875 0.8072769 0.8072654 0.8072532 [176] 0.8072403 0.8072265 0.8072120 0.8071968 0.8071807 0.8071639 0.8071463 [183] 0.8071280 0.8071089 0.8070890 0.8070684 0.8070470 0.8070248 0.8070019 [190] 0.8069782 0.8069537 0.8069285 0.8069025 0.8068758 0.8068483 0.8068201 [197] 0.8067911 0.8067613 0.8067308 0.8066995 0.8066675 0.8066347 0.8066012 [204] 0.8065669 0.8065318 0.8064961 0.8064595 0.8064222 0.8063842 0.8063454 [211] 0.8063059 0.8062657 0.8062246 0.8061829 0.8061404 0.8060971 0.8060532 [218] 0.8060084 0.8059630 0.8059168 0.8058698 0.8058222 0.8057738 0.8057246 [225] 0.8056747 0.8056241 0.8055728 0.8055207 0.8054679 0.8054144 0.8053601 [232] 0.8053051 0.8052494 0.8051929 0.8051358 0.8050779 0.8050193 0.8049599 [239] 0.8048999 0.8048391 0.8047776 0.8047154 0.8046524 0.8045888 0.8045244 [246] 0.8044593 0.8043935 0.8043270 0.8042598 0.8041919 0.8041233 0.8040539 [253] 0.8039839 0.8039131 0.8038417 0.8037695 0.8036966 0.8036231 0.8035488 [260] 0.8034738 0.8033982 0.8033218 0.8032447 0.8031670 0.8030885 0.8030094 [267] 0.8029296 0.8028490 0.8027678 0.8026859 0.8026033 0.8025201 0.8024361 [274] 0.8023514 0.8022661 0.8021801 0.8020934 0.8020060 0.8019180 0.8018293 [281] 0.8017399 0.8016498 0.8015590 0.8014676 0.8013755 0.8012827 0.8011893 [288] 0.8010952 0.8010004 0.8009050 0.8008089 0.8007121 0.8006147 0.8005166 [295] 0.8004179 0.8003185 0.8002184 0.8001177 0.8000163 0.7999143 0.7998116 [302] 0.7997083 0.7996043 0.7994997 0.7993944 0.7992885 0.7991819 0.7990747 [309] 0.7989668 0.7988583 0.7987492 0.7986394 0.7985290 0.7984180 0.7983063 [316] 0.7981940 0.7980810 0.7979674 0.7978532 0.7977384 0.7976229 0.7975068 [323] 0.7973901 0.7972728 0.7971548 0.7970363 0.7969171 0.7967972 0.7966768 [330] 0.7965557 0.7964341 0.7963118 0.7961889 0.7960654 0.7959413 0.7958166 [337] 0.7956913 0.7955653 0.7954388 0.7953117 0.7951839 0.7950556 0.7949267 [344] 0.7947971 0.7946670 0.7945363 0.7944050 0.7942731 0.7941406 0.7940075 [351] 0.7938738 0.7937395 0.7936047 0.7934693 0.7933333 0.7931967 0.7930595 [358] 0.7929217 0.7927834 0.7926445 0.7925050 0.7923650 0.7922244 0.7920832 [365] 0.7919414 0.7917991 0.7916562 0.7915127 0.7913687 0.7912241 0.7910790 [372] 0.7909333 0.7907870 0.7906402 0.7904928 0.7903449 0.7901964 0.7900474 [379] 0.7898978 0.7897477 0.7895970 0.7894458 0.7892940 0.7891417 0.7889889 [386] 0.7888355 0.7886816 0.7885271 0.7883721 0.7882166 0.7880605 0.7879039 [393] 0.7877468 0.7875891 0.7874310 0.7872723 0.7871130 0.7869533 0.7867930 [400] 0.7866322 0.7864709 > mx [1] 0.8073554 > 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/1t2sj1194286485.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/2aw361194286485.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/3o1xh1194286485.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/4haa51194286486.tab") > > system("convert tmp/1t2sj1194286485.ps tmp/1t2sj1194286485.png") > system("convert tmp/2aw361194286485.ps tmp/2aw361194286485.png") > system("convert tmp/3o1xh1194286485.ps tmp/3o1xh1194286485.png") > > > proc.time() user system elapsed 1.054 0.527 1.227