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(0.8833,0.87,0.8758,0.8858,0.917,0.9554,0.9922,0.9778,0.9808,0.9811,1.0014,1.0183,1.0622,1.0773,1.0807,1.0848,1.1582,1.1663,1.1372,1.1139,1.1222,1.1692,1.1702,1.2286,1.2613,1.2646,1.2262,1.1985,1.2007,1.2138,1.2266,1.2176,1.2218,1.249,1.2991,1.3408,1.3119,1.3014,1.3201,1.2938,1.2694,1.2165,1.2037,1.2292,1.2256,1.2015,1.1786,1.1856,1.2103,1.1938,1.202,1.2271,1.277,1.265,1.2684,1.2811,1.2727,1.2611,1.2881,1.3213,1.2999,1.3074,1.3242,1.3516,1.3511,1.3419,1.3716,1.3622,1.3896,1.4227) > x <- c(18.33,22.6,24.9,24.8,23.8,25.1,26,27.4,27.3,24.3,28.4,24.4,30.3,31.5,29.8,25.3,25.6,26.7,27.4,28.6,26.3,28.5,28.4,29.4,30.3,29.6,32.1,32.4,36.3,34.6,36.3,40.3,40.4,45.4,39,35.7,40.2,41.7,49.1,49.6,47,52,53.1,57.8,57.9,54.6,51.3,52.7,58.5,56.6,57.9,64.4,65.1,64.6,68.9,68.8,59.3,55,55.4,58,50.8,54.6,58.6,63.6,64.5,66.9,71.9,68.7,74.2,75.8) > #'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.8407412 0.8407483 0.8407526 0.8407540 0.8407526 0.8407484 0.8407414 [8] 0.8407317 0.8407191 0.8407038 0.8406856 0.8406648 0.8406412 0.8406148 [15] 0.8405857 0.8405539 0.8405193 0.8404821 0.8404422 0.8403995 0.8403542 [22] 0.8403062 0.8402556 0.8402023 0.8401463 0.8400878 0.8400266 0.8399627 [29] 0.8398963 0.8398273 0.8397557 0.8396815 0.8396047 0.8395254 0.8394435 [36] 0.8393591 0.8392722 0.8391827 0.8390908 0.8389963 0.8388993 0.8387999 [43] 0.8386980 0.8385936 0.8384868 0.8383775 0.8382658 0.8381517 0.8380352 [50] 0.8379162 0.8377949 0.8376712 0.8375451 0.8374167 0.8372859 0.8371528 [57] 0.8370173 0.8368795 0.8367394 0.8365971 0.8364524 0.8363054 0.8361562 [64] 0.8360047 0.8358510 0.8356951 0.8355369 0.8353765 0.8352139 0.8350491 [71] 0.8348821 0.8347129 0.8345416 0.8343681 0.8341925 0.8340148 0.8338349 [78] 0.8336529 0.8334688 0.8332827 0.8330944 0.8329041 0.8327118 0.8325173 [85] 0.8323209 0.8321224 0.8319219 0.8317194 0.8315150 0.8313085 0.8311000 [92] 0.8308896 0.8306773 0.8304630 0.8302468 0.8300286 0.8298086 0.8295866 [99] 0.8293628 0.8291371 0.8289095 0.8286801 0.8284488 0.8282157 0.8279807 [106] 0.8277440 0.8275054 0.8272651 0.8270230 0.8267791 0.8265334 0.8262860 [113] 0.8260368 0.8257860 0.8255334 0.8252791 0.8250230 0.8247654 0.8245060 [120] 0.8242449 0.8239823 0.8237179 0.8234519 0.8231843 0.8229151 0.8226443 [127] 0.8223719 0.8220979 0.8218223 0.8215452 0.8212665 0.8209862 0.8207045 [134] 0.8204212 0.8201363 0.8198500 0.8195622 0.8192729 0.8189822 0.8186899 [141] 0.8183963 0.8181011 0.8178046 0.8175066 0.8172072 0.8169064 0.8166042 [148] 0.8163006 0.8159957 0.8156893 0.8153817 0.8150726 0.8147623 0.8144506 [155] 0.8141376 0.8138233 0.8135077 0.8131908 0.8128726 0.8125531 0.8122324 [162] 0.8119105 0.8115873 0.8112629 0.8109372 0.8106103 0.8102823 0.8099530 [169] 0.8096226 0.8092909 0.8089581 0.8086242 0.8082891 0.8079528 0.8076155 [176] 0.8072770 0.8069374 0.8065967 0.8062549 0.8059120 0.8055680 0.8052230 [183] 0.8048769 0.8045297 0.8041815 0.8038323 0.8034820 0.8031308 0.8027785 [190] 0.8024252 0.8020709 0.8017157 0.8013595 0.8010023 0.8006441 0.8002850 [197] 0.7999250 0.7995640 0.7992021 0.7988393 0.7984756 0.7981110 0.7977455 [204] 0.7973791 0.7970118 0.7966436 0.7962746 0.7959048 0.7955341 0.7951626 [211] 0.7947902 0.7944170 0.7940431 0.7936683 0.7932927 0.7929163 0.7925391 [218] 0.7921612 0.7917825 0.7914030 0.7910228 0.7906419 0.7902602 0.7898777 [225] 0.7894946 0.7891107 0.7887262 0.7883409 0.7879549 0.7875683 0.7871810 [232] 0.7867930 0.7864043 0.7860150 0.7856250 0.7852344 0.7848432 0.7844513 [239] 0.7840588 0.7836657 0.7832720 0.7828777 0.7824828 0.7820872 0.7816912 [246] 0.7812945 0.7808973 0.7804995 0.7801011 0.7797022 0.7793028 0.7789028 [253] 0.7785023 0.7781013 0.7776998 0.7772977 0.7768952 0.7764921 0.7760886 [260] 0.7756846 0.7752801 0.7748751 0.7744696 0.7740637 0.7736574 0.7732506 [267] 0.7728433 0.7724356 0.7720275 0.7716190 0.7712100 0.7708006 0.7703909 [274] 0.7699807 0.7695701 0.7691591 0.7687478 0.7683361 0.7679240 0.7675115 [281] 0.7670987 0.7666855 0.7662719 0.7658581 0.7654438 0.7650293 0.7646144 [288] 0.7641992 0.7637837 0.7633678 0.7629517 0.7625352 0.7621185 0.7617014 [295] 0.7612841 0.7608665 0.7604486 0.7600305 0.7596120 0.7591933 0.7587744 [302] 0.7583552 0.7579358 0.7575161 0.7570962 0.7566760 0.7562556 0.7558350 [309] 0.7554142 0.7549932 0.7545719 0.7541505 0.7537288 0.7533070 0.7528850 [316] 0.7524628 0.7520404 0.7516178 0.7511950 0.7507721 0.7503491 0.7499258 [323] 0.7495024 0.7490789 0.7486552 0.7482314 0.7478074 0.7473833 0.7469591 [330] 0.7465348 0.7461103 0.7456857 0.7452610 0.7448362 0.7444113 0.7439863 [337] 0.7435612 0.7431360 0.7427107 0.7422854 0.7418599 0.7414344 0.7410088 [344] 0.7405831 0.7401574 0.7397316 0.7393058 0.7388799 0.7384540 0.7380280 [351] 0.7376019 0.7371759 0.7367498 0.7363236 0.7358975 0.7354713 0.7350451 [358] 0.7346189 0.7341926 0.7337664 0.7333402 0.7329139 0.7324877 0.7320614 [365] 0.7316352 0.7312090 0.7307827 0.7303566 0.7299304 0.7295042 0.7290781 [372] 0.7286520 0.7282260 0.7278000 0.7273740 0.7269480 0.7265222 0.7260963 [379] 0.7256705 0.7252448 0.7248192 0.7243935 0.7239680 0.7235425 0.7231171 [386] 0.7226918 0.7222666 0.7218414 0.7214163 0.7209913 0.7205664 0.7201416 [393] 0.7197169 0.7192922 0.7188677 0.7184433 0.7180190 0.7175948 0.7171707 [400] 0.7167467 0.7163228 > mx [1] 0.840754 > mxli [1] -1.97 > 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/1kqkm1197039059.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/2q3xe1197039059.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/37us41197039059.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/4kltg1197039059.tab") > > system("convert tmp/1kqkm1197039059.ps tmp/1kqkm1197039059.png") > system("convert tmp/2q3xe1197039059.ps tmp/2q3xe1197039059.png") > system("convert tmp/37us41197039059.ps tmp/37us41197039059.png") > > > proc.time() user system elapsed 1.093 0.542 1.319