R version 2.6.0 (2007-10-03) Copyright (C) 2007 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(98.6,98,106.8,96.7,100.2,107.7,92,98.4,107.4,117.7,105.7,97.5,99.9,98.2,104.5,100.8,101.5,103.9,99.6,98.4,112.7,118.4,108.1,105.4,114.6,106.9,115.9,109.8,101.8,114.2,110.8,108.4,127.5,128.6,116.6,127.4,105,108.3,125,111.6,106.5,130.3,115,116.1,134,126.5,125.8,136.4,114.9,110.9,125.5,116.8,116.8,125.5,104.2,115.1,132.8,123.3,124.8,122,117.4,117.9,137.4,114.6,124.7,129.6,109.4,120.9,134.9,136.3,133.2,127.2,122.7,120.5,137.8,119.1,124.3,134.3,121.7,125) > x <- c(103.1,100.6,103.1,95.5,90.5,90.9,88.8,90.7,94.3,104.6,111.1,110.8,107.2,99,99,91,96.2,96.9,96.2,100.1,99,115.4,106.9,107.1,99.3,99.2,108.3,105.6,99.5,107.4,93.1,88.1,110.7,113.1,99.6,93.6,98.6,99.6,114.3,107.8,101.2,112.5,100.5,93.9,116.2,112,106.4,95.7,96,95.8,103,102.2,98.4,111.4,86.6,91.3,107.9,101.8,104.4,93.4,100.1,98.5,112.9,101.4,107.1,110.8,90.3,95.5,111.4,113,107.5,95.9,106.3,105.2,117.2,106.9,108.2,110,96.1,100.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.5245556 0.5246215 0.5246875 0.5247533 0.5248191 0.5248849 0.5249506 [8] 0.5250163 0.5250819 0.5251474 0.5252129 0.5252784 0.5253438 0.5254091 [15] 0.5254744 0.5255397 0.5256049 0.5256700 0.5257351 0.5258001 0.5258651 [22] 0.5259300 0.5259949 0.5260597 0.5261245 0.5261892 0.5262539 0.5263185 [29] 0.5263831 0.5264476 0.5265121 0.5265765 0.5266408 0.5267051 0.5267694 [36] 0.5268336 0.5268977 0.5269618 0.5270258 0.5270898 0.5271538 0.5272176 [43] 0.5272815 0.5273452 0.5274089 0.5274726 0.5275362 0.5275998 0.5276633 [50] 0.5277267 0.5277901 0.5278535 0.5279168 0.5279800 0.5280432 0.5281063 [57] 0.5281694 0.5282324 0.5282954 0.5283583 0.5284211 0.5284840 0.5285467 [64] 0.5286094 0.5286720 0.5287346 0.5287972 0.5288596 0.5289221 0.5289844 [71] 0.5290468 0.5291090 0.5291712 0.5292334 0.5292955 0.5293575 0.5294195 [78] 0.5294815 0.5295433 0.5296052 0.5296669 0.5297287 0.5297903 0.5298519 [85] 0.5299135 0.5299750 0.5300364 0.5300978 0.5301591 0.5302204 0.5302816 [92] 0.5303428 0.5304039 0.5304650 0.5305260 0.5305869 0.5306478 0.5307087 [99] 0.5307694 0.5308302 0.5308908 0.5309514 0.5310120 0.5310725 0.5311329 [106] 0.5311933 0.5312537 0.5313139 0.5313742 0.5314343 0.5314944 0.5315545 [113] 0.5316145 0.5316744 0.5317343 0.5317942 0.5318539 0.5319136 0.5319733 [120] 0.5320329 0.5320925 0.5321520 0.5322114 0.5322708 0.5323301 0.5323894 [127] 0.5324486 0.5325077 0.5325668 0.5326259 0.5326849 0.5327438 0.5328026 [134] 0.5328615 0.5329202 0.5329789 0.5330376 0.5330961 0.5331547 0.5332132 [141] 0.5332716 0.5333299 0.5333882 0.5334465 0.5335047 0.5335628 0.5336209 [148] 0.5336789 0.5337368 0.5337947 0.5338526 0.5339104 0.5339681 0.5340258 [155] 0.5340834 0.5341409 0.5341984 0.5342559 0.5343133 0.5343706 0.5344278 [162] 0.5344851 0.5345422 0.5345993 0.5346563 0.5347133 0.5347702 0.5348271 [169] 0.5348839 0.5349407 0.5349973 0.5350540 0.5351105 0.5351671 0.5352235 [176] 0.5352799 0.5353363 0.5353925 0.5354488 0.5355049 0.5355610 0.5356171 [183] 0.5356731 0.5357290 0.5357849 0.5358407 0.5358964 0.5359521 0.5360078 [190] 0.5360634 0.5361189 0.5361743 0.5362297 0.5362851 0.5363404 0.5363956 [197] 0.5364508 0.5365059 0.5365609 0.5366159 0.5366709 0.5367257 0.5367806 [204] 0.5368353 0.5368900 0.5369446 0.5369992 0.5370537 0.5371082 0.5371626 [211] 0.5372169 0.5372712 0.5373254 0.5373796 0.5374337 0.5374878 0.5375417 [218] 0.5375957 0.5376495 0.5377033 0.5377571 0.5378108 0.5378644 0.5379180 [225] 0.5379715 0.5380249 0.5380783 0.5381317 0.5381849 0.5382381 0.5382913 [232] 0.5383444 0.5383974 0.5384504 0.5385033 0.5385561 0.5386089 0.5386617 [239] 0.5387143 0.5387669 0.5388195 0.5388720 0.5389244 0.5389768 0.5390291 [246] 0.5390813 0.5391335 0.5391857 0.5392377 0.5392897 0.5393417 0.5393936 [253] 0.5394454 0.5394972 0.5395489 0.5396005 0.5396521 0.5397036 0.5397551 [260] 0.5398065 0.5398578 0.5399091 0.5399604 0.5400115 0.5400626 0.5401137 [267] 0.5401646 0.5402156 0.5402664 0.5403172 0.5403679 0.5404186 0.5404692 [274] 0.5405198 0.5405703 0.5406207 0.5406711 0.5407214 0.5407716 0.5408218 [281] 0.5408720 0.5409220 0.5409720 0.5410220 0.5410719 0.5411217 0.5411714 [288] 0.5412211 0.5412708 0.5413203 0.5413699 0.5414193 0.5414687 0.5415180 [295] 0.5415673 0.5416165 0.5416657 0.5417147 0.5417638 0.5418127 0.5418616 [302] 0.5419105 0.5419592 0.5420080 0.5420566 0.5421052 0.5421537 0.5422022 [309] 0.5422506 0.5422990 0.5423473 0.5423955 0.5424436 0.5424917 0.5425398 [316] 0.5425877 0.5426357 0.5426835 0.5427313 0.5427790 0.5428267 0.5428743 [323] 0.5429218 0.5429693 0.5430167 0.5430641 0.5431114 0.5431586 0.5432058 [330] 0.5432529 0.5433000 0.5433469 0.5433939 0.5434407 0.5434875 0.5435343 [337] 0.5435809 0.5436275 0.5436741 0.5437206 0.5437670 0.5438134 0.5438597 [344] 0.5439059 0.5439521 0.5439982 0.5440442 0.5440902 0.5441361 0.5441820 [351] 0.5442278 0.5442736 0.5443192 0.5443648 0.5444104 0.5444559 0.5445013 [358] 0.5445467 0.5445920 0.5446372 0.5446824 0.5447275 0.5447725 0.5448175 [365] 0.5448625 0.5449073 0.5449521 0.5449969 0.5450415 0.5450861 0.5451307 [372] 0.5451752 0.5452196 0.5452640 0.5453083 0.5453525 0.5453967 0.5454408 [379] 0.5454848 0.5455288 0.5455727 0.5456166 0.5456604 0.5457041 0.5457478 [386] 0.5457914 0.5458349 0.5458784 0.5459218 0.5459652 0.5460085 0.5460517 [393] 0.5460949 0.5461380 0.5461810 0.5462240 0.5462669 0.5463097 0.5463525 [400] 0.5463953 0.5464379 > mx [1] 0.5464379 > 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/1keo81194695964.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/2q1kd1194695964.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/3cjm71194695964.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 > 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/4485g1194695964.tab") > > system("convert tmp/1keo81194695964.ps tmp/1keo81194695964.png") > system("convert tmp/2q1kd1194695964.ps tmp/2q1kd1194695964.png") > system("convert tmp/3cjm71194695964.ps tmp/3cjm71194695964.png") > > > proc.time() user system elapsed 2.419 1.285 2.580