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(25.60,23.70,22.00,21.30,20.70,20.40,20.30,20.40,19.80,19.50,23.10,23.50,23.50,22.90,21.90,21.50,20.50,20.20,19.40,19.20,18.80,18.80,22.60,23.30,23.00,21.40,19.90,18.80,18.60,18.40,18.60,19.90,19.20,18.40,21.10,20.50,19.10,18.10,17.00,17.10,17.40,16.80,15.30,14.30,13.40,15.30,22.10,23.70,22.20,19.50,16.60,17.30,19.80,21.20,21.50,20.60,19.10,19.60,23.50,24.00) > x <- c(161,149,139,135,130,127,122,117,112,113,149,157,157,147,137,132,125,123,117,114,111,112,144,150,149,134,123,116,117,111,105,102,95,93,124,130,124,115,106,105,105,101,95,93,84,87,116,120,117,109,105,107,109,109,108,107,99,103,131,137) > #'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.8533339 0.8534086 0.8534825 0.8535558 0.8536285 0.8537004 0.8537717 [8] 0.8538423 0.8539123 0.8539815 0.8540501 0.8541180 0.8541853 0.8542519 [15] 0.8543177 0.8543830 0.8544475 0.8545114 0.8545746 0.8546371 0.8546989 [22] 0.8547601 0.8548206 0.8548804 0.8549395 0.8549980 0.8550558 0.8551129 [29] 0.8551693 0.8552250 0.8552801 0.8553345 0.8553882 0.8554412 0.8554936 [36] 0.8555453 0.8555963 0.8556466 0.8556963 0.8557452 0.8557935 0.8558411 [43] 0.8558881 0.8559343 0.8559799 0.8560248 0.8560690 0.8561126 0.8561555 [50] 0.8561976 0.8562392 0.8562800 0.8563201 0.8563596 0.8563984 0.8564365 [57] 0.8564740 0.8565107 0.8565468 0.8565822 0.8566170 0.8566510 0.8566844 [64] 0.8567171 0.8567491 0.8567805 0.8568112 0.8568412 0.8568705 0.8568991 [71] 0.8569271 0.8569544 0.8569810 0.8570069 0.8570322 0.8570568 0.8570807 [78] 0.8571039 0.8571265 0.8571484 0.8571696 0.8571901 0.8572100 0.8572292 [85] 0.8572477 0.8572656 0.8572828 0.8572993 0.8573151 0.8573302 0.8573447 [92] 0.8573586 0.8573717 0.8573842 0.8573960 0.8574071 0.8574176 0.8574274 [99] 0.8574365 0.8574450 0.8574528 0.8574599 0.8574664 0.8574722 0.8574773 [106] 0.8574818 0.8574855 0.8574887 0.8574911 0.8574929 0.8574941 0.8574945 [113] 0.8574944 0.8574935 0.8574920 0.8574898 0.8574870 0.8574835 0.8574793 [120] 0.8574745 0.8574690 0.8574629 0.8574561 0.8574486 0.8574405 0.8574317 [127] 0.8574223 0.8574122 0.8574015 0.8573901 0.8573780 0.8573653 0.8573520 [134] 0.8573380 0.8573233 0.8573080 0.8572920 0.8572754 0.8572582 0.8572403 [141] 0.8572217 0.8572025 0.8571826 0.8571621 0.8571410 0.8571192 0.8570968 [148] 0.8570737 0.8570499 0.8570256 0.8570006 0.8569749 0.8569486 0.8569217 [155] 0.8568941 0.8568659 0.8568370 0.8568076 0.8567774 0.8567467 0.8567153 [162] 0.8566832 0.8566506 0.8566173 0.8565833 0.8565488 0.8565136 0.8564778 [169] 0.8564413 0.8564042 0.8563665 0.8563282 0.8562892 0.8562496 0.8562094 [176] 0.8561686 0.8561271 0.8560850 0.8560423 0.8559990 0.8559550 0.8559105 [183] 0.8558653 0.8558195 0.8557730 0.8557260 0.8556784 0.8556301 0.8555812 [190] 0.8555317 0.8554816 0.8554309 0.8553796 0.8553276 0.8552751 0.8552219 [197] 0.8551682 0.8551138 0.8550588 0.8550033 0.8549471 0.8548903 0.8548329 [204] 0.8547750 0.8547164 0.8546572 0.8545974 0.8545371 0.8544761 0.8544145 [211] 0.8543524 0.8542896 0.8542263 0.8541623 0.8540978 0.8540327 0.8539670 [218] 0.8539007 0.8538339 0.8537664 0.8536984 0.8536297 0.8535605 0.8534907 [225] 0.8534204 0.8533494 0.8532779 0.8532058 0.8531331 0.8530599 0.8529860 [232] 0.8529116 0.8528367 0.8527611 0.8526850 0.8526083 0.8525311 0.8524532 [239] 0.8523749 0.8522959 0.8522164 0.8521363 0.8520557 0.8519745 0.8518927 [246] 0.8518104 0.8517275 0.8516441 0.8515601 0.8514756 0.8513905 0.8513048 [253] 0.8512186 0.8511319 0.8510446 0.8509568 0.8508684 0.8507794 0.8506899 [260] 0.8505999 0.8505094 0.8504183 0.8503266 0.8502344 0.8501417 0.8500484 [267] 0.8499547 0.8498603 0.8497655 0.8496701 0.8495741 0.8494777 0.8493807 [274] 0.8492832 0.8491852 0.8490866 0.8489875 0.8488879 0.8487878 0.8486871 [281] 0.8485860 0.8484843 0.8483821 0.8482794 0.8481761 0.8480724 0.8479681 [288] 0.8478633 0.8477581 0.8476523 0.8475460 0.8474392 0.8473319 0.8472240 [295] 0.8471157 0.8470069 0.8468976 0.8467878 0.8466775 0.8465666 0.8464553 [302] 0.8463435 0.8462312 0.8461184 0.8460052 0.8458914 0.8457771 0.8456624 [309] 0.8455472 0.8454315 0.8453153 0.8451986 0.8450814 0.8449638 0.8448457 [316] 0.8447271 0.8446080 0.8444884 0.8443684 0.8442479 0.8441270 0.8440055 [323] 0.8438836 0.8437613 0.8436384 0.8435151 0.8433914 0.8432671 0.8431424 [330] 0.8430173 0.8428917 0.8427656 0.8426391 0.8425121 0.8423847 0.8422568 [337] 0.8421285 0.8419997 0.8418704 0.8417408 0.8416106 0.8414801 0.8413491 [344] 0.8412176 0.8410857 0.8409534 0.8408206 0.8406874 0.8405537 0.8404196 [351] 0.8402851 0.8401502 0.8400148 0.8398790 0.8397427 0.8396060 0.8394689 [358] 0.8393314 0.8391935 0.8390551 0.8389163 0.8387771 0.8386375 0.8384975 [365] 0.8383570 0.8382161 0.8380748 0.8379331 0.8377910 0.8376485 0.8375056 [372] 0.8373623 0.8372185 0.8370744 0.8369298 0.8367849 0.8366395 0.8364938 [379] 0.8363476 0.8362011 0.8360542 0.8359068 0.8357591 0.8356110 0.8354625 [386] 0.8353136 0.8351643 0.8350146 0.8348646 0.8347141 0.8345633 0.8344121 [393] 0.8342605 0.8341086 0.8339562 0.8338035 0.8336504 0.8334969 0.8333431 [400] 0.8331889 0.8330343 > mx [1] 0.8574945 > mxli [1] -0.89 > 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/17sw31257673985.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/2w0xv1257673985.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/3rgdb1257673985.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/4nxqb1257673985.tab") > > system("convert tmp/17sw31257673985.ps tmp/17sw31257673985.png") > system("convert tmp/2w0xv1257673985.ps tmp/2w0xv1257673985.png") > system("convert tmp/3rgdb1257673985.ps tmp/3rgdb1257673985.png") > > > proc.time() user system elapsed 1.211 0.813 1.319