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(6.5,6.4,6.2,6.2,6.3,7.5,7.4,7.4,7.4,7.4,7.4,7.2,7.2,7.2,7.5,7.4,7.4,8,8.1,8.1,8.1,8.1,8.1,7.9,7.9,8,8.1,8.1,8.1,8.5,8.5,8.6,8.4,8.4,8.4,7.7,7.8,7.9,8.7,8.8,8.8,8.5,8.5,8.5,8.4,8.5,8.5,8.3,8.4,8.4,8.4,8.4,8.4,8.5,8.5,8.5,8.5,8.5,8.5,8.3,8.3,8.4,8.2,8.2,8.1,8.1,8,7.8,7.9,7.8,7.7,7.9,7.8) > x <- c(7.7,7.7,7.8,7.8,7.8,7.9,7.9,7.9,7.9,8,8,8.1,8.1,8.1,8.2,8.3,8.3,8.3,8.4,8.4,8.5,8.6,8.6,8.6,8.7,8.7,8.7,8.7,8.7,8.7,8.7,8.8,8.8,8.8,8.8,8.8,8.9,8.9,8.8,8.8,8.8,8.8,8.7,8.7,8.7,8.8,8.8,8.7,8.7,8.6,8.5,8.4,8.3,8.3,8.4,8.4,8.3,8.2,8.1,8,7.9,7.9,7.8,7.8,7.7,7.7,7.6,7.5,7.4,7.2,7.1,7,7) > #'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.4634220 0.4635400 0.4636580 0.4637758 0.4638935 0.4640111 0.4641286 [8] 0.4642460 0.4643633 0.4644805 0.4645975 0.4647145 0.4648313 0.4649481 [15] 0.4650647 0.4651813 0.4652977 0.4654140 0.4655302 0.4656463 0.4657623 [22] 0.4658782 0.4659940 0.4661096 0.4662252 0.4663406 0.4664560 0.4665712 [29] 0.4666864 0.4668014 0.4669163 0.4670311 0.4671458 0.4672604 0.4673748 [36] 0.4674892 0.4676035 0.4677176 0.4678317 0.4679456 0.4680594 0.4681732 [43] 0.4682868 0.4684003 0.4685137 0.4686269 0.4687401 0.4688532 0.4689661 [50] 0.4690790 0.4691917 0.4693043 0.4694169 0.4695293 0.4696416 0.4697538 [57] 0.4698658 0.4699778 0.4700897 0.4702014 0.4703131 0.4704246 0.4705360 [64] 0.4706474 0.4707586 0.4708697 0.4709806 0.4710915 0.4712023 0.4713129 [71] 0.4714235 0.4715339 0.4716443 0.4717545 0.4718646 0.4719746 0.4720845 [78] 0.4721942 0.4723039 0.4724135 0.4725229 0.4726323 0.4727415 0.4728506 [85] 0.4729596 0.4730685 0.4731773 0.4732860 0.4733945 0.4735030 0.4736113 [92] 0.4737196 0.4738277 0.4739357 0.4740436 0.4741514 0.4742591 0.4743667 [99] 0.4744741 0.4745815 0.4746887 0.4747958 0.4749028 0.4750098 0.4751165 [106] 0.4752232 0.4753298 0.4754363 0.4755426 0.4756489 0.4757550 0.4758610 [113] 0.4759669 0.4760727 0.4761784 0.4762840 0.4763894 0.4764948 0.4766000 [120] 0.4767052 0.4768102 0.4769151 0.4770199 0.4771246 0.4772292 0.4773336 [127] 0.4774380 0.4775422 0.4776463 0.4777504 0.4778543 0.4779581 0.4780617 [134] 0.4781653 0.4782688 0.4783721 0.4784754 0.4785785 0.4786815 0.4787844 [141] 0.4788872 0.4789899 0.4790925 0.4791949 0.4792973 0.4793995 0.4795016 [148] 0.4796036 0.4797055 0.4798073 0.4799090 0.4800106 0.4801120 0.4802133 [155] 0.4803146 0.4804157 0.4805167 0.4806176 0.4807184 0.4808190 0.4809196 [162] 0.4810201 0.4811204 0.4812206 0.4813207 0.4814207 0.4815206 0.4816204 [169] 0.4817200 0.4818196 0.4819190 0.4820184 0.4821176 0.4822167 0.4823157 [176] 0.4824146 0.4825133 0.4826120 0.4827105 0.4828090 0.4829073 0.4830055 [183] 0.4831036 0.4832016 0.4832994 0.4833972 0.4834948 0.4835924 0.4836898 [190] 0.4837871 0.4838843 0.4839814 0.4840784 0.4841752 0.4842720 0.4843686 [197] 0.4844652 0.4845616 0.4846579 0.4847541 0.4848501 0.4849461 0.4850420 [204] 0.4851377 0.4852333 0.4853289 0.4854243 0.4855196 0.4856147 0.4857098 [211] 0.4858048 0.4858996 0.4859944 0.4860890 0.4861835 0.4862779 0.4863722 [218] 0.4864663 0.4865604 0.4866544 0.4867482 0.4868419 0.4869355 0.4870290 [225] 0.4871224 0.4872157 0.4873089 0.4874019 0.4874949 0.4875877 0.4876804 [232] 0.4877730 0.4878655 0.4879579 0.4880501 0.4881423 0.4882343 0.4883263 [239] 0.4884181 0.4885098 0.4886014 0.4886929 0.4887843 0.4888755 0.4889667 [246] 0.4890577 0.4891486 0.4892394 0.4893301 0.4894207 0.4895112 0.4896016 [253] 0.4896918 0.4897820 0.4898720 0.4899619 0.4900517 0.4901414 0.4902310 [260] 0.4903205 0.4904098 0.4904991 0.4905882 0.4906772 0.4907661 0.4908549 [267] 0.4909436 0.4910322 0.4911206 0.4912090 0.4912972 0.4913854 0.4914734 [274] 0.4915613 0.4916491 0.4917368 0.4918243 0.4919118 0.4919991 0.4920864 [281] 0.4921735 0.4922605 0.4923474 0.4924342 0.4925209 0.4926074 0.4926939 [288] 0.4927802 0.4928665 0.4929526 0.4930386 0.4931245 0.4932103 0.4932959 [295] 0.4933815 0.4934670 0.4935523 0.4936375 0.4937226 0.4938077 0.4938925 [302] 0.4939773 0.4940620 0.4941466 0.4942310 0.4943153 0.4943996 0.4944837 [309] 0.4945677 0.4946516 0.4947354 0.4948190 0.4949026 0.4949861 0.4950694 [316] 0.4951526 0.4952357 0.4953187 0.4954016 0.4954844 0.4955671 0.4956497 [323] 0.4957321 0.4958145 0.4958967 0.4959788 0.4960608 0.4961427 0.4962245 [330] 0.4963062 0.4963877 0.4964692 0.4965505 0.4966318 0.4967129 0.4967939 [337] 0.4968748 0.4969556 0.4970363 0.4971168 0.4971973 0.4972777 0.4973579 [344] 0.4974380 0.4975180 0.4975980 0.4976778 0.4977574 0.4978370 0.4979165 [351] 0.4979958 0.4980751 0.4981542 0.4982333 0.4983122 0.4983910 0.4984697 [358] 0.4985483 0.4986267 0.4987051 0.4987834 0.4988615 0.4989396 0.4990175 [365] 0.4990953 0.4991730 0.4992506 0.4993281 0.4994055 0.4994827 0.4995599 [372] 0.4996370 0.4997139 0.4997907 0.4998675 0.4999441 0.5000206 0.5000970 [379] 0.5001733 0.5002494 0.5003255 0.5004014 0.5004773 0.5005530 0.5006287 [386] 0.5007042 0.5007796 0.5008549 0.5009301 0.5010052 0.5010802 0.5011550 [393] 0.5012298 0.5013044 0.5013790 0.5014534 0.5015277 0.5016019 0.5016760 [400] 0.5017500 0.5018239 > mx [1] 0.5018239 > 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/1hwfr1194261693.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/2jq6o1194261693.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/35zlz1194261693.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/47rx21194261699.tab") > > system("convert tmp/1hwfr1194261693.ps tmp/1hwfr1194261693.png") > system("convert tmp/2jq6o1194261693.ps tmp/2jq6o1194261693.png") > system("convert tmp/35zlz1194261693.ps tmp/35zlz1194261693.png") > > > proc.time() user system elapsed 1.847 0.813 1.962