R version 2.8.1 (2008-12-22) Copyright (C) 2008 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(1.4,1.2,1,1.7,2.4,2,2.1,2,1.8,2.7,2.3,1.9,2,2.3,2.8,2.4,2.3,2.7,2.7,2.9,3,2.2,2.3,2.8,2.8,2.8,2.2,2.6,2.8,2.5,2.4,2.3,1.9,1.7,2,2.1,1.7,1.8,1.8,1.8,1.3,1.3,1.3,1.2,1.4,2.2,2.9,3.1,3.5,3.6,4.4,4.1,5.1,5.8,5.9,5.4,5.5,4.8,3.2,2.7,2.1,1.9,0.6,0.7,-0.2,-1,-1.7,-0.7,-1) > x <- c(2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2.21,2.25,2.25,2.45,2.5,2.5,2.64,2.75,2.93,3,3.17,3.25,3.39,3.5,3.5,3.65,3.75,3.75,3.9,4,4,4,4,4,4,4,4,4,4,4,4,4.18,4.25,4.25,3.97,3.42,2.75,2.31,2,1.66,1.31,1.09,1,1,1,1) > #'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.7087298 0.7088729 0.7090141 0.7091532 0.7092902 0.7094252 0.7095581 [8] 0.7096888 0.7098174 0.7099438 0.7100679 0.7101898 0.7103095 0.7104268 [15] 0.7105419 0.7106545 0.7107648 0.7108727 0.7109781 0.7110811 0.7111816 [22] 0.7112795 0.7113749 0.7114678 0.7115580 0.7116456 0.7117306 0.7118128 [29] 0.7118924 0.7119693 0.7120433 0.7121146 0.7121831 0.7122487 0.7123115 [36] 0.7123714 0.7124283 0.7124823 0.7125334 0.7125814 0.7126265 0.7126685 [43] 0.7127074 0.7127432 0.7127759 0.7128055 0.7128319 0.7128552 0.7128752 [50] 0.7128920 0.7129055 0.7129157 0.7129227 0.7129263 0.7129266 0.7129235 [57] 0.7129170 0.7129071 0.7128938 0.7128770 0.7128568 0.7128330 0.7128058 [64] 0.7127750 0.7127407 0.7127028 0.7126614 0.7126163 0.7125676 0.7125153 [71] 0.7124593 0.7123997 0.7123364 0.7122694 0.7121987 0.7121242 0.7120460 [78] 0.7119641 0.7118784 0.7117889 0.7116956 0.7115986 0.7114977 0.7113929 [85] 0.7112844 0.7111720 0.7110557 0.7109356 0.7108116 0.7106838 0.7105520 [92] 0.7104164 0.7102768 0.7101334 0.7099860 0.7098347 0.7096795 0.7095204 [99] 0.7093573 0.7091904 0.7090194 0.7088446 0.7086658 0.7084831 0.7082964 [106] 0.7081058 0.7079113 0.7077128 0.7075105 0.7073041 0.7070939 0.7068797 [113] 0.7066616 0.7064397 0.7062138 0.7059840 0.7057503 0.7055127 0.7052712 [120] 0.7050259 0.7047767 0.7045237 0.7042668 0.7040061 0.7037416 0.7034732 [127] 0.7032011 0.7029252 0.7026455 0.7023620 0.7020748 0.7017839 0.7014893 [134] 0.7011910 0.7008890 0.7005833 0.7002740 0.6999610 0.6996445 0.6993243 [141] 0.6990006 0.6986733 0.6983425 0.6980082 0.6976704 0.6973292 0.6969845 [148] 0.6966364 0.6962848 0.6959299 0.6955717 0.6952101 0.6948453 0.6944771 [155] 0.6941058 0.6937311 0.6933533 0.6929724 0.6925883 0.6922011 0.6918108 [162] 0.6914174 0.6910210 0.6906217 0.6902193 0.6898141 0.6894059 0.6889948 [169] 0.6885810 0.6881643 0.6877448 0.6873226 0.6868976 0.6864700 0.6860398 [176] 0.6856069 0.6851714 0.6847334 0.6842929 0.6838499 0.6834045 0.6829567 [183] 0.6825064 0.6820539 0.6815990 0.6811419 0.6806826 0.6802210 0.6797573 [190] 0.6792915 0.6788236 0.6783537 0.6778817 0.6774078 0.6769319 0.6764541 [197] 0.6759745 0.6754930 0.6750097 0.6745247 0.6740380 0.6735496 0.6730596 [204] 0.6725680 0.6720748 0.6715800 0.6710838 0.6705862 0.6700871 0.6695867 [211] 0.6690849 0.6685818 0.6680775 0.6675719 0.6670652 0.6665573 0.6660483 [218] 0.6655382 0.6650271 0.6645150 0.6640019 0.6634879 0.6629730 0.6624573 [225] 0.6619408 0.6614235 0.6609054 0.6603866 0.6598672 0.6593472 0.6588265 [232] 0.6583053 0.6577836 0.6572614 0.6567387 0.6562156 0.6556922 0.6551684 [239] 0.6546443 0.6541199 0.6535952 0.6530704 0.6525454 0.6520202 0.6514949 [246] 0.6509696 0.6504442 0.6499188 0.6493935 0.6488682 0.6483429 0.6478178 [253] 0.6472929 0.6467681 0.6462436 0.6457193 0.6451953 0.6446716 0.6441482 [260] 0.6436252 0.6431026 0.6425804 0.6420586 0.6415374 0.6410167 0.6404965 [267] 0.6399768 0.6394578 0.6389394 0.6384216 0.6379045 0.6373882 0.6368725 [274] 0.6363576 0.6358435 0.6353302 0.6348177 0.6343061 0.6337954 0.6332855 [281] 0.6327766 0.6322687 0.6317617 0.6312557 0.6307508 0.6302469 0.6297440 [288] 0.6292423 0.6287416 0.6282421 0.6277437 0.6272465 0.6267505 0.6262557 [295] 0.6257622 0.6252699 0.6247788 0.6242891 0.6238006 0.6233135 0.6228277 [302] 0.6223433 0.6218603 0.6213786 0.6208984 0.6204196 0.6199423 0.6194664 [309] 0.6189919 0.6185190 0.6180476 0.6175777 0.6171093 0.6166425 0.6161773 [316] 0.6157136 0.6152515 0.6147910 0.6143322 0.6138749 0.6134193 0.6129654 [323] 0.6125131 0.6120625 0.6116136 0.6111664 0.6107209 0.6102771 0.6098351 [330] 0.6093948 0.6089562 0.6085194 0.6080844 0.6076512 0.6072197 0.6067900 [337] 0.6063622 0.6059361 0.6055119 0.6050895 0.6046689 0.6042502 0.6038333 [344] 0.6034183 0.6030051 0.6025938 0.6021844 0.6017769 0.6013712 0.6009674 [351] 0.6005656 0.6001656 0.5997675 0.5993714 0.5989771 0.5985848 0.5981944 [358] 0.5978059 0.5974194 0.5970348 0.5966521 0.5962714 0.5958926 0.5955157 [365] 0.5951408 0.5947679 0.5943969 0.5940278 0.5936607 0.5932956 0.5929324 [372] 0.5925712 0.5922120 0.5918547 0.5914994 0.5911460 0.5907946 0.5904452 [379] 0.5900977 0.5897522 0.5894087 0.5890671 0.5887275 0.5883899 0.5880542 [386] 0.5877205 0.5873887 0.5870589 0.5867311 0.5864052 0.5860813 0.5857593 [393] 0.5854393 0.5851213 0.5848052 0.5844910 0.5841788 0.5838685 0.5835602 [400] 0.5832538 0.5829494 > mx [1] 0.7129266 > mxli [1] -1.46 > 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/rcomp/tmp/1iv5i1257707298.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/rcomp/tmp/2nnus1257707298.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/rcomp/tmp/3ksmu1257707298.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/47ucv1257707298.tab") > > system("convert tmp/1iv5i1257707298.ps tmp/1iv5i1257707298.png") > system("convert tmp/2nnus1257707298.ps tmp/2nnus1257707298.png") > system("convert tmp/3ksmu1257707298.ps tmp/3ksmu1257707298.png") > > > proc.time() user system elapsed 0.89 0.72 1.54