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(141,121,121,117,109,111,106,98,100,105,103,107,104) > x <- c(34,44,37,34,45,50,54,61,62,60,67,70,86) > #'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.8430582 -0.8429488 -0.8428380 -0.8427258 -0.8426123 -0.8424973 [7] -0.8423810 -0.8422632 -0.8421441 -0.8420235 -0.8419015 -0.8417781 [13] -0.8416533 -0.8415270 -0.8413993 -0.8412701 -0.8411395 -0.8410075 [19] -0.8408740 -0.8407390 -0.8406026 -0.8404646 -0.8403252 -0.8401844 [25] -0.8400420 -0.8398981 -0.8397528 -0.8396059 -0.8394575 -0.8393076 [31] -0.8391562 -0.8390032 -0.8388487 -0.8386927 -0.8385352 -0.8383761 [37] -0.8382154 -0.8380532 -0.8378894 -0.8377241 -0.8375571 -0.8373886 [43] -0.8372186 -0.8370469 -0.8368736 -0.8366988 -0.8365223 -0.8363442 [49] -0.8361645 -0.8359832 -0.8358003 -0.8356158 -0.8354296 -0.8352417 [55] -0.8350523 -0.8348612 -0.8346684 -0.8344740 -0.8342779 -0.8340801 [61] -0.8338807 -0.8336796 -0.8334768 -0.8332723 -0.8330661 -0.8328583 [67] -0.8326487 -0.8324374 -0.8322244 -0.8320097 -0.8317933 -0.8315752 [73] -0.8313553 -0.8311337 -0.8309103 -0.8306852 -0.8304584 -0.8302298 [79] -0.8299994 -0.8297673 -0.8295334 -0.8292978 -0.8290604 -0.8288212 [85] -0.8285802 -0.8283374 -0.8280928 -0.8278464 -0.8275983 -0.8273483 [91] -0.8270965 -0.8268429 -0.8265875 -0.8263303 -0.8260712 -0.8258103 [97] -0.8255475 -0.8252830 -0.8250166 -0.8247483 -0.8244782 -0.8242062 [103] -0.8239324 -0.8236567 -0.8233791 -0.8230997 -0.8228183 -0.8225352 [109] -0.8222501 -0.8219631 -0.8216743 -0.8213835 -0.8210909 -0.8207963 [115] -0.8204999 -0.8202015 -0.8199013 -0.8195991 -0.8192950 -0.8189889 [121] -0.8186810 -0.8183711 -0.8180593 -0.8177455 -0.8174298 -0.8171122 [127] -0.8167926 -0.8164711 -0.8161476 -0.8158222 -0.8154948 -0.8151654 [133] -0.8148341 -0.8145008 -0.8141656 -0.8138283 -0.8134891 -0.8131479 [139] -0.8128048 -0.8124596 -0.8121125 -0.8117634 -0.8114122 -0.8110591 [145] -0.8107040 -0.8103469 -0.8099878 -0.8096267 -0.8092635 -0.8088984 [151] -0.8085313 -0.8081621 -0.8077909 -0.8074177 -0.8070425 -0.8066653 [157] -0.8062861 -0.8059048 -0.8055215 -0.8051361 -0.8047488 -0.8043594 [163] -0.8039679 -0.8035745 -0.8031789 -0.8027814 -0.8023818 -0.8019802 [169] -0.8015765 -0.8011708 -0.8007630 -0.8003532 -0.7999413 -0.7995274 [175] -0.7991115 -0.7986934 -0.7982734 -0.7978512 -0.7974271 -0.7970008 [181] -0.7965725 -0.7961422 -0.7957098 -0.7952753 -0.7948388 -0.7944002 [187] -0.7939596 -0.7935169 -0.7930721 -0.7926253 -0.7921764 -0.7917255 [193] -0.7912724 -0.7908174 -0.7903602 -0.7899010 -0.7894398 -0.7889765 [199] -0.7885111 -0.7880437 -0.7875742 -0.7871026 -0.7866290 -0.7861533 [205] -0.7856756 -0.7851958 -0.7847139 -0.7842300 -0.7837441 -0.7832560 [211] -0.7827660 -0.7822738 -0.7817797 -0.7812834 -0.7807852 -0.7802848 [217] -0.7797825 -0.7792781 -0.7787716 -0.7782631 -0.7777525 -0.7772400 [223] -0.7767253 -0.7762087 -0.7756900 -0.7751693 -0.7746465 -0.7741217 [229] -0.7735949 -0.7730661 -0.7725352 -0.7720024 -0.7714675 -0.7709306 [235] -0.7703916 -0.7698507 -0.7693078 -0.7687628 -0.7682159 -0.7676669 [241] -0.7671160 -0.7665630 -0.7660081 -0.7654512 -0.7648923 -0.7643314 [247] -0.7637686 -0.7632037 -0.7626369 -0.7620681 -0.7614974 -0.7609247 [253] -0.7603500 -0.7597734 -0.7591948 -0.7586143 -0.7580319 -0.7574475 [259] -0.7568612 -0.7562729 -0.7556827 -0.7550906 -0.7544966 -0.7539006 [265] -0.7533028 -0.7527030 -0.7521014 -0.7514978 -0.7508924 -0.7502850 [271] -0.7496758 -0.7490647 -0.7484517 -0.7478369 -0.7472202 -0.7466017 [277] -0.7459813 -0.7453590 -0.7447349 -0.7441090 -0.7434812 -0.7428516 [283] -0.7422202 -0.7415870 -0.7409520 -0.7403152 -0.7396765 -0.7390361 [289] -0.7383939 -0.7377499 -0.7371041 -0.7364566 -0.7358073 -0.7351563 [295] -0.7345035 -0.7338490 -0.7331927 -0.7325347 -0.7318750 -0.7312135 [301] -0.7305504 -0.7298855 -0.7292190 -0.7285507 -0.7278808 -0.7272092 [307] -0.7265359 -0.7258610 -0.7251844 -0.7245062 -0.7238263 -0.7231448 [313] -0.7224617 -0.7217769 -0.7210905 -0.7204026 -0.7197130 -0.7190219 [319] -0.7183291 -0.7176348 -0.7169390 -0.7162415 -0.7155425 -0.7148420 [325] -0.7141400 -0.7134364 -0.7127313 -0.7120247 -0.7113166 -0.7106070 [331] -0.7098959 -0.7091833 -0.7084693 -0.7077538 -0.7070368 -0.7063185 [337] -0.7055986 -0.7048774 -0.7041547 -0.7034307 -0.7027052 -0.7019783 [343] -0.7012501 -0.7005204 -0.6997895 -0.6990571 -0.6983234 -0.6975884 [349] -0.6968521 -0.6961144 -0.6953754 -0.6946351 -0.6938936 -0.6931507 [355] -0.6924066 -0.6916612 -0.6909146 -0.6901667 -0.6894175 -0.6886672 [361] -0.6879156 -0.6871629 -0.6864089 -0.6856537 -0.6848974 -0.6841399 [367] -0.6833813 -0.6826215 -0.6818605 -0.6810984 -0.6803353 -0.6795710 [373] -0.6788056 -0.6780391 -0.6772715 -0.6765029 -0.6757332 -0.6749625 [379] -0.6741907 -0.6734179 -0.6726441 -0.6718692 -0.6710934 -0.6703166 [385] -0.6695388 -0.6687601 -0.6679804 -0.6671997 -0.6664181 -0.6656356 [391] -0.6648522 -0.6640678 -0.6632826 -0.6624965 -0.6617095 -0.6609217 [397] -0.6601330 -0.6593434 -0.6585531 -0.6577619 -0.6569699 > mx [1] 0.8430582 > 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/1qmac1226580013.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/29g1h1226580014.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/3gml81226580014.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/4ml2q1226580014.tab") > > system("convert tmp/1qmac1226580013.ps tmp/1qmac1226580013.png") > system("convert tmp/29g1h1226580014.ps tmp/29g1h1226580014.png") > system("convert tmp/3gml81226580014.ps tmp/3gml81226580014.png") > > > proc.time() user system elapsed 1.171 0.784 1.275