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(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) > x <- 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) > #'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.5138882 0.5139973 0.5141063 0.5142153 0.5143241 0.5144329 0.5145416 [8] 0.5146502 0.5147587 0.5148671 0.5149754 0.5150836 0.5151918 0.5152998 [15] 0.5154078 0.5155156 0.5156234 0.5157311 0.5158387 0.5159462 0.5160536 [22] 0.5161609 0.5162682 0.5163753 0.5164823 0.5165893 0.5166961 0.5168029 [29] 0.5169095 0.5170161 0.5171226 0.5172290 0.5173353 0.5174415 0.5175476 [36] 0.5176536 0.5177595 0.5178653 0.5179710 0.5180766 0.5181822 0.5182876 [43] 0.5183929 0.5184982 0.5186033 0.5187084 0.5188133 0.5189182 0.5190229 [50] 0.5191276 0.5192321 0.5193366 0.5194410 0.5195452 0.5196494 0.5197535 [57] 0.5198574 0.5199613 0.5200651 0.5201688 0.5202723 0.5203758 0.5204792 [64] 0.5205825 0.5206856 0.5207887 0.5208917 0.5209945 0.5210973 0.5212000 [71] 0.5213025 0.5214050 0.5215074 0.5216096 0.5217118 0.5218139 0.5219158 [78] 0.5220177 0.5221194 0.5222211 0.5223226 0.5224241 0.5225254 0.5226266 [85] 0.5227278 0.5228288 0.5229297 0.5230305 0.5231312 0.5232318 0.5233323 [92] 0.5234327 0.5235330 0.5236332 0.5237333 0.5238333 0.5239331 0.5240329 [99] 0.5241326 0.5242321 0.5243316 0.5244309 0.5245301 0.5246292 0.5247283 [106] 0.5248272 0.5249260 0.5250247 0.5251232 0.5252217 0.5253201 0.5254183 [113] 0.5255165 0.5256145 0.5257125 0.5258103 0.5259080 0.5260056 0.5261031 [120] 0.5262005 0.5262978 0.5263949 0.5264920 0.5265889 0.5266858 0.5267825 [127] 0.5268791 0.5269756 0.5270720 0.5271683 0.5272644 0.5273605 0.5274564 [134] 0.5275522 0.5276479 0.5277436 0.5278390 0.5279344 0.5280297 0.5281248 [141] 0.5282199 0.5283148 0.5284096 0.5285043 0.5285989 0.5286934 0.5287877 [148] 0.5288819 0.5289761 0.5290701 0.5291640 0.5292577 0.5293514 0.5294450 [155] 0.5295384 0.5296317 0.5297249 0.5298180 0.5299110 0.5300038 0.5300966 [162] 0.5301892 0.5302817 0.5303741 0.5304663 0.5305585 0.5306505 0.5307424 [169] 0.5308342 0.5309259 0.5310175 0.5311089 0.5312002 0.5312914 0.5313825 [176] 0.5314735 0.5315643 0.5316551 0.5317457 0.5318362 0.5319265 0.5320168 [183] 0.5321069 0.5321969 0.5322868 0.5323766 0.5324662 0.5325558 0.5326452 [190] 0.5327345 0.5328236 0.5329127 0.5330016 0.5330904 0.5331791 0.5332677 [197] 0.5333561 0.5334444 0.5335326 0.5336207 0.5337086 0.5337964 0.5338841 [204] 0.5339717 0.5340592 0.5341465 0.5342337 0.5343208 0.5344078 0.5344946 [211] 0.5345813 0.5346679 0.5347544 0.5348407 0.5349269 0.5350130 0.5350990 [218] 0.5351848 0.5352706 0.5353561 0.5354416 0.5355270 0.5356122 0.5356973 [225] 0.5357822 0.5358671 0.5359518 0.5360364 0.5361208 0.5362051 0.5362894 [232] 0.5363734 0.5364574 0.5365412 0.5366249 0.5367085 0.5367919 0.5368752 [239] 0.5369584 0.5370415 0.5371244 0.5372072 0.5372899 0.5373725 0.5374549 [246] 0.5375372 0.5376193 0.5377014 0.5377833 0.5378650 0.5379467 0.5380282 [253] 0.5381096 0.5381908 0.5382720 0.5383530 0.5384338 0.5385146 0.5385952 [260] 0.5386757 0.5387560 0.5388362 0.5389163 0.5389963 0.5390761 0.5391558 [267] 0.5392353 0.5393148 0.5393941 0.5394732 0.5395523 0.5396312 0.5397100 [274] 0.5397886 0.5398671 0.5399455 0.5400237 0.5401018 0.5401798 0.5402577 [281] 0.5403354 0.5404130 0.5404904 0.5405677 0.5406449 0.5407220 0.5407989 [288] 0.5408757 0.5409523 0.5410288 0.5411052 0.5411815 0.5412576 0.5413335 [295] 0.5414094 0.5414851 0.5415607 0.5416361 0.5417114 0.5417866 0.5418616 [302] 0.5419365 0.5420113 0.5420859 0.5421604 0.5422348 0.5423090 0.5423831 [309] 0.5424571 0.5425309 0.5426046 0.5426781 0.5427515 0.5428248 0.5428979 [316] 0.5429709 0.5430438 0.5431165 0.5431891 0.5432616 0.5433339 0.5434061 [323] 0.5434781 0.5435500 0.5436218 0.5436934 0.5437649 0.5438363 0.5439075 [330] 0.5439786 0.5440496 0.5441204 0.5441910 0.5442616 0.5443320 0.5444022 [337] 0.5444723 0.5445423 0.5446122 0.5446819 0.5447514 0.5448208 0.5448901 [344] 0.5449593 0.5450283 0.5450972 0.5451659 0.5452345 0.5453029 0.5453712 [351] 0.5454394 0.5455075 0.5455753 0.5456431 0.5457107 0.5457782 0.5458455 [358] 0.5459127 0.5459798 0.5460467 0.5461135 0.5461801 0.5462466 0.5463130 [365] 0.5463792 0.5464452 0.5465112 0.5465770 0.5466426 0.5467081 0.5467735 [372] 0.5468387 0.5469038 0.5469688 0.5470336 0.5470982 0.5471627 0.5472271 [379] 0.5472914 0.5473555 0.5474194 0.5474832 0.5475469 0.5476104 0.5476738 [386] 0.5477371 0.5478002 0.5478631 0.5479260 0.5479886 0.5480512 0.5481136 [393] 0.5481758 0.5482379 0.5482999 0.5483617 0.5484234 0.5484849 0.5485463 [400] 0.5486076 0.5486687 > mx [1] 0.5486687 > 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/1zta21194695733.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/2mwfu1194695733.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/38eqy1194695733.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/4gz2a1194695733.tab") > > system("convert tmp/1zta21194695733.ps tmp/1zta21194695733.png") > system("convert tmp/2mwfu1194695733.ps tmp/2mwfu1194695733.png") > system("convert tmp/38eqy1194695733.ps tmp/38eqy1194695733.png") > > > proc.time() user system elapsed 1.054 0.492 1.190