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(101,101,98.7,96.4,95.6,95.4,98.7,98.7,98.7,99.3,99.5,99.6,100.8,100.8,100.8,101,101.6,102.3,102.3,102.3,102.3,102.4,102.4,102.4,102.4,102.4,102.4,102.4,101.6,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.2,102.1,102.1,102.1,102.1,100.7,100.7,100.7,100.7,100.7,100.7,100.7,100.7) > x <- c(101,100.3,100.1,99.8,99.9,99.9,100.2,99.7,100.4,100.9,101.3,101.4,101.3,100.9,100.9,100.9,101.1,101.1,101.3,101.8,102.9,103.2,103.3,104.5,105,104.9,104.9,105.4,106,105.7,105.9,106.2,106.4,106.9,107.3,107.9,109.2,110.2,110.2,110.5,110.6,110.8,111.3,111.1,111.2,111.2,111.1,111.5,112.1,111.4,110.4,110,110.4,110,110,109.3,109.7,109.6,109.6,109.4) > #'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.5479362 0.5478750 0.5478137 0.5477525 0.5476913 0.5476300 0.5475688 [8] 0.5475075 0.5474463 0.5473850 0.5473238 0.5472625 0.5472013 0.5471400 [15] 0.5470788 0.5470176 0.5469563 0.5468951 0.5468338 0.5467726 0.5467114 [22] 0.5466501 0.5465889 0.5465276 0.5464664 0.5464052 0.5463439 0.5462827 [29] 0.5462215 0.5461602 0.5460990 0.5460378 0.5459765 0.5459153 0.5458541 [36] 0.5457928 0.5457316 0.5456704 0.5456091 0.5455479 0.5454867 0.5454255 [43] 0.5453642 0.5453030 0.5452418 0.5451806 0.5451193 0.5450581 0.5449969 [50] 0.5449357 0.5448745 0.5448132 0.5447520 0.5446908 0.5446296 0.5445684 [57] 0.5445072 0.5444459 0.5443847 0.5443235 0.5442623 0.5442011 0.5441399 [64] 0.5440787 0.5440175 0.5439563 0.5438950 0.5438338 0.5437726 0.5437114 [71] 0.5436502 0.5435890 0.5435278 0.5434666 0.5434054 0.5433442 0.5432830 [78] 0.5432218 0.5431606 0.5430994 0.5430383 0.5429771 0.5429159 0.5428547 [85] 0.5427935 0.5427323 0.5426711 0.5426099 0.5425487 0.5424876 0.5424264 [92] 0.5423652 0.5423040 0.5422428 0.5421817 0.5421205 0.5420593 0.5419981 [99] 0.5419369 0.5418758 0.5418146 0.5417534 0.5416923 0.5416311 0.5415699 [106] 0.5415088 0.5414476 0.5413864 0.5413253 0.5412641 0.5412029 0.5411418 [113] 0.5410806 0.5410195 0.5409583 0.5408972 0.5408360 0.5407748 0.5407137 [120] 0.5406525 0.5405914 0.5405303 0.5404691 0.5404080 0.5403468 0.5402857 [127] 0.5402245 0.5401634 0.5401023 0.5400411 0.5399800 0.5399189 0.5398577 [134] 0.5397966 0.5397355 0.5396743 0.5396132 0.5395521 0.5394910 0.5394298 [141] 0.5393687 0.5393076 0.5392465 0.5391853 0.5391242 0.5390631 0.5390020 [148] 0.5389409 0.5388798 0.5388187 0.5387576 0.5386965 0.5386354 0.5385743 [155] 0.5385132 0.5384521 0.5383910 0.5383299 0.5382688 0.5382077 0.5381466 [162] 0.5380855 0.5380244 0.5379633 0.5379022 0.5378411 0.5377801 0.5377190 [169] 0.5376579 0.5375968 0.5375357 0.5374747 0.5374136 0.5373525 0.5372915 [176] 0.5372304 0.5371693 0.5371083 0.5370472 0.5369861 0.5369251 0.5368640 [183] 0.5368030 0.5367419 0.5366808 0.5366198 0.5365587 0.5364977 0.5364367 [190] 0.5363756 0.5363146 0.5362535 0.5361925 0.5361314 0.5360704 0.5360094 [197] 0.5359483 0.5358873 0.5358263 0.5357653 0.5357042 0.5356432 0.5355822 [204] 0.5355212 0.5354602 0.5353991 0.5353381 0.5352771 0.5352161 0.5351551 [211] 0.5350941 0.5350331 0.5349721 0.5349111 0.5348501 0.5347891 0.5347281 [218] 0.5346671 0.5346061 0.5345451 0.5344841 0.5344232 0.5343622 0.5343012 [225] 0.5342402 0.5341792 0.5341183 0.5340573 0.5339963 0.5339354 0.5338744 [232] 0.5338134 0.5337525 0.5336915 0.5336305 0.5335696 0.5335086 0.5334477 [239] 0.5333867 0.5333258 0.5332648 0.5332039 0.5331429 0.5330820 0.5330211 [246] 0.5329601 0.5328992 0.5328383 0.5327773 0.5327164 0.5326555 0.5325946 [253] 0.5325337 0.5324727 0.5324118 0.5323509 0.5322900 0.5322291 0.5321682 [260] 0.5321073 0.5320464 0.5319855 0.5319246 0.5318637 0.5318028 0.5317419 [267] 0.5316810 0.5316201 0.5315592 0.5314984 0.5314375 0.5313766 0.5313157 [274] 0.5312549 0.5311940 0.5311331 0.5310723 0.5310114 0.5309505 0.5308897 [281] 0.5308288 0.5307680 0.5307071 0.5306463 0.5305854 0.5305246 0.5304637 [288] 0.5304029 0.5303421 0.5302812 0.5302204 0.5301596 0.5300987 0.5300379 [295] 0.5299771 0.5299163 0.5298555 0.5297947 0.5297338 0.5296730 0.5296122 [302] 0.5295514 0.5294906 0.5294298 0.5293690 0.5293082 0.5292474 0.5291867 [309] 0.5291259 0.5290651 0.5290043 0.5289435 0.5288828 0.5288220 0.5287612 [316] 0.5287004 0.5286397 0.5285789 0.5285182 0.5284574 0.5283967 0.5283359 [323] 0.5282752 0.5282144 0.5281537 0.5280929 0.5280322 0.5279715 0.5279107 [330] 0.5278500 0.5277893 0.5277285 0.5276678 0.5276071 0.5275464 0.5274857 [337] 0.5274250 0.5273643 0.5273036 0.5272429 0.5271822 0.5271215 0.5270608 [344] 0.5270001 0.5269394 0.5268787 0.5268180 0.5267573 0.5266967 0.5266360 [351] 0.5265753 0.5265147 0.5264540 0.5263933 0.5263327 0.5262720 0.5262114 [358] 0.5261507 0.5260901 0.5260294 0.5259688 0.5259081 0.5258475 0.5257869 [365] 0.5257262 0.5256656 0.5256050 0.5255444 0.5254838 0.5254231 0.5253625 [372] 0.5253019 0.5252413 0.5251807 0.5251201 0.5250595 0.5249989 0.5249383 [379] 0.5248778 0.5248172 0.5247566 0.5246960 0.5246354 0.5245749 0.5245143 [386] 0.5244537 0.5243932 0.5243326 0.5242721 0.5242115 0.5241510 0.5240904 [393] 0.5240299 0.5239693 0.5239088 0.5238483 0.5237877 0.5237272 0.5236667 [400] 0.5236062 0.5235457 > mx [1] 0.5479362 > 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/1z50i1257937091.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/23omx1257937091.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/3kaz61257937091.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/4ku6c1257937091.tab") > > system("convert tmp/1z50i1257937091.ps tmp/1z50i1257937091.png") > system("convert tmp/23omx1257937091.ps tmp/23omx1257937091.png") > system("convert tmp/3kaz61257937091.ps tmp/3kaz61257937091.png") > > > proc.time() user system elapsed 1.232 0.843 1.437