R version 2.7.2 (2008-08-25) 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(145.3,143.6,142.8,155.9,156.2,149.8,152.7,155.5,159.3,143,141.4,142.8,146.4,152.3,164.3,168,171.3,162.7,150.2,142.5,138.2,138,145.1,138.4,131.8,130.8,126.3,123,124,120.8,122.1,106.5,104.3,108.7,113.8,112.5,106.1,98.4,96,99.3,97.5,95.3,88,94.7,99.4,98.9,96.4,95.3,99.5,101.6,103.9,106.6,108.3,102,93.8,91.6,97.7,94.8,98,103.8,97.8,91.2,89.3,87.5,90.4,94.2,102.2,101.3,96,90.8,93.2,90.9,91.1,90.2,94.3,96,99,103.3,113.1,112.8,112.1,107.4,111,110.5,110.8,112.4,111.5,116.2,122.5,121.3,113.9,110.7,120.8,141.1,147.4,148,158.1,165,187,190.3,182.4,168.8,151.2,120.1,112.5,106.2,107.1,108.5,106.5,108.3,125.6,124,127.2,136.9,135.8,124.3,115.4,113.6,114.4,118.4,117,116.5,115.4,113.6,117.4,116.9,116.4,111.1,110.2,118.9,131.8,130.6,138.3,148.4,148.7,144.3,152.5,162.9,167.2,166.5,185.6) > #'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.6262957 0.6261709 0.6260452 0.6259188 0.6257915 0.6256634 0.6255345 [8] 0.6254048 0.6252743 0.6251430 0.6250109 0.6248779 0.6247442 0.6246096 [15] 0.6244742 0.6243380 0.6242010 0.6240632 0.6239245 0.6237851 0.6236448 [22] 0.6235037 0.6233618 0.6232190 0.6230755 0.6229311 0.6227859 0.6226398 [29] 0.6224930 0.6223453 0.6221968 0.6220475 0.6218973 0.6217463 0.6215945 [36] 0.6214419 0.6212884 0.6211341 0.6209790 0.6208231 0.6206663 0.6205087 [43] 0.6203502 0.6201909 0.6200308 0.6198699 0.6197081 0.6195455 0.6193821 [50] 0.6192178 0.6190527 0.6188867 0.6187199 0.6185523 0.6183838 0.6182145 [57] 0.6180444 0.6178734 0.6177016 0.6175289 0.6173554 0.6171811 0.6170059 [64] 0.6168299 0.6166530 0.6164753 0.6162968 0.6161174 0.6159371 0.6157561 [71] 0.6155741 0.6153914 0.6152078 0.6150233 0.6148380 0.6146519 0.6144649 [78] 0.6142770 0.6140884 0.6138988 0.6137085 0.6135172 0.6133252 0.6131322 [85] 0.6129385 0.6127439 0.6125484 0.6123521 0.6121549 0.6119569 0.6117581 [92] 0.6115584 0.6113578 0.6111564 0.6109542 0.6107511 0.6105471 0.6103423 [99] 0.6101367 0.6099302 0.6097228 0.6095146 0.6093055 0.6090956 0.6088849 [106] 0.6086733 0.6084608 0.6082475 0.6080334 0.6078183 0.6076025 0.6073858 [113] 0.6071682 0.6069498 0.6067305 0.6065104 0.6062895 0.6060676 0.6058450 [120] 0.6056214 0.6053971 0.6051718 0.6049458 0.6047189 0.6044911 0.6042625 [127] 0.6040330 0.6038027 0.6035715 0.6033394 0.6031066 0.6028728 0.6026383 [134] 0.6024028 0.6021666 0.6019294 0.6016915 0.6014526 0.6012130 0.6009725 [141] 0.6007311 0.6004889 0.6002458 0.6000019 0.5997571 0.5995115 0.5992651 [148] 0.5990178 0.5987696 0.5985206 0.5982708 0.5980201 0.5977686 0.5975162 [155] 0.5972630 0.5970089 0.5967540 0.5964983 0.5962417 0.5959842 0.5957260 [162] 0.5954668 0.5952069 0.5949461 0.5946844 0.5944219 0.5941586 0.5938945 [169] 0.5936294 0.5933636 0.5930969 0.5928294 0.5925610 0.5922919 0.5920218 [176] 0.5917510 0.5914793 0.5912067 0.5909333 0.5906591 0.5903841 0.5901082 [183] 0.5898315 0.5895540 0.5892756 0.5889964 0.5887164 0.5884355 0.5881539 [190] 0.5878713 0.5875880 0.5873038 0.5870188 0.5867330 0.5864464 0.5861589 [197] 0.5858706 0.5855815 0.5852915 0.5850008 0.5847092 0.5844168 0.5841236 [204] 0.5838295 0.5835347 0.5832390 0.5829425 0.5826452 0.5823471 0.5820481 [211] 0.5817484 0.5814478 0.5811465 0.5808443 0.5805413 0.5802375 0.5799328 [218] 0.5796274 0.5793212 0.5790142 0.5787063 0.5783977 0.5780882 0.5777780 [225] 0.5774669 0.5771551 0.5768424 0.5765289 0.5762147 0.5758996 0.5755838 [232] 0.5752672 0.5749497 0.5746315 0.5743125 0.5739927 0.5736721 0.5733507 [239] 0.5730285 0.5727055 0.5723818 0.5720572 0.5717319 0.5714058 0.5710789 [246] 0.5707512 0.5704228 0.5700935 0.5697635 0.5694327 0.5691012 0.5687688 [253] 0.5684357 0.5681018 0.5677672 0.5674318 0.5670956 0.5667586 0.5664209 [260] 0.5660824 0.5657431 0.5654031 0.5650623 0.5647208 0.5643785 0.5640354 [267] 0.5636916 0.5633470 0.5630017 0.5626556 0.5623088 0.5619612 0.5616129 [274] 0.5612638 0.5609139 0.5605634 0.5602120 0.5598600 0.5595072 0.5591536 [281] 0.5587993 0.5584443 0.5580886 0.5577321 0.5573748 0.5570169 0.5566582 [288] 0.5562987 0.5559386 0.5555777 0.5552161 0.5548538 0.5544907 0.5541269 [295] 0.5537624 0.5533972 0.5530313 0.5526647 0.5522973 0.5519292 0.5515604 [302] 0.5511909 0.5508207 0.5504498 0.5500782 0.5497059 0.5493329 0.5489591 [309] 0.5485847 0.5482096 0.5478338 0.5474573 0.5470801 0.5467022 0.5463236 [316] 0.5459443 0.5455644 0.5451837 0.5448024 0.5444204 0.5440377 0.5436543 [323] 0.5432702 0.5428855 0.5425001 0.5421140 0.5417273 0.5413399 0.5409518 [330] 0.5405631 0.5401736 0.5397836 0.5393928 0.5390014 0.5386094 0.5382167 [337] 0.5378233 0.5374293 0.5370346 0.5366393 0.5362434 0.5358467 0.5354495 [344] 0.5350516 0.5346531 0.5342539 0.5338541 0.5334536 0.5330526 0.5326509 [351] 0.5322485 0.5318455 0.5314419 0.5310377 0.5306329 0.5302274 0.5298213 [358] 0.5294146 0.5290073 0.5285994 0.5281909 0.5277817 0.5273720 0.5269616 [365] 0.5265506 0.5261391 0.5257269 0.5253141 0.5249008 0.5244868 0.5240722 [372] 0.5236571 0.5232414 0.5228250 0.5224081 0.5219906 0.5215726 0.5211539 [379] 0.5207347 0.5203149 0.5198945 0.5194735 0.5190520 0.5186299 0.5182073 [386] 0.5177841 0.5173603 0.5169359 0.5165110 0.5160856 0.5156596 0.5152330 [393] 0.5148059 0.5143782 0.5139500 0.5135213 0.5130920 0.5126621 0.5122318 [400] 0.5118008 0.5113694 > mx [1] 0.6262957 > 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/1rid71226418844.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/2ptlh1226418844.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/3ze061226418844.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/4adr71226418844.tab") > > system("convert tmp/1rid71226418844.ps tmp/1rid71226418844.png") > system("convert tmp/2ptlh1226418844.ps tmp/2ptlh1226418844.png") > system("convert tmp/3ze061226418844.ps tmp/3ze061226418844.png") > > > proc.time() user system elapsed 1.011 0.515 1.566