R version 2.7.0 (2008-04-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(94.7,101.8,102.5,105.3,110.3,109.8,117.3,118.8,131.3,125.9,133.1,147,145.8,164.4,149.8,137.7,151.7,156.8,180,180.4,170.4,191.6,199.5,218.2,217.5,205,194,199.3,219.3,211.1,215.2,240.2,242.2,240.7,255.4,253,218.2,203.7,205.6,215.6,188.5,202.9,214,230.3,230,241,259.6,247.8,270.3,289.7,322.7,315,320.2,329.5,360.6,382.2,435.4,464,468.8,403,351.6) > x <- c(1.7,1.4,1.8,1.7,1.4,1.2,1,1.7,2.4,2,2.1,2,1.8,2.7,2.3,1.9,2,2.3,2.8,2.4,2.3,2.7,2.7,2.9,3,2.2,2.3,2.8,2.8,2.8,2.2,2.6,2.8,2.5,2.4,2.3,1.9,1.7,2,2.1,1.7,1.8,1.8,1.8,1.3,1.3,1.3,1.2,1.4,2.2,2.9,3.1,3.5,3.6,4.4,4.1,5.1,5.8,5.9,5.4,5.5) > #'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.4815092 0.4827299 0.4839536 0.4851801 0.4864095 0.4876418 0.4888770 [8] 0.4901150 0.4913558 0.4925994 0.4938458 0.4950949 0.4963468 0.4976014 [15] 0.4988588 0.5001188 0.5013814 0.5026467 0.5039146 0.5051851 0.5064582 [22] 0.5077339 0.5090120 0.5102927 0.5115758 0.5128614 0.5141494 0.5154398 [29] 0.5167326 0.5180277 0.5193252 0.5206249 0.5219270 0.5232312 0.5245377 [36] 0.5258464 0.5271572 0.5284701 0.5297852 0.5311023 0.5324214 0.5337426 [43] 0.5350657 0.5363908 0.5377178 0.5390466 0.5403773 0.5417098 0.5430441 [50] 0.5443801 0.5457179 0.5470573 0.5483983 0.5497410 0.5510852 0.5524310 [57] 0.5537782 0.5551269 0.5564771 0.5578286 0.5591814 0.5605355 0.5618910 [64] 0.5632476 0.5646054 0.5659644 0.5673244 0.5686855 0.5700477 0.5714108 [71] 0.5727748 0.5741398 0.5755056 0.5768722 0.5782395 0.5796076 0.5809763 [78] 0.5823457 0.5837156 0.5850861 0.5864571 0.5878285 0.5892003 0.5905725 [85] 0.5919449 0.5933176 0.5946905 0.5960636 0.5974367 0.5988100 0.6001832 [92] 0.6015564 0.6029295 0.6043024 0.6056751 0.6070476 0.6084198 0.6097917 [99] 0.6111631 0.6125341 0.6139046 0.6152746 0.6166439 0.6180125 0.6193804 [106] 0.6207476 0.6221139 0.6234793 0.6248438 0.6262073 0.6275698 0.6289311 [113] 0.6302913 0.6316502 0.6330079 0.6343643 0.6357193 0.6370728 0.6384248 [120] 0.6397753 0.6411242 0.6424714 0.6438169 0.6451606 0.6465024 0.6478424 [127] 0.6491803 0.6505163 0.6518502 0.6531820 0.6545116 0.6558389 0.6571639 [134] 0.6584866 0.6598068 0.6611246 0.6624398 0.6637524 0.6650624 0.6663696 [141] 0.6676741 0.6689757 0.6702745 0.6715703 0.6728631 0.6741529 0.6754395 [148] 0.6767229 0.6780031 0.6792800 0.6805536 0.6818237 0.6830904 0.6843536 [155] 0.6856132 0.6868691 0.6881213 0.6893698 0.6906145 0.6918554 0.6930923 [162] 0.6943252 0.6955541 0.6967789 0.6979996 0.6992161 0.7004283 0.7016363 [169] 0.7028398 0.7040390 0.7052337 0.7064239 0.7076095 0.7087905 0.7099669 [176] 0.7111385 0.7123053 0.7134673 0.7146245 0.7157767 0.7169240 0.7180662 [183] 0.7192033 0.7203354 0.7214622 0.7225839 0.7237003 0.7248114 0.7259171 [190] 0.7270175 0.7281124 0.7292018 0.7302857 0.7313640 0.7324367 0.7335037 [197] 0.7345651 0.7356207 0.7366705 0.7377145 0.7387526 0.7397849 0.7408112 [204] 0.7418316 0.7428459 0.7438542 0.7448564 0.7458525 0.7468424 0.7478261 [211] 0.7488037 0.7497750 0.7507400 0.7516986 0.7526510 0.7535970 0.7545365 [218] 0.7554697 0.7563963 0.7573165 0.7582302 0.7591373 0.7600379 0.7609319 [225] 0.7618193 0.7627000 0.7635741 0.7644415 0.7653022 0.7661562 0.7670034 [232] 0.7678439 0.7686776 0.7695045 0.7703246 0.7711379 0.7719444 0.7727440 [239] 0.7735367 0.7743225 0.7751014 0.7758735 0.7766386 0.7773968 0.7781480 [246] 0.7788923 0.7796297 0.7803601 0.7810835 0.7818000 0.7825094 0.7832119 [253] 0.7839074 0.7845959 0.7852774 0.7859520 0.7866195 0.7872800 0.7879335 [260] 0.7885801 0.7892196 0.7898522 0.7904778 0.7910963 0.7917079 0.7923126 [267] 0.7929102 0.7935009 0.7940847 0.7946615 0.7952313 0.7957942 0.7963502 [274] 0.7968993 0.7974415 0.7979768 0.7985052 0.7990267 0.7995414 0.8000493 [281] 0.8005503 0.8010445 0.8015319 0.8020126 0.8024864 0.8029536 0.8034140 [288] 0.8038676 0.8043146 0.8047550 0.8051886 0.8056157 0.8060361 0.8064499 [295] 0.8068571 0.8072578 0.8076520 0.8080397 0.8084209 0.8087956 0.8091639 [302] 0.8095258 0.8098813 0.8102304 0.8105732 0.8109097 0.8112399 0.8115639 [309] 0.8118816 0.8121932 0.8124985 0.8127978 0.8130909 0.8133779 0.8136589 [316] 0.8139338 0.8142028 0.8144658 0.8147228 0.8149740 0.8152193 0.8154587 [323] 0.8156923 0.8159202 0.8161423 0.8163586 0.8165693 0.8167744 0.8169739 [330] 0.8171677 0.8173560 0.8175388 0.8177161 0.8178880 0.8180545 0.8182156 [337] 0.8183713 0.8185217 0.8186669 0.8188068 0.8189415 0.8190711 0.8191955 [344] 0.8193148 0.8194291 0.8195383 0.8196426 0.8197419 0.8198362 0.8199257 [351] 0.8200104 0.8200902 0.8201653 0.8202356 0.8203012 0.8203622 0.8204185 [358] 0.8204702 0.8205174 0.8205601 0.8205983 0.8206320 0.8206613 0.8206863 [365] 0.8207069 0.8207232 0.8207353 0.8207431 0.8207467 0.8207462 0.8207416 [372] 0.8207329 0.8207201 0.8207033 0.8206826 0.8206579 0.8206293 0.8205969 [379] 0.8205606 0.8205205 0.8204767 0.8204292 0.8203779 0.8203230 0.8202645 [386] 0.8202024 0.8201368 0.8200677 0.8199950 0.8199190 0.8198395 0.8197567 [393] 0.8196705 0.8195810 0.8194883 0.8193923 0.8192931 0.8191908 0.8190853 [400] 0.8189767 0.8188651 > mx [1] 0.8207467 > mxli [1] 1.68 > 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/19b5h1226161181.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/2uyx41226161181.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/37cg01226161181.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/4wh761226161181.tab") > > system("convert tmp/19b5h1226161181.ps tmp/19b5h1226161181.png") > system("convert tmp/2uyx41226161181.ps tmp/2uyx41226161181.png") > system("convert tmp/37cg01226161181.ps tmp/37cg01226161181.png") > > > proc.time() user system elapsed 1.854 0.819 1.981