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(145.9,158.5,152.2,153.7,157.9,154.4,150.7,151.2,147.3,146.6,145.2,139.3,145.7,163.3,181.8,188.1,222.9,206.3,184.9,183.6,186.6,176.5,173.9,184.9,182.5,183.6,172.4,168.9,163.3,152.4,145.8,148.6,143.4,141.2,144.6,144.5,140.8,133.3,127.3,119.6,120.2,121.9,112.4,111,107.8,110.5,118.3,123,112.1,104.2,102.4,100.3,102.6,101.5,103.4,99.4,97.9,98,90.2,87.1,91.8,94.8,91.8,89.3,91.7,86.2,82.8,82.3,79.8,79.4,85.3,87.5,88.3,88.6,94.9,94.7,92.6,91.8,96.4,96.4,107.1,111.9,107.8,109.2,115.3,119.2,107.8,106.8,104.2,94.8,97.5,98.3,100.6,94.9,93.6,98,104.3,103.9,105.3,102.6,103.3,107.9,107.8,109.8,110.6,110.8,119.3,128.1,127.6,137.9,151.4,143.6,143.4,141.9,135.2,133.1,129.6,134.1,136.8,143.5,162.5,163.1,157.2,158.8,155.4,148.5,154.2,153.3,149.4,147.9,156,163,159.1,159.5,157.3,156.4,156.6,162.4,166.8,162.6,168.1) > x <- c(174.1,180.4,182.6,207.1,213.7,186.5,179.1,168.3,156.5,144.3,138.9,137.8,136.3,140.3,149.1,149.2,140.4,129,124.7,130.8,130.1,133.2,130.1,126.6,124.8,125.3,126.9,120.1,118.7,117.7,113.4,107.5,107.6,114.3,114.9,111.2,109.9,108.6,109.2,106.4,103.7,103,96.9,104.7,102.2,99,95.8,94.5,102.7,103.2,105.6,103.9,107.2,100.7,92.1,90.3,93.4,98.5,100.8,102.3,104.7,101.1,101.4,99.5,98.4,96.3,100.7,101.2,100.3,97.8,97.4,98.6,99.7,99,98.1,97,98.5,103.8,114.4,124.5,134.2,131.8,125.6,119.9,114.9,115.5,112.5,111.4,115.3,110.8,103.7,111.1,113,111.2,117.6,121.7,127.3,129.8,137.1,141.4,137.4,130.7,117.2,110.8,111.4,108.2,108.8,110.2,109.5,109.5,116,111.2,112.1,114,119.1,114.1,115.1,115.4,110.8,116,119.2,126.5,127.8,131.3,140.3,137.3,143,134.5,139.9,159.3,170.4,175,175.8,180.9,180.3,169.6,172.3,184.8,177.7,184.6,211.4) > par20 = '' > par19 = '' > par18 = '' > par17 = '' > par16 = '' > par15 = '' > par14 = '' > par13 = '' > par12 = '' > par11 = '' > par10 = '' > par9 = '' > par8 = '' > par7 = '' > par6 = '' > par5 = '' > par4 = '' > par3 = '' > par2 = '' > par1 = '' > ylab = '' > xlab = '' > main = '' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2007), Box-Cox Linearity Plot (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxlin.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description > 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.6817044 0.6815700 0.6814347 0.6812984 0.6811613 0.6810232 0.6808842 [8] 0.6807444 0.6806035 0.6804618 0.6803192 0.6801756 0.6800311 0.6798857 [15] 0.6797394 0.6795921 0.6794440 0.6792949 0.6791449 0.6789939 0.6788421 [22] 0.6786893 0.6785356 0.6783810 0.6782254 0.6780689 0.6779115 0.6777531 [29] 0.6775939 0.6774337 0.6772725 0.6771105 0.6769475 0.6767836 0.6766187 [36] 0.6764529 0.6762862 0.6761185 0.6759499 0.6757804 0.6756100 0.6754386 [43] 0.6752663 0.6750930 0.6749188 0.6747437 0.6745676 0.6743906 0.6742127 [50] 0.6740338 0.6738540 0.6736732 0.6734915 0.6733089 0.6731253 0.6729408 [57] 0.6727554 0.6725690 0.6723817 0.6721934 0.6720042 0.6718141 0.6716230 [64] 0.6714309 0.6712380 0.6710441 0.6708492 0.6706534 0.6704567 0.6702590 [71] 0.6700604 0.6698609 0.6696604 0.6694590 0.6692566 0.6690533 0.6688490 [78] 0.6686438 0.6684377 0.6682306 0.6680226 0.6678136 0.6676037 0.6673929 [85] 0.6671811 0.6669684 0.6667547 0.6665401 0.6663246 0.6661081 0.6658907 [92] 0.6656723 0.6654530 0.6652328 0.6650116 0.6647895 0.6645665 0.6643425 [99] 0.6641176 0.6638917 0.6636649 0.6634372 0.6632085 0.6629789 0.6627484 [106] 0.6625169 0.6622845 0.6620512 0.6618169 0.6615817 0.6613455 0.6611085 [113] 0.6608705 0.6606315 0.6603917 0.6601509 0.6599091 0.6596665 0.6594229 [120] 0.6591784 0.6589330 0.6586866 0.6584393 0.6581911 0.6579420 0.6576919 [127] 0.6574409 0.6571890 0.6569362 0.6566824 0.6564278 0.6561722 0.6559157 [134] 0.6556582 0.6553999 0.6551406 0.6548805 0.6546194 0.6543574 0.6540944 [141] 0.6538306 0.6535659 0.6533002 0.6530337 0.6527662 0.6524978 0.6522285 [148] 0.6519584 0.6516873 0.6514153 0.6511424 0.6508686 0.6505939 0.6503183 [155] 0.6500418 0.6497644 0.6494861 0.6492069 0.6489268 0.6486459 0.6483640 [162] 0.6480813 0.6477976 0.6475131 0.6472277 0.6469414 0.6466542 0.6463661 [169] 0.6460772 0.6457873 0.6454966 0.6452050 0.6449126 0.6446192 0.6443250 [176] 0.6440300 0.6437340 0.6434372 0.6431395 0.6428409 0.6425415 0.6422412 [183] 0.6419401 0.6416380 0.6413352 0.6410314 0.6407269 0.6404214 0.6401151 [190] 0.6398080 0.6395000 0.6391911 0.6388814 0.6385709 0.6382595 0.6379473 [197] 0.6376342 0.6373203 0.6370056 0.6366900 0.6363736 0.6360564 0.6357383 [204] 0.6354194 0.6350997 0.6347791 0.6344578 0.6341356 0.6338126 0.6334887 [211] 0.6331641 0.6328386 0.6325124 0.6321853 0.6318574 0.6315287 0.6311992 [218] 0.6308689 0.6305378 0.6302059 0.6298732 0.6295397 0.6292054 0.6288703 [225] 0.6285344 0.6281978 0.6278603 0.6275221 0.6271831 0.6268433 0.6265028 [232] 0.6261615 0.6258194 0.6254765 0.6251328 0.6247884 0.6244433 0.6240973 [239] 0.6237506 0.6234032 0.6230550 0.6227060 0.6223563 0.6220059 0.6216547 [246] 0.6213027 0.6209500 0.6205966 0.6202425 0.6198876 0.6195319 0.6191756 [253] 0.6188185 0.6184607 0.6181022 0.6177429 0.6173829 0.6170222 0.6166608 [260] 0.6162987 0.6159359 0.6155724 0.6152082 0.6148432 0.6144776 0.6141113 [267] 0.6137443 0.6133766 0.6130082 0.6126391 0.6122693 0.6118989 0.6115277 [274] 0.6111559 0.6107835 0.6104103 0.6100365 0.6096620 0.6092869 0.6089111 [281] 0.6085346 0.6081575 0.6077797 0.6074013 0.6070223 0.6066426 0.6062622 [288] 0.6058812 0.6054996 0.6051173 0.6047344 0.6043509 0.6039668 0.6035820 [295] 0.6031966 0.6028106 0.6024240 0.6020367 0.6016489 0.6012605 0.6008714 [302] 0.6004817 0.6000915 0.5997006 0.5993092 0.5989172 0.5985246 0.5981314 [309] 0.5977376 0.5973432 0.5969483 0.5965528 0.5961567 0.5957601 0.5953629 [316] 0.5949651 0.5945668 0.5941679 0.5937684 0.5933685 0.5929679 0.5925669 [323] 0.5921652 0.5917631 0.5913604 0.5909572 0.5905534 0.5901492 0.5897444 [330] 0.5893391 0.5889332 0.5885269 0.5881200 0.5877126 0.5873048 0.5868964 [337] 0.5864875 0.5860781 0.5856683 0.5852579 0.5848471 0.5844358 0.5840240 [344] 0.5836117 0.5831989 0.5827857 0.5823720 0.5819578 0.5815432 0.5811281 [351] 0.5807125 0.5802965 0.5798801 0.5794632 0.5790458 0.5786281 0.5782098 [358] 0.5777912 0.5773721 0.5769526 0.5765326 0.5761122 0.5756915 0.5752702 [365] 0.5748486 0.5744266 0.5740041 0.5735813 0.5731581 0.5727344 0.5723104 [372] 0.5718859 0.5714611 0.5710359 0.5706103 0.5701843 0.5697580 0.5693313 [379] 0.5689042 0.5684767 0.5680489 0.5676207 0.5671922 0.5667633 0.5663340 [386] 0.5659044 0.5654745 0.5650442 0.5646136 0.5641826 0.5637513 0.5633197 [393] 0.5628877 0.5624554 0.5620228 0.5615899 0.5611567 0.5607231 0.5602893 [400] 0.5598551 0.5594207 > mx [1] 0.6817044 > 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/1mm5i1226418619.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/2v3z61226418619.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/3u5r61226418619.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/4r1x21226418619.tab") > > system("convert tmp/1mm5i1226418619.ps tmp/1mm5i1226418619.png") > system("convert tmp/2v3z61226418619.ps tmp/2v3z61226418619.png") > system("convert tmp/3u5r61226418619.ps tmp/3u5r61226418619.png") > > > proc.time() user system elapsed 1.316 0.888 1.666