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(148,138,137,136,133,126,120,114,116,153,162,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) > x <- c(565,547,555,562,561,555,544,537,543,594,611,613,611,594,595,591,589,584,573,567,569,621,629,628,612,595,597,593,590,580,574,573,573,620,626,620,588,566,557,561,549,532,526,511,499,555,565,542,527,510,514,517,508,493,490,469,478,528,534,518) > #'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.8623230 0.8623758 0.8624285 0.8624811 0.8625336 0.8625860 0.8626382 [8] 0.8626903 0.8627422 0.8627941 0.8628458 0.8628974 0.8629488 0.8630001 [15] 0.8630513 0.8631024 0.8631533 0.8632041 0.8632548 0.8633054 0.8633558 [22] 0.8634061 0.8634563 0.8635063 0.8635562 0.8636060 0.8636557 0.8637052 [29] 0.8637546 0.8638039 0.8638530 0.8639020 0.8639509 0.8639997 0.8640483 [36] 0.8640968 0.8641452 0.8641935 0.8642416 0.8642896 0.8643374 0.8643852 [43] 0.8644328 0.8644803 0.8645276 0.8645748 0.8646219 0.8646689 0.8647157 [50] 0.8647625 0.8648090 0.8648555 0.8649018 0.8649480 0.8649941 0.8650400 [57] 0.8650859 0.8651316 0.8651771 0.8652225 0.8652679 0.8653130 0.8653581 [64] 0.8654030 0.8654478 0.8654925 0.8655370 0.8655814 0.8656257 0.8656698 [71] 0.8657139 0.8657578 0.8658015 0.8658452 0.8658887 0.8659321 0.8659753 [78] 0.8660185 0.8660615 0.8661044 0.8661471 0.8661897 0.8662322 0.8662746 [85] 0.8663168 0.8663589 0.8664009 0.8664428 0.8664845 0.8665261 0.8665676 [92] 0.8666089 0.8666501 0.8666912 0.8667322 0.8667730 0.8668137 0.8668543 [99] 0.8668947 0.8669351 0.8669753 0.8670153 0.8670553 0.8670951 0.8671348 [106] 0.8671743 0.8672138 0.8672531 0.8672923 0.8673313 0.8673702 0.8674090 [113] 0.8674477 0.8674862 0.8675247 0.8675630 0.8676011 0.8676391 0.8676771 [120] 0.8677148 0.8677525 0.8677900 0.8678274 0.8678647 0.8679018 0.8679389 [127] 0.8679757 0.8680125 0.8680491 0.8680857 0.8681220 0.8681583 0.8681944 [134] 0.8682304 0.8682663 0.8683021 0.8683377 0.8683732 0.8684086 0.8684438 [141] 0.8684789 0.8685139 0.8685488 0.8685835 0.8686181 0.8686526 0.8686870 [148] 0.8687212 0.8687553 0.8687893 0.8688232 0.8688569 0.8688905 0.8689240 [155] 0.8689573 0.8689905 0.8690236 0.8690566 0.8690894 0.8691222 0.8691548 [162] 0.8691872 0.8692196 0.8692518 0.8692839 0.8693158 0.8693477 0.8693794 [169] 0.8694110 0.8694424 0.8694738 0.8695050 0.8695361 0.8695670 0.8695979 [176] 0.8696286 0.8696592 0.8696896 0.8697200 0.8697502 0.8697803 0.8698102 [183] 0.8698400 0.8698697 0.8698993 0.8699288 0.8699581 0.8699873 0.8700164 [190] 0.8700454 0.8700742 0.8701029 0.8701315 0.8701599 0.8701883 0.8702165 [197] 0.8702446 0.8702725 0.8703004 0.8703281 0.8703557 0.8703831 0.8704105 [204] 0.8704377 0.8704648 0.8704917 0.8705186 0.8705453 0.8705719 0.8705983 [211] 0.8706247 0.8706509 0.8706770 0.8707030 0.8707288 0.8707545 0.8707801 [218] 0.8708056 0.8708310 0.8708562 0.8708813 0.8709063 0.8709311 0.8709559 [225] 0.8709805 0.8710049 0.8710293 0.8710536 0.8710777 0.8711017 0.8711255 [232] 0.8711493 0.8711729 0.8711964 0.8712198 0.8712430 0.8712662 0.8712892 [239] 0.8713121 0.8713348 0.8713575 0.8713800 0.8714024 0.8714246 0.8714468 [246] 0.8714688 0.8714907 0.8715125 0.8715342 0.8715557 0.8715771 0.8715984 [253] 0.8716196 0.8716406 0.8716616 0.8716824 0.8717031 0.8717236 0.8717441 [260] 0.8717644 0.8717846 0.8718046 0.8718246 0.8718444 0.8718641 0.8718837 [267] 0.8719032 0.8719225 0.8719418 0.8719609 0.8719798 0.8719987 0.8720174 [274] 0.8720361 0.8720546 0.8720729 0.8720912 0.8721093 0.8721273 0.8721452 [281] 0.8721630 0.8721806 0.8721982 0.8722156 0.8722329 0.8722500 0.8722671 [288] 0.8722840 0.8723008 0.8723175 0.8723341 0.8723505 0.8723669 0.8723831 [295] 0.8723992 0.8724151 0.8724310 0.8724467 0.8724623 0.8724778 0.8724932 [302] 0.8725084 0.8725236 0.8725386 0.8725535 0.8725682 0.8725829 0.8725974 [309] 0.8726118 0.8726261 0.8726403 0.8726544 0.8726683 0.8726821 0.8726958 [316] 0.8727094 0.8727229 0.8727362 0.8727495 0.8727626 0.8727756 0.8727884 [323] 0.8728012 0.8728138 0.8728263 0.8728387 0.8728510 0.8728632 0.8728752 [330] 0.8728872 0.8728990 0.8729107 0.8729223 0.8729337 0.8729451 0.8729563 [337] 0.8729674 0.8729784 0.8729893 0.8730000 0.8730106 0.8730212 0.8730316 [344] 0.8730419 0.8730520 0.8730621 0.8730720 0.8730818 0.8730916 0.8731011 [351] 0.8731106 0.8731200 0.8731292 0.8731383 0.8731473 0.8731562 0.8731650 [358] 0.8731737 0.8731822 0.8731906 0.8731989 0.8732071 0.8732152 0.8732232 [365] 0.8732310 0.8732388 0.8732464 0.8732539 0.8732613 0.8732686 0.8732757 [372] 0.8732828 0.8732897 0.8732965 0.8733032 0.8733098 0.8733162 0.8733226 [379] 0.8733288 0.8733350 0.8733410 0.8733469 0.8733527 0.8733583 0.8733639 [386] 0.8733693 0.8733747 0.8733799 0.8733850 0.8733900 0.8733948 0.8733996 [393] 0.8734042 0.8734088 0.8734132 0.8734175 0.8734217 0.8734258 0.8734297 [400] 0.8734336 0.8734373 > mx [1] 0.8734373 > 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/1h1ga1226489413.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/2sior1226489413.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/3hw041226489413.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/48dyo1226489414.tab") > > system("convert tmp/1h1ga1226489413.ps tmp/1h1ga1226489413.png") > system("convert tmp/2sior1226489413.ps tmp/2sior1226489413.png") > system("convert tmp/3hw041226489413.ps tmp/3hw041226489413.png") > > > proc.time() user system elapsed 1.188 0.799 1.507