R version 2.8.1 (2008-12-22) 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(19,18,19,19,22,23,20,14,14,14,15,11,17,16,20,24,23,20,21,19,23,23,23,23,27,26,17,24,26,24,27,27,26,24,23,23,24,17,21,19,22,22,18,16,14,12,14,16,8,3,0,5,1,1,3,6,7,8,14,14,13) > x <- c(80.2,74.8,77.8,73,72,75.8,72.6,71.9,74.8,72.9,72.9,79.9,74,76,69.6,77.3,75.2,75.8,77.6,76.7,77,77.9,76.7,71.9,73.4,72.5,73.7,69.5,74.7,72.5,72.1,70.7,71.4,69.5,73.5,72.4,74.5,72.2,73,73.3,71.3,73.6,71.3,71.2,81.4,76.1,71.1,75.7,70,68.5,56.7,57.9,58.8,59.3,61.3,62.9,61.4,64.5,63.8,61.6,64.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.6940842 0.6939664 0.6938484 0.6937301 0.6936116 0.6934928 0.6933738 [8] 0.6932546 0.6931351 0.6930154 0.6928954 0.6927752 0.6926547 0.6925340 [15] 0.6924131 0.6922919 0.6921705 0.6920488 0.6919269 0.6918047 0.6916823 [22] 0.6915597 0.6914368 0.6913137 0.6911904 0.6910668 0.6909429 0.6908188 [29] 0.6906945 0.6905699 0.6904451 0.6903201 0.6901948 0.6900692 0.6899434 [36] 0.6898174 0.6896912 0.6895647 0.6894379 0.6893109 0.6891837 0.6890562 [43] 0.6889285 0.6888005 0.6886723 0.6885439 0.6884152 0.6882863 0.6881571 [50] 0.6880277 0.6878980 0.6877681 0.6876380 0.6875076 0.6873770 0.6872461 [57] 0.6871150 0.6869837 0.6868521 0.6867203 0.6865882 0.6864559 0.6863233 [64] 0.6861905 0.6860575 0.6859242 0.6857907 0.6856569 0.6855229 0.6853886 [71] 0.6852541 0.6851194 0.6849844 0.6848492 0.6847138 0.6845780 0.6844421 [78] 0.6843059 0.6841695 0.6840328 0.6838959 0.6837588 0.6836214 0.6834837 [85] 0.6833459 0.6832077 0.6830694 0.6829308 0.6827919 0.6826528 0.6825135 [92] 0.6823740 0.6822341 0.6820941 0.6819538 0.6818133 0.6816725 0.6815315 [99] 0.6813902 0.6812487 0.6811070 0.6809650 0.6808228 0.6806803 0.6805376 [106] 0.6803947 0.6802515 0.6801081 0.6799644 0.6798205 0.6796764 0.6795320 [113] 0.6793874 0.6792425 0.6790974 0.6789520 0.6788065 0.6786606 0.6785146 [120] 0.6783682 0.6782217 0.6780749 0.6779279 0.6777806 0.6776331 0.6774853 [127] 0.6773374 0.6771891 0.6770407 0.6768919 0.6767430 0.6765938 0.6764444 [134] 0.6762947 0.6761448 0.6759947 0.6758443 0.6756936 0.6755428 0.6753917 [141] 0.6752403 0.6750888 0.6749369 0.6747849 0.6746326 0.6744800 0.6743273 [148] 0.6741742 0.6740210 0.6738675 0.6737138 0.6735598 0.6734056 0.6732512 [155] 0.6730965 0.6729416 0.6727864 0.6726310 0.6724754 0.6723195 0.6721634 [162] 0.6720070 0.6718504 0.6716936 0.6715366 0.6713793 0.6712217 0.6710640 [169] 0.6709059 0.6707477 0.6705892 0.6704305 0.6702715 0.6701123 0.6699529 [176] 0.6697932 0.6696333 0.6694732 0.6693128 0.6691522 0.6689914 0.6688303 [183] 0.6686690 0.6685074 0.6683456 0.6681836 0.6680213 0.6678588 0.6676961 [190] 0.6675331 0.6673699 0.6672065 0.6670428 0.6668789 0.6667147 0.6665504 [197] 0.6663857 0.6662209 0.6660558 0.6658905 0.6657249 0.6655592 0.6653931 [204] 0.6652269 0.6650604 0.6648937 0.6647267 0.6645595 0.6643921 0.6642245 [211] 0.6640566 0.6638885 0.6637201 0.6635515 0.6633827 0.6632136 0.6630444 [218] 0.6628748 0.6627051 0.6625351 0.6623649 0.6621945 0.6620238 0.6618529 [225] 0.6616817 0.6615104 0.6613388 0.6611669 0.6609949 0.6608226 0.6606500 [232] 0.6604773 0.6603043 0.6601311 0.6599576 0.6597839 0.6596100 0.6594359 [239] 0.6592615 0.6590869 0.6589121 0.6587370 0.6585617 0.6583862 0.6582105 [246] 0.6580345 0.6578583 0.6576819 0.6575052 0.6573283 0.6571512 0.6569738 [253] 0.6567963 0.6566185 0.6564404 0.6562622 0.6560837 0.6559050 0.6557260 [260] 0.6555469 0.6553675 0.6551879 0.6550080 0.6548279 0.6546476 0.6544671 [267] 0.6542864 0.6541054 0.6539242 0.6537427 0.6535611 0.6533792 0.6531971 [274] 0.6530148 0.6528322 0.6526494 0.6524664 0.6522832 0.6520997 0.6519161 [281] 0.6517322 0.6515480 0.6513637 0.6511791 0.6509943 0.6508093 0.6506241 [288] 0.6504386 0.6502529 0.6500670 0.6498809 0.6496945 0.6495079 0.6493211 [295] 0.6491341 0.6489469 0.6487594 0.6485717 0.6483838 0.6481957 0.6480073 [302] 0.6478188 0.6476300 0.6474410 0.6472517 0.6470623 0.6468726 0.6466827 [309] 0.6464926 0.6463023 0.6461117 0.6459210 0.6457300 0.6455388 0.6453474 [316] 0.6451557 0.6449639 0.6447718 0.6445795 0.6443870 0.6441943 0.6440013 [323] 0.6438081 0.6436148 0.6434212 0.6432274 0.6430333 0.6428391 0.6426446 [330] 0.6424500 0.6422551 0.6420600 0.6418646 0.6416691 0.6414733 0.6412774 [337] 0.6410812 0.6408848 0.6406882 0.6404914 0.6402943 0.6400971 0.6398996 [344] 0.6397020 0.6395041 0.6393060 0.6391077 0.6389091 0.6387104 0.6385114 [351] 0.6383123 0.6381129 0.6379133 0.6377135 0.6375135 0.6373133 0.6371129 [358] 0.6369123 0.6367114 0.6365104 0.6363091 0.6361076 0.6359059 0.6357040 [365] 0.6355019 0.6352996 0.6350971 0.6348944 0.6346914 0.6344883 0.6342850 [372] 0.6340814 0.6338776 0.6336737 0.6334695 0.6332651 0.6330605 0.6328557 [379] 0.6326507 0.6324455 0.6322401 0.6320345 0.6318287 0.6316226 0.6314164 [386] 0.6312100 0.6310033 0.6307965 0.6305894 0.6303822 0.6301747 0.6299671 [393] 0.6297592 0.6295511 0.6293429 0.6291344 0.6289257 0.6287169 0.6285078 [400] 0.6282985 0.6280890 > mx [1] 0.6940842 > 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/rcomp/tmp/17mxe1258012069.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/rcomp/tmp/2yvub1258012069.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/rcomp/tmp/3ug251258012069.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/4uef71258012069.tab") > > system("convert tmp/17mxe1258012069.ps tmp/17mxe1258012069.png") > system("convert tmp/2yvub1258012069.ps tmp/2yvub1258012069.png") > system("convert tmp/3ug251258012069.ps tmp/3ug251258012069.png") > > > proc.time() user system elapsed 0.970 0.820 1.563