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(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) > x <- c(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) > #'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.4556135 0.4555727 0.4555317 0.4554905 0.4554492 0.4554076 0.4553659 [8] 0.4553239 0.4552818 0.4552395 0.4551970 0.4551543 0.4551115 0.4550685 [15] 0.4550253 0.4549819 0.4549383 0.4548946 0.4548507 0.4548066 0.4547624 [22] 0.4547180 0.4546734 0.4546286 0.4545837 0.4545386 0.4544934 0.4544480 [29] 0.4544024 0.4543566 0.4543107 0.4542647 0.4542184 0.4541720 0.4541255 [36] 0.4540788 0.4540320 0.4539850 0.4539378 0.4538905 0.4538430 0.4537954 [43] 0.4537477 0.4536998 0.4536517 0.4536035 0.4535552 0.4535067 0.4534581 [50] 0.4534093 0.4533604 0.4533114 0.4532622 0.4532129 0.4531634 0.4531138 [57] 0.4530641 0.4530143 0.4529643 0.4529142 0.4528639 0.4528135 0.4527630 [64] 0.4527124 0.4526617 0.4526108 0.4525598 0.4525087 0.4524575 0.4524061 [71] 0.4523546 0.4523031 0.4522514 0.4521995 0.4521476 0.4520956 0.4520434 [78] 0.4519912 0.4519388 0.4518863 0.4518337 0.4517810 0.4517282 0.4516753 [85] 0.4516223 0.4515692 0.4515160 0.4514627 0.4514093 0.4513558 0.4513022 [92] 0.4512485 0.4511948 0.4511409 0.4510869 0.4510329 0.4509787 0.4509245 [99] 0.4508702 0.4508158 0.4507613 0.4507068 0.4506521 0.4505974 0.4505426 [106] 0.4504877 0.4504327 0.4503777 0.4503226 0.4502674 0.4502121 0.4501568 [113] 0.4501014 0.4500459 0.4499904 0.4499347 0.4498791 0.4498233 0.4497675 [120] 0.4497116 0.4496557 0.4495997 0.4495437 0.4494876 0.4494314 0.4493752 [127] 0.4493189 0.4492626 0.4492062 0.4491497 0.4490933 0.4490367 0.4489801 [134] 0.4489235 0.4488668 0.4488101 0.4487533 0.4486965 0.4486397 0.4485828 [141] 0.4485258 0.4484689 0.4484119 0.4483548 0.4482977 0.4482406 0.4481835 [148] 0.4481263 0.4480691 0.4480119 0.4479546 0.4478973 0.4478400 0.4477826 [155] 0.4477253 0.4476679 0.4476104 0.4475530 0.4474955 0.4474381 0.4473806 [162] 0.4473231 0.4472655 0.4472080 0.4471504 0.4470929 0.4470353 0.4469777 [169] 0.4469201 0.4468625 0.4468049 0.4467473 0.4466897 0.4466320 0.4465744 [176] 0.4465168 0.4464591 0.4464015 0.4463439 0.4462862 0.4462286 0.4461710 [183] 0.4461134 0.4460557 0.4459981 0.4459405 0.4458830 0.4458254 0.4457678 [190] 0.4457103 0.4456527 0.4455952 0.4455377 0.4454802 0.4454227 0.4453653 [197] 0.4453078 0.4452504 0.4451930 0.4451357 0.4450783 0.4450210 0.4449637 [204] 0.4449064 0.4448492 0.4447920 0.4447348 0.4446776 0.4446205 0.4445634 [211] 0.4445063 0.4444493 0.4443923 0.4443354 0.4442785 0.4442216 0.4441647 [218] 0.4441079 0.4440512 0.4439945 0.4439378 0.4438812 0.4438246 0.4437680 [225] 0.4437115 0.4436551 0.4435987 0.4435423 0.4434860 0.4434298 0.4433736 [232] 0.4433174 0.4432614 0.4432053 0.4431493 0.4430934 0.4430376 0.4429817 [239] 0.4429260 0.4428703 0.4428147 0.4427591 0.4427036 0.4426482 0.4425928 [246] 0.4425375 0.4424822 0.4424270 0.4423719 0.4423169 0.4422619 0.4422070 [253] 0.4421522 0.4420974 0.4420427 0.4419881 0.4419336 0.4418791 0.4418247 [260] 0.4417704 0.4417162 0.4416620 0.4416079 0.4415539 0.4415000 0.4414462 [267] 0.4413924 0.4413387 0.4412852 0.4412317 0.4411782 0.4411249 0.4410717 [274] 0.4410185 0.4409654 0.4409124 0.4408596 0.4408068 0.4407540 0.4407014 [281] 0.4406489 0.4405965 0.4405441 0.4404919 0.4404398 0.4403877 0.4403358 [288] 0.4402839 0.4402321 0.4401805 0.4401289 0.4400775 0.4400261 0.4399749 [295] 0.4399237 0.4398727 0.4398217 0.4397709 0.4397201 0.4396695 0.4396190 [302] 0.4395686 0.4395183 0.4394681 0.4394180 0.4393680 0.4393182 0.4392684 [309] 0.4392188 0.4391692 0.4391198 0.4390705 0.4390213 0.4389722 0.4389233 [316] 0.4388744 0.4388257 0.4387771 0.4387286 0.4386802 0.4386320 0.4385838 [323] 0.4385358 0.4384879 0.4384401 0.4383925 0.4383449 0.4382975 0.4382502 [330] 0.4382031 0.4381560 0.4381091 0.4380624 0.4380157 0.4379692 0.4379228 [337] 0.4378765 0.4378303 0.4377843 0.4377384 0.4376926 0.4376470 0.4376015 [344] 0.4375561 0.4375109 0.4374658 0.4374208 0.4373760 0.4373313 0.4372867 [351] 0.4372423 0.4371979 0.4371538 0.4371097 0.4370658 0.4370221 0.4369785 [358] 0.4369350 0.4368916 0.4368484 0.4368053 0.4367624 0.4367196 0.4366770 [365] 0.4366345 0.4365921 0.4365499 0.4365078 0.4364658 0.4364240 0.4363824 [372] 0.4363408 0.4362995 0.4362582 0.4362172 0.4361762 0.4361354 0.4360948 [379] 0.4360543 0.4360139 0.4359737 0.4359336 0.4358937 0.4358539 0.4358143 [386] 0.4357748 0.4357355 0.4356963 0.4356573 0.4356184 0.4355797 0.4355411 [393] 0.4355027 0.4354644 0.4354263 0.4353883 0.4353505 0.4353128 0.4352753 [400] 0.4352379 0.4352007 > mx [1] 0.4556135 > 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/1cqt61197582637.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/2pu2h1197582637.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/3w0qm1197582637.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/49quk1197582638.tab") > > system("convert tmp/1cqt61197582637.ps tmp/1cqt61197582637.png") > system("convert tmp/2pu2h1197582637.ps tmp/2pu2h1197582637.png") > system("convert tmp/3w0qm1197582637.ps tmp/3w0qm1197582637.png") > > > proc.time() user system elapsed 1.027 0.502 1.145