R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(79.8,83.4,113.6,112.9,104,109.9,99,106.3,128.9,111.1,102.9,130,87,87.5,117.6,103.4,110.8,112.6,102.5,112.4,135.6,105.1,127.7,137,91,90.5,122.4,123.3,124.3,120,118.1,119,142.7,123.6,129.6,151.6,110.4,99.2,130.5,136.2,129.7,128,121.6,135.8,143.8,147.5,136.2,156.6,123.3,104.5,139.8,136.5,112.1,118.5,94.4,102.3,111.4,99.2,87.8,115.8) > x <- c(109.87,95.74,123.06,123.39,120.28,115.33,110.4,114.49,132.03,123.16,118.82,128.32,112.24,104.53,132.57,122.52,131.8,124.55,120.96,122.6,145.52,118.57,134.25,136.7,121.37,111.63,134.42,137.65,137.86,119.77,130.69,128.28,147.45,128.42,136.9,143.95,135.64,122.48,136.83,153.04,142.71,123.46,144.37,146.15,147.61,158.51,147.4,165.05,154.64,126.2,157.36,154.15,123.21,113.07,110.45,113.57,122.44,114.93,111.85,126.04) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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.8760623 0.8761664 0.8762698 0.8763726 0.8764748 0.8765764 0.8766774 [8] 0.8767778 0.8768776 0.8769768 0.8770754 0.8771735 0.8772709 0.8773677 [15] 0.8774639 0.8775595 0.8776545 0.8777489 0.8778427 0.8779359 0.8780285 [22] 0.8781205 0.8782119 0.8783028 0.8783930 0.8784826 0.8785717 0.8786601 [29] 0.8787480 0.8788352 0.8789219 0.8790079 0.8790934 0.8791783 0.8792626 [36] 0.8793463 0.8794294 0.8795119 0.8795938 0.8796752 0.8797559 0.8798361 [43] 0.8799156 0.8799946 0.8800730 0.8801508 0.8802280 0.8803046 0.8803807 [50] 0.8804562 0.8805310 0.8806053 0.8806790 0.8807521 0.8808247 0.8808966 [57] 0.8809680 0.8810388 0.8811090 0.8811786 0.8812476 0.8813161 0.8813840 [64] 0.8814513 0.8815180 0.8815842 0.8816497 0.8817147 0.8817791 0.8818430 [71] 0.8819062 0.8819689 0.8820310 0.8820925 0.8821535 0.8822139 0.8822737 [78] 0.8823329 0.8823916 0.8824497 0.8825072 0.8825641 0.8826205 0.8826763 [85] 0.8827316 0.8827862 0.8828403 0.8828939 0.8829468 0.8829992 0.8830511 [92] 0.8831023 0.8831530 0.8832032 0.8832528 0.8833018 0.8833502 0.8833981 [99] 0.8834454 0.8834922 0.8835384 0.8835840 0.8836291 0.8836736 0.8837176 [106] 0.8837610 0.8838038 0.8838461 0.8838878 0.8839290 0.8839696 0.8840096 [113] 0.8840491 0.8840881 0.8841265 0.8841643 0.8842016 0.8842384 0.8842745 [120] 0.8843102 0.8843453 0.8843798 0.8844138 0.8844472 0.8844801 0.8845125 [127] 0.8845442 0.8845755 0.8846062 0.8846364 0.8846660 0.8846950 0.8847236 [134] 0.8847515 0.8847790 0.8848059 0.8848322 0.8848581 0.8848833 0.8849081 [141] 0.8849323 0.8849559 0.8849790 0.8850016 0.8850237 0.8850452 0.8850662 [148] 0.8850866 0.8851065 0.8851259 0.8851447 0.8851630 0.8851808 0.8851981 [155] 0.8852148 0.8852310 0.8852466 0.8852618 0.8852764 0.8852904 0.8853040 [162] 0.8853170 0.8853295 0.8853415 0.8853529 0.8853638 0.8853742 0.8853841 [169] 0.8853935 0.8854023 0.8854106 0.8854184 0.8854257 0.8854324 0.8854387 [176] 0.8854444 0.8854496 0.8854543 0.8854584 0.8854621 0.8854652 0.8854679 [183] 0.8854700 0.8854716 0.8854727 0.8854732 0.8854733 0.8854729 0.8854719 [190] 0.8854705 0.8854685 0.8854660 0.8854630 0.8854595 0.8854556 0.8854511 [197] 0.8854461 0.8854406 0.8854345 0.8854280 0.8854210 0.8854135 0.8854055 [204] 0.8853970 0.8853880 0.8853785 0.8853685 0.8853580 0.8853470 0.8853355 [211] 0.8853235 0.8853110 0.8852980 0.8852845 0.8852706 0.8852561 0.8852412 [218] 0.8852257 0.8852098 0.8851934 0.8851765 0.8851591 0.8851412 0.8851229 [225] 0.8851040 0.8850847 0.8850649 0.8850446 0.8850238 0.8850025 0.8849808 [232] 0.8849585 0.8849358 0.8849126 0.8848890 0.8848648 0.8848402 0.8848151 [239] 0.8847895 0.8847635 0.8847370 0.8847100 0.8846825 0.8846545 0.8846261 [246] 0.8845972 0.8845679 0.8845380 0.8845077 0.8844770 0.8844457 0.8844140 [253] 0.8843819 0.8843492 0.8843161 0.8842825 0.8842485 0.8842140 0.8841791 [260] 0.8841436 0.8841078 0.8840714 0.8840346 0.8839974 0.8839597 0.8839215 [267] 0.8838828 0.8838438 0.8838042 0.8837642 0.8837238 0.8836829 0.8836415 [274] 0.8835997 0.8835574 0.8835147 0.8834715 0.8834279 0.8833839 0.8833394 [281] 0.8832944 0.8832490 0.8832031 0.8831568 0.8831101 0.8830629 0.8830153 [288] 0.8829672 0.8829187 0.8828698 0.8828204 0.8827705 0.8827203 0.8826696 [295] 0.8826184 0.8825668 0.8825148 0.8824623 0.8824095 0.8823561 0.8823024 [302] 0.8822482 0.8821936 0.8821385 0.8820830 0.8820271 0.8819708 0.8819140 [309] 0.8818568 0.8817992 0.8817411 0.8816826 0.8816237 0.8815644 0.8815046 [316] 0.8814445 0.8813839 0.8813228 0.8812614 0.8811995 0.8811373 0.8810746 [323] 0.8810114 0.8809479 0.8808839 0.8808196 0.8807548 0.8806896 0.8806240 [330] 0.8805580 0.8804915 0.8804247 0.8803574 0.8802898 0.8802217 0.8801532 [337] 0.8800843 0.8800150 0.8799453 0.8798752 0.8798046 0.8797337 0.8796624 [344] 0.8795906 0.8795185 0.8794460 0.8793730 0.8792997 0.8792259 0.8791518 [351] 0.8790773 0.8790023 0.8789270 0.8788513 0.8787751 0.8786986 0.8786217 [358] 0.8785444 0.8784667 0.8783886 0.8783101 0.8782312 0.8781520 0.8780723 [365] 0.8779923 0.8779118 0.8778310 0.8777498 0.8776682 0.8775863 0.8775039 [372] 0.8774211 0.8773380 0.8772545 0.8771706 0.8770863 0.8770017 0.8769167 [379] 0.8768312 0.8767455 0.8766593 0.8765727 0.8764858 0.8763985 0.8763109 [386] 0.8762228 0.8761344 0.8760456 0.8759564 0.8758669 0.8757770 0.8756867 [393] 0.8755961 0.8755051 0.8754137 0.8753220 0.8752298 0.8751374 0.8750445 [400] 0.8749513 0.8748577 > mx [1] 0.8854733 > mxli [1] -0.14 > 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/14kk41257679889.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/2vndp1257679889.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/3120r1257679889.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/4499a1257679889.tab") > > system("convert tmp/14kk41257679889.ps tmp/14kk41257679889.png") > system("convert tmp/2vndp1257679889.ps tmp/2vndp1257679889.png") > system("convert tmp/3120r1257679889.ps tmp/3120r1257679889.png") > > > proc.time() user system elapsed 0.791 0.514 0.972