R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(109.20,88.60,94.30,98.30,86.40,80.60,104.10,108.20,93.40,71.90,94.10,94.90,96.40,91.10,84.40,86.40,88.00,75.10,109.70,103.00,82.10,68.00,96.40,94.30,90.00,88.00,76.10,82.50,81.40,66.50,97.20,94.10,80.70,70.50,87.80,89.50,99.60,84.20,75.10,92.00,80.80,73.10,99.80,90.00,83.10,72.40,78.80,87.30,91.00,80.10,73.60,86.40,74.50,71.20,92.40,81.50,85.30,69.90,84.20,90.70,100.30) > x <- c(110.40,96.40,101.90,106.20,81.00,94.70,101.00,109.40,102.30,90.70,96.20,96.10,106.00,103.10,102.00,104.70,86.00,92.10,106.90,112.60,101.70,92.00,97.40,97.00,105.40,102.70,98.10,104.50,87.40,89.90,109.80,111.70,98.60,96.90,95.10,97.00,112.70,102.90,97.40,111.40,87.40,96.80,114.10,110.30,103.90,101.60,94.60,95.90,104.70,102.80,98.10,113.90,80.90,95.70,113.20,105.90,108.80,102.30,99.00,100.70,115.50) > #'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.5249687 0.5251365 0.5253041 0.5254715 0.5256387 0.5258056 0.5259724 [8] 0.5261389 0.5263053 0.5264714 0.5266373 0.5268030 0.5269685 0.5271337 [15] 0.5272988 0.5274637 0.5276283 0.5277927 0.5279570 0.5281210 0.5282848 [22] 0.5284483 0.5286117 0.5287748 0.5289378 0.5291005 0.5292630 0.5294253 [29] 0.5295874 0.5297493 0.5299109 0.5300724 0.5302336 0.5303946 0.5305554 [36] 0.5307160 0.5308763 0.5310365 0.5311964 0.5313561 0.5315156 0.5316749 [43] 0.5318339 0.5319928 0.5321514 0.5323098 0.5324680 0.5326260 0.5327837 [50] 0.5329412 0.5330986 0.5332557 0.5334125 0.5335692 0.5337256 0.5338819 [57] 0.5340379 0.5341936 0.5343492 0.5345045 0.5346597 0.5348146 0.5349692 [64] 0.5351237 0.5352779 0.5354320 0.5355857 0.5357393 0.5358927 0.5360458 [71] 0.5361987 0.5363514 0.5365039 0.5366561 0.5368081 0.5369599 0.5371115 [78] 0.5372628 0.5374140 0.5375649 0.5377155 0.5378660 0.5380162 0.5381662 [85] 0.5383160 0.5384656 0.5386149 0.5387640 0.5389129 0.5390616 0.5392100 [92] 0.5393582 0.5395062 0.5396539 0.5398015 0.5399488 0.5400959 0.5402427 [99] 0.5403894 0.5405358 0.5406819 0.5408279 0.5409736 0.5411191 0.5412644 [106] 0.5414094 0.5415542 0.5416988 0.5418432 0.5419873 0.5421312 0.5422749 [113] 0.5424184 0.5425616 0.5427046 0.5428473 0.5429899 0.5431322 0.5432743 [120] 0.5434161 0.5435578 0.5436992 0.5438403 0.5439813 0.5441220 0.5442624 [127] 0.5444027 0.5445427 0.5446825 0.5448221 0.5449614 0.5451005 0.5452394 [134] 0.5453780 0.5455164 0.5456546 0.5457926 0.5459303 0.5460678 0.5462050 [141] 0.5463421 0.5464789 0.5466154 0.5467518 0.5468879 0.5470237 0.5471594 [148] 0.5472948 0.5474300 0.5475649 0.5476996 0.5478341 0.5479684 0.5481024 [155] 0.5482362 0.5483697 0.5485031 0.5486362 0.5487690 0.5489016 0.5490340 [162] 0.5491662 0.5492981 0.5494298 0.5495613 0.5496925 0.5498235 0.5499543 [169] 0.5500848 0.5502151 0.5503452 0.5504751 0.5506047 0.5507340 0.5508632 [176] 0.5509921 0.5511207 0.5512492 0.5513774 0.5515054 0.5516331 0.5517606 [183] 0.5518879 0.5520149 0.5521417 0.5522683 0.5523946 0.5525207 0.5526466 [190] 0.5527722 0.5528976 0.5530228 0.5531477 0.5532724 0.5533969 0.5535211 [197] 0.5536451 0.5537689 0.5538924 0.5540157 0.5541387 0.5542616 0.5543841 [204] 0.5545065 0.5546286 0.5547505 0.5548722 0.5549936 0.5551148 0.5552357 [211] 0.5553564 0.5554769 0.5555971 0.5557171 0.5558369 0.5559565 0.5560758 [218] 0.5561948 0.5563137 0.5564323 0.5565506 0.5566688 0.5567867 0.5569043 [225] 0.5570218 0.5571389 0.5572559 0.5573726 0.5574891 0.5576054 0.5577214 [232] 0.5578372 0.5579527 0.5580680 0.5581831 0.5582979 0.5584126 0.5585269 [239] 0.5586411 0.5587550 0.5588686 0.5589821 0.5590953 0.5592082 0.5593210 [246] 0.5594335 0.5595457 0.5596578 0.5597695 0.5598811 0.5599924 0.5601035 [253] 0.5602144 0.5603250 0.5604354 0.5605455 0.5606554 0.5607651 0.5608745 [260] 0.5609838 0.5610927 0.5612015 0.5613100 0.5614182 0.5615263 0.5616341 [267] 0.5617416 0.5618490 0.5619561 0.5620629 0.5621696 0.5622760 0.5623821 [274] 0.5624881 0.5625938 0.5626992 0.5628044 0.5629094 0.5630142 0.5631187 [281] 0.5632230 0.5633271 0.5634309 0.5635345 0.5636378 0.5637409 0.5638438 [288] 0.5639465 0.5640489 0.5641511 0.5642530 0.5643548 0.5644562 0.5645575 [295] 0.5646585 0.5647593 0.5648598 0.5649602 0.5650602 0.5651601 0.5652597 [302] 0.5653591 0.5654583 0.5655572 0.5656559 0.5657543 0.5658525 0.5659505 [309] 0.5660483 0.5661458 0.5662431 0.5663402 0.5664370 0.5665336 0.5666300 [316] 0.5667261 0.5668220 0.5669176 0.5670131 0.5671083 0.5672033 0.5672980 [323] 0.5673925 0.5674868 0.5675808 0.5676746 0.5677682 0.5678616 0.5679547 [330] 0.5680476 0.5681402 0.5682327 0.5683249 0.5684168 0.5685086 0.5686001 [337] 0.5686913 0.5687824 0.5688732 0.5689638 0.5690541 0.5691442 0.5692341 [344] 0.5693238 0.5694132 0.5695024 0.5695914 0.5696801 0.5697687 0.5698569 [351] 0.5699450 0.5700328 0.5701204 0.5702078 0.5702949 0.5703818 0.5704685 [358] 0.5705550 0.5706412 0.5707272 0.5708129 0.5708985 0.5709838 0.5710689 [365] 0.5711537 0.5712383 0.5713227 0.5714069 0.5714909 0.5715746 0.5716581 [372] 0.5717413 0.5718243 0.5719072 0.5719897 0.5720721 0.5721542 0.5722361 [379] 0.5723178 0.5723992 0.5724804 0.5725614 0.5726422 0.5727227 0.5728031 [386] 0.5728831 0.5729630 0.5730426 0.5731221 0.5732012 0.5732802 0.5733589 [393] 0.5734375 0.5735157 0.5735938 0.5736716 0.5737493 0.5738266 0.5739038 [400] 0.5739808 0.5740575 > mx [1] 0.5740575 > 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/rcomp/tmp/128y01257198473.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/2q6lm1257198473.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/3x22i1257198473.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/4jx961257198473.tab") > > system("convert tmp/128y01257198473.ps tmp/128y01257198473.png") > system("convert tmp/2q6lm1257198473.ps tmp/2q6lm1257198473.png") > system("convert tmp/3x22i1257198473.ps tmp/3x22i1257198473.png") > > > proc.time() user system elapsed 0.763 0.492 0.963