R version 2.7.2 (2008-08-25) 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(7.6,7.9,7.9,8.1,8.2,8,7.5,6.8,6.5,6.6,7.6,8,8,7.7,7.5,7.6,7.7,7.9,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.1,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.7,6.4,6.3,6.2,6.5,6.8,6.8,6.5,6.3,5.9,5.9,6.4,6.4) > x <- c(8.4,8.4,8.4,8.6,8.9,8.8,8.3,7.5,7.2,7.5,8.8,9.3,9.3,8.7,8.2,8.3,8.5,8.6,8.6,8.2,8.1,8,8.6,8.7,8.8,8.5,8.4,8.5,8.7,8.7,8.6,8.5,8.3,8.1,8.2,8.1,8.1,7.9,7.9,7.9,8,8,7.9,8,7.7,7.2,7.5,7.3,7,7,7,7.2,7.3,7.1,6.8,6.6,6.2,6.2,6.8,6.9) > #'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.8966302 0.8967504 0.8968703 0.8969899 0.8971093 0.8972283 0.8973470 [8] 0.8974655 0.8975836 0.8977015 0.8978190 0.8979363 0.8980532 0.8981699 [15] 0.8982862 0.8984023 0.8985181 0.8986335 0.8987487 0.8988636 0.8989781 [22] 0.8990924 0.8992064 0.8993201 0.8994335 0.8995465 0.8996593 0.8997718 [29] 0.8998840 0.8999959 0.9001075 0.9002187 0.9003297 0.9004404 0.9005508 [36] 0.9006609 0.9007707 0.9008802 0.9009894 0.9010983 0.9012068 0.9013151 [43] 0.9014231 0.9015308 0.9016382 0.9017453 0.9018521 0.9019585 0.9020647 [50] 0.9021706 0.9022762 0.9023815 0.9024865 0.9025911 0.9026955 0.9027996 [57] 0.9029033 0.9030068 0.9031100 0.9032129 0.9033154 0.9034177 0.9035196 [64] 0.9036213 0.9037226 0.9038237 0.9039245 0.9040249 0.9041250 0.9042249 [71] 0.9043244 0.9044237 0.9045226 0.9046212 0.9047195 0.9048176 0.9049153 [78] 0.9050127 0.9051098 0.9052066 0.9053031 0.9053993 0.9054952 0.9055908 [85] 0.9056861 0.9057811 0.9058758 0.9059701 0.9060642 0.9061580 0.9062515 [92] 0.9063446 0.9064375 0.9065300 0.9066223 0.9067142 0.9068058 0.9068972 [99] 0.9069882 0.9070789 0.9071693 0.9072594 0.9073493 0.9074388 0.9075279 [106] 0.9076168 0.9077054 0.9077937 0.9078817 0.9079693 0.9080567 0.9081438 [113] 0.9082305 0.9083170 0.9084031 0.9084889 0.9085745 0.9086597 0.9087446 [120] 0.9088292 0.9089135 0.9089975 0.9090812 0.9091646 0.9092477 0.9093305 [127] 0.9094129 0.9094951 0.9095769 0.9096585 0.9097397 0.9098207 0.9099013 [134] 0.9099816 0.9100616 0.9101413 0.9102207 0.9102998 0.9103786 0.9104571 [141] 0.9105353 0.9106132 0.9106907 0.9107680 0.9108449 0.9109216 0.9109979 [148] 0.9110739 0.9111496 0.9112250 0.9113002 0.9113750 0.9114494 0.9115236 [155] 0.9115975 0.9116711 0.9117443 0.9118173 0.9118899 0.9119623 0.9120343 [162] 0.9121060 0.9121774 0.9122486 0.9123194 0.9123899 0.9124600 0.9125299 [169] 0.9125995 0.9126688 0.9127377 0.9128064 0.9128747 0.9129427 0.9130105 [176] 0.9130779 0.9131450 0.9132118 0.9132783 0.9133445 0.9134104 0.9134759 [183] 0.9135412 0.9136062 0.9136708 0.9137351 0.9137992 0.9138629 0.9139263 [190] 0.9139894 0.9140522 0.9141147 0.9141769 0.9142388 0.9143004 0.9143616 [197] 0.9144226 0.9144832 0.9145436 0.9146036 0.9146633 0.9147228 0.9147819 [204] 0.9148407 0.9148992 0.9149573 0.9150152 0.9150728 0.9151301 0.9151870 [211] 0.9152437 0.9153000 0.9153560 0.9154117 0.9154672 0.9155223 0.9155771 [218] 0.9156316 0.9156858 0.9157396 0.9157932 0.9158465 0.9158994 0.9159521 [225] 0.9160044 0.9160564 0.9161082 0.9161596 0.9162107 0.9162615 0.9163120 [232] 0.9163622 0.9164120 0.9164616 0.9165109 0.9165598 0.9166085 0.9166568 [239] 0.9167049 0.9167526 0.9168000 0.9168471 0.9168939 0.9169404 0.9169866 [246] 0.9170325 0.9170781 0.9171233 0.9171683 0.9172130 0.9172573 0.9173013 [253] 0.9173451 0.9173885 0.9174316 0.9174744 0.9175169 0.9175591 0.9176010 [260] 0.9176426 0.9176839 0.9177249 0.9177655 0.9178059 0.9178459 0.9178857 [267] 0.9179251 0.9179642 0.9180031 0.9180416 0.9180798 0.9181177 0.9181553 [274] 0.9181926 0.9182296 0.9182663 0.9183026 0.9183387 0.9183745 0.9184099 [281] 0.9184451 0.9184799 0.9185145 0.9185487 0.9185826 0.9186162 0.9186495 [288] 0.9186825 0.9187152 0.9187476 0.9187797 0.9188115 0.9188430 0.9188742 [295] 0.9189050 0.9189356 0.9189659 0.9189958 0.9190255 0.9190548 0.9190838 [302] 0.9191126 0.9191410 0.9191691 0.9191969 0.9192244 0.9192517 0.9192786 [309] 0.9193052 0.9193314 0.9193574 0.9193831 0.9194085 0.9194336 0.9194583 [316] 0.9194828 0.9195070 0.9195308 0.9195544 0.9195776 0.9196006 0.9196232 [323] 0.9196455 0.9196676 0.9196893 0.9197107 0.9197318 0.9197527 0.9197732 [330] 0.9197934 0.9198133 0.9198329 0.9198522 0.9198712 0.9198899 0.9199083 [337] 0.9199264 0.9199441 0.9199616 0.9199788 0.9199957 0.9200123 0.9200285 [344] 0.9200445 0.9200602 0.9200755 0.9200906 0.9201053 0.9201198 0.9201339 [351] 0.9201478 0.9201613 0.9201746 0.9201875 0.9202002 0.9202125 0.9202245 [358] 0.9202363 0.9202477 0.9202589 0.9202697 0.9202802 0.9202904 0.9203004 [365] 0.9203100 0.9203193 0.9203284 0.9203371 0.9203455 0.9203536 0.9203614 [372] 0.9203690 0.9203762 0.9203831 0.9203897 0.9203960 0.9204021 0.9204078 [379] 0.9204132 0.9204183 0.9204231 0.9204277 0.9204319 0.9204358 0.9204394 [386] 0.9204427 0.9204458 0.9204485 0.9204509 0.9204530 0.9204549 0.9204564 [393] 0.9204576 0.9204586 0.9204592 0.9204595 0.9204595 0.9204593 0.9204587 [400] 0.9204579 0.9204567 > mx [1] 0.9204595 > mxli [1] 1.96 > 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/rcomp/tmp/1xla81226415152.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/rcomp/tmp/2unue1226415152.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/rcomp/tmp/3257z1226415152.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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/rcomp/tmp/4wfid1226415152.tab") > > system("convert tmp/1xla81226415152.ps tmp/1xla81226415152.png") > system("convert tmp/2unue1226415152.ps tmp/2unue1226415152.png") > system("convert tmp/3257z1226415152.ps tmp/3257z1226415152.png") > > > proc.time() user system elapsed 1.006 0.523 1.174