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(10.9,10.0,9.2,9.2,9.5,9.6,9.5,9.1,8.9,9.0,10.1,10.3,10.2,9.6,9.2,9.3,9.4,9.4,9.2,9.0,9.0,9.0,9.8,10.0,9.8,9.3,9.0,9.0,9.1,9.1,9.1,9.2,8.8,8.3,8.4,8.1,7.7,7.9,7.9,8.0,7.9,7.6,7.1,6.8,6.5,6.9,8.2,8.7,8.3,7.9,7.5,7.8,8.3,8.4,8.2,7.7,7.2,7.3,8.1,8.5) > x <- c(8.1,7.7,7.5,7.6,7.8,7.8,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.2,7.9,7.3,6.9,6.6,6.7,6.9,7.0,7.1,7.2,7.1,6.9,7.0,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,7.9,7.7,7.4,7.5,8.0,8.1) > #'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.6095427 0.6094612 0.6093795 0.6092977 0.6092158 0.6091337 0.6090515 [8] 0.6089691 0.6088866 0.6088040 0.6087212 0.6086383 0.6085552 0.6084720 [15] 0.6083887 0.6083052 0.6082215 0.6081378 0.6080539 0.6079698 0.6078856 [22] 0.6078013 0.6077168 0.6076322 0.6075475 0.6074626 0.6073776 0.6072924 [29] 0.6072071 0.6071216 0.6070361 0.6069503 0.6068645 0.6067785 0.6066924 [36] 0.6066061 0.6065197 0.6064331 0.6063465 0.6062596 0.6061727 0.6060856 [43] 0.6059984 0.6059110 0.6058235 0.6057359 0.6056481 0.6055602 0.6054721 [50] 0.6053840 0.6052956 0.6052072 0.6051186 0.6050299 0.6049410 0.6048520 [57] 0.6047629 0.6046736 0.6045843 0.6044947 0.6044051 0.6043153 0.6042253 [64] 0.6041353 0.6040451 0.6039548 0.6038643 0.6037737 0.6036830 0.6035921 [71] 0.6035011 0.6034100 0.6033188 0.6032274 0.6031359 0.6030442 0.6029524 [78] 0.6028605 0.6027685 0.6026763 0.6025840 0.6024916 0.6023990 0.6023063 [85] 0.6022135 0.6021205 0.6020274 0.6019342 0.6018409 0.6017474 0.6016538 [92] 0.6015601 0.6014662 0.6013722 0.6012781 0.6011839 0.6010895 0.6009950 [99] 0.6009004 0.6008056 0.6007108 0.6006158 0.6005206 0.6004254 0.6003300 [106] 0.6002345 0.6001388 0.6000431 0.5999472 0.5998511 0.5997550 0.5996587 [113] 0.5995623 0.5994658 0.5993692 0.5992724 0.5991755 0.5990785 0.5989814 [120] 0.5988841 0.5987867 0.5986892 0.5985916 0.5984938 0.5983959 0.5982979 [127] 0.5981998 0.5981015 0.5980032 0.5979047 0.5978061 0.5977073 0.5976085 [134] 0.5975095 0.5974104 0.5973112 0.5972118 0.5971123 0.5970128 0.5969130 [141] 0.5968132 0.5967133 0.5966132 0.5965130 0.5964127 0.5963123 0.5962117 [148] 0.5961111 0.5960103 0.5959094 0.5958084 0.5957072 0.5956060 0.5955046 [155] 0.5954031 0.5953015 0.5951998 0.5950980 0.5949960 0.5948939 0.5947917 [162] 0.5946894 0.5945870 0.5944845 0.5943818 0.5942790 0.5941761 0.5940731 [169] 0.5939700 0.5938668 0.5937634 0.5936600 0.5935564 0.5934527 0.5933489 [176] 0.5932450 0.5931409 0.5930368 0.5929325 0.5928282 0.5927237 0.5926191 [183] 0.5925144 0.5924096 0.5923046 0.5921996 0.5920944 0.5919891 0.5918838 [190] 0.5917783 0.5916727 0.5915670 0.5914611 0.5913552 0.5912492 0.5911430 [197] 0.5910367 0.5909304 0.5908239 0.5907173 0.5906106 0.5905038 0.5903969 [204] 0.5902898 0.5901827 0.5900755 0.5899681 0.5898607 0.5897531 0.5896454 [211] 0.5895376 0.5894297 0.5893218 0.5892137 0.5891054 0.5889971 0.5888887 [218] 0.5887802 0.5886716 0.5885628 0.5884540 0.5883450 0.5882360 0.5881268 [225] 0.5880176 0.5879082 0.5877988 0.5876892 0.5875795 0.5874697 0.5873599 [232] 0.5872499 0.5871398 0.5870296 0.5869193 0.5868089 0.5866984 0.5865878 [239] 0.5864771 0.5863663 0.5862554 0.5861444 0.5860333 0.5859221 0.5858108 [246] 0.5856994 0.5855879 0.5854763 0.5853646 0.5852528 0.5851409 0.5850289 [253] 0.5849168 0.5848046 0.5846923 0.5845799 0.5844674 0.5843548 0.5842421 [260] 0.5841294 0.5840165 0.5839035 0.5837904 0.5836773 0.5835640 0.5834506 [267] 0.5833372 0.5832236 0.5831100 0.5829962 0.5828824 0.5827684 0.5826544 [274] 0.5825403 0.5824261 0.5823117 0.5821973 0.5820828 0.5819682 0.5818536 [281] 0.5817388 0.5816239 0.5815089 0.5813939 0.5812787 0.5811635 0.5810481 [288] 0.5809327 0.5808172 0.5807016 0.5805859 0.5804701 0.5803542 0.5802382 [295] 0.5801222 0.5800060 0.5798898 0.5797734 0.5796570 0.5795405 0.5794239 [302] 0.5793072 0.5791904 0.5790736 0.5789566 0.5788396 0.5787224 0.5786052 [309] 0.5784879 0.5783705 0.5782530 0.5781355 0.5780178 0.5779001 0.5777823 [316] 0.5776643 0.5775463 0.5774283 0.5773101 0.5771918 0.5770735 0.5769551 [323] 0.5768366 0.5767180 0.5765993 0.5764806 0.5763617 0.5762428 0.5761238 [330] 0.5760047 0.5758855 0.5757662 0.5756469 0.5755275 0.5754080 0.5752884 [337] 0.5751687 0.5750490 0.5749291 0.5748092 0.5746892 0.5745692 0.5744490 [344] 0.5743288 0.5742085 0.5740881 0.5739676 0.5738471 0.5737264 0.5736057 [351] 0.5734849 0.5733641 0.5732431 0.5731221 0.5730010 0.5728798 0.5727586 [358] 0.5726372 0.5725158 0.5723943 0.5722728 0.5721511 0.5720294 0.5719076 [365] 0.5717857 0.5716638 0.5715418 0.5714197 0.5712975 0.5711753 0.5710529 [372] 0.5709305 0.5708081 0.5706855 0.5705629 0.5704402 0.5703175 0.5701946 [379] 0.5700717 0.5699487 0.5698257 0.5697026 0.5695794 0.5694561 0.5693328 [386] 0.5692093 0.5690859 0.5689623 0.5688387 0.5687150 0.5685912 0.5684674 [393] 0.5683435 0.5682195 0.5680955 0.5679713 0.5678472 0.5677229 0.5675986 [400] 0.5674742 0.5673497 > mx [1] 0.6095427 > 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/13fb11257769741.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/257k51257769741.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/3v40r1257769741.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/4vmwy1257769742.tab") > > system("convert tmp/13fb11257769741.ps tmp/13fb11257769741.png") > system("convert tmp/257k51257769741.ps tmp/257k51257769741.png") > system("convert tmp/3v40r1257769741.ps tmp/3v40r1257769741.png") > > > proc.time() user system elapsed 1.000 0.780 1.596