R version 2.8.0 (2008-10-20) 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(6.6,6.6,6.3,6,6,6.4,6.9,7.1,7.1,6.7,6.4,6.4,6.6,6.8,6.7,6.1,5.9,6.2,6.4,6.7,6.9,6.9,6.8,6.7,6.4,6.5,6.7,6.9,7.4,7.7,7.9,8,8,7.8,7.6,7.6,7.6,7.7,7.8,7.8,8,8.1,8.2,8.3,8.2,8,7.8,8,8.5,8.6,8.5,8,7.8,7.9,8.3,8.3,8.1,7.7,7.6,8.2) > x <- c(8.2,8.3,8.1,7.4,7.3,7.7,8,8,7.7,6.9,6.6,6.9,7.5,7.9,7.7,6.5,6.1,6.4,6.8,7.1,7.3,7.2,7,7,7,7.3,7.5,7.2,7.7,8,7.9,8,8,7.9,7.9,8,8.1,8.1,8.2,8,8.3,8.5,8.6,8.7,8.7,8.5,8.4,8.5,8.7,8.7,8.6,7.9,8.1,8.2,8.5,8.6,8.5,8.3,8.2,8.7) > #'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.8023437 0.8024782 0.8026125 0.8027466 0.8028804 0.8030141 0.8031476 [8] 0.8032808 0.8034139 0.8035468 0.8036794 0.8038119 0.8039441 0.8040762 [15] 0.8042080 0.8043397 0.8044711 0.8046024 0.8047334 0.8048642 0.8049949 [22] 0.8051253 0.8052556 0.8053856 0.8055154 0.8056450 0.8057745 0.8059037 [29] 0.8060327 0.8061615 0.8062901 0.8064185 0.8065467 0.8066747 0.8068025 [36] 0.8069301 0.8070575 0.8071847 0.8073117 0.8074384 0.8075650 0.8076914 [43] 0.8078176 0.8079435 0.8080693 0.8081949 0.8083202 0.8084454 0.8085703 [50] 0.8086951 0.8088196 0.8089440 0.8090681 0.8091920 0.8093158 0.8094393 [57] 0.8095626 0.8096857 0.8098086 0.8099313 0.8100538 0.8101761 0.8102982 [64] 0.8104201 0.8105418 0.8106633 0.8107846 0.8109057 0.8110265 0.8111472 [71] 0.8112677 0.8113879 0.8115080 0.8116279 0.8117475 0.8118670 0.8119862 [78] 0.8121052 0.8122241 0.8123427 0.8124611 0.8125793 0.8126973 0.8128152 [85] 0.8129328 0.8130502 0.8131674 0.8132844 0.8134012 0.8135177 0.8136341 [92] 0.8137503 0.8138663 0.8139820 0.8140976 0.8142130 0.8143281 0.8144431 [99] 0.8145578 0.8146724 0.8147867 0.8149008 0.8150148 0.8151285 0.8152420 [106] 0.8153553 0.8154684 0.8155813 0.8156941 0.8158066 0.8159188 0.8160309 [113] 0.8161428 0.8162545 0.8163660 0.8164773 0.8165883 0.8166992 0.8168099 [120] 0.8169203 0.8170306 0.8171406 0.8172505 0.8173601 0.8174695 0.8175788 [127] 0.8176878 0.8177966 0.8179052 0.8180136 0.8181218 0.8182299 0.8183377 [134] 0.8184453 0.8185526 0.8186598 0.8187668 0.8188736 0.8189802 0.8190866 [141] 0.8191927 0.8192987 0.8194045 0.8195100 0.8196154 0.8197205 0.8198255 [148] 0.8199302 0.8200347 0.8201391 0.8202432 0.8203471 0.8204509 0.8205544 [155] 0.8206577 0.8207608 0.8208637 0.8209664 0.8210689 0.8211712 0.8212733 [162] 0.8213752 0.8214769 0.8215784 0.8216797 0.8217807 0.8218816 0.8219823 [169] 0.8220827 0.8221830 0.8222831 0.8223829 0.8224826 0.8225820 0.8226813 [176] 0.8227803 0.8228792 0.8229778 0.8230762 0.8231745 0.8232725 0.8233703 [183] 0.8234680 0.8235654 0.8236626 0.8237596 0.8238564 0.8239530 0.8240495 [190] 0.8241457 0.8242417 0.8243375 0.8244331 0.8245285 0.8246237 0.8247187 [197] 0.8248134 0.8249080 0.8250024 0.8250966 0.8251906 0.8252844 0.8253779 [204] 0.8254713 0.8255645 0.8256575 0.8257502 0.8258428 0.8259352 0.8260274 [211] 0.8261193 0.8262111 0.8263026 0.8263940 0.8264852 0.8265761 0.8266669 [218] 0.8267574 0.8268478 0.8269379 0.8270279 0.8271177 0.8272072 0.8272966 [225] 0.8273857 0.8274747 0.8275634 0.8276519 0.8277403 0.8278284 0.8279164 [232] 0.8280041 0.8280917 0.8281790 0.8282662 0.8283531 0.8284399 0.8285264 [239] 0.8286128 0.8286989 0.8287848 0.8288706 0.8289561 0.8290415 0.8291266 [246] 0.8292116 0.8292963 0.8293809 0.8294652 0.8295494 0.8296333 0.8297171 [253] 0.8298006 0.8298840 0.8299672 0.8300501 0.8301329 0.8302154 0.8302978 [260] 0.8303799 0.8304619 0.8305437 0.8306252 0.8307066 0.8307878 0.8308688 [267] 0.8309495 0.8310301 0.8311105 0.8311907 0.8312707 0.8313504 0.8314300 [274] 0.8315094 0.8315886 0.8316676 0.8317464 0.8318250 0.8319034 0.8319816 [281] 0.8320596 0.8321375 0.8322151 0.8322925 0.8323697 0.8324467 0.8325236 [288] 0.8326002 0.8326766 0.8327529 0.8328289 0.8329048 0.8329804 0.8330559 [295] 0.8331312 0.8332062 0.8332811 0.8333558 0.8334303 0.8335045 0.8335786 [302] 0.8336525 0.8337262 0.8337997 0.8338730 0.8339462 0.8340191 0.8340918 [309] 0.8341643 0.8342367 0.8343088 0.8343808 0.8344525 0.8345241 0.8345954 [316] 0.8346666 0.8347376 0.8348084 0.8348789 0.8349493 0.8350195 0.8350896 [323] 0.8351594 0.8352290 0.8352984 0.8353677 0.8354367 0.8355056 0.8355742 [330] 0.8356427 0.8357109 0.8357790 0.8358469 0.8359146 0.8359821 0.8360494 [337] 0.8361165 0.8361835 0.8362502 0.8363167 0.8363831 0.8364493 0.8365152 [344] 0.8365810 0.8366466 0.8367120 0.8367772 0.8368422 0.8369070 0.8369717 [351] 0.8370361 0.8371004 0.8371644 0.8372283 0.8372920 0.8373555 0.8374188 [358] 0.8374819 0.8375448 0.8376075 0.8376701 0.8377324 0.8377946 0.8378566 [365] 0.8379183 0.8379799 0.8380413 0.8381026 0.8381636 0.8382244 0.8382851 [372] 0.8383455 0.8384058 0.8384659 0.8385258 0.8385855 0.8386450 0.8387044 [379] 0.8387635 0.8388225 0.8388813 0.8389398 0.8389982 0.8390564 0.8391145 [386] 0.8391723 0.8392300 0.8392874 0.8393447 0.8394018 0.8394587 0.8395154 [393] 0.8395719 0.8396283 0.8396845 0.8397404 0.8397962 0.8398518 0.8399072 [400] 0.8399625 0.8400175 > mx [1] 0.8400175 > mxli [1] 2 > 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/freestat/rcomp/tmp/1ietr1257944121.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/freestat/rcomp/tmp/2ezfr1257944121.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/freestat/rcomp/tmp/3nesj1257944121.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/42ace1257944121.tab") > > system("convert tmp/1ietr1257944121.ps tmp/1ietr1257944121.png") > system("convert tmp/2ezfr1257944121.ps tmp/2ezfr1257944121.png") > system("convert tmp/3nesj1257944121.ps tmp/3nesj1257944121.png") > > > proc.time() user system elapsed 1.226 0.842 1.407