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(4.5,5.6,5.4,5.4,5.2,5.3,5.3,5.3,5.2,5.2,5.0,5.0,5.0,6.5,6.5,6.6,6.2,6.2,6.2,6.1,6.1,6.1,5.9,5.9,5.9,6.2,6.1,6.2,6.6,6.6,6.7,5.8,5.7,5.7,6.1,6.2,6.2,6.2,6.1,6.2,6.5,6.5,6.5,6.0,6.3,6.0,6.1,6.1,6.1,6.2,6.1,6.2,6.8,6.8,6.8,6.7,6.7,6.7,5.7,5.6,5.6,5.8,5.7,5.7,6.1,6.1,5.9,5.9,5.8,5.6,5.5,5.5,5.4) > x <- c(16.8,18.7,18.7,18.7,16.8,16.8,16.8,16.0,16.0,16.0,18.0,18.0,18.0,18.0,18.0,18.0,21.6,21.6,21.6,20.1,20.1,20.1,22.9,22.9,22.9,24.0,24.0,24.0,20.3,20.3,20.3,15.8,15.8,15.8,23.2,23.2,23.2,20.9,20.9,20.9,19.8,19.8,19.8,20.6,20.6,20.6,21.1,21.1,21.1,22.4,22.4,22.4,20.5,20.5,20.5,18.4,18.4,18.4,17.6,17.6,17.6,18.5,18.5,18.5,17.3,17.3,17.3,16.2,16.2,16.2,18.0,18.0,18.0) > #'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.5250612 0.5249731 0.5248847 0.5247959 0.5247069 0.5246176 0.5245279 [8] 0.5244380 0.5243478 0.5242572 0.5241664 0.5240753 0.5239838 0.5238921 [15] 0.5238001 0.5237077 0.5236151 0.5235222 0.5234289 0.5233354 0.5232416 [22] 0.5231474 0.5230530 0.5229583 0.5228633 0.5227679 0.5226723 0.5225764 [29] 0.5224802 0.5223836 0.5222868 0.5221897 0.5220923 0.5219946 0.5218966 [36] 0.5217982 0.5216996 0.5216007 0.5215015 0.5214020 0.5213022 0.5212021 [43] 0.5211017 0.5210010 0.5209000 0.5207987 0.5206971 0.5205953 0.5204931 [50] 0.5203906 0.5202878 0.5201847 0.5200814 0.5199777 0.5198737 0.5197695 [57] 0.5196649 0.5195601 0.5194549 0.5193495 0.5192437 0.5191377 0.5190314 [64] 0.5189247 0.5188178 0.5187106 0.5186031 0.5184953 0.5183872 0.5182788 [71] 0.5181701 0.5180611 0.5179518 0.5178422 0.5177323 0.5176222 0.5175117 [78] 0.5174010 0.5172899 0.5171786 0.5170669 0.5169550 0.5168428 0.5167303 [85] 0.5166175 0.5165044 0.5163910 0.5162773 0.5161633 0.5160490 0.5159345 [92] 0.5158196 0.5157045 0.5155891 0.5154733 0.5153573 0.5152410 0.5151244 [99] 0.5150075 0.5148903 0.5147729 0.5146551 0.5145370 0.5144187 0.5143001 [106] 0.5141811 0.5140619 0.5139424 0.5138227 0.5137026 0.5135822 0.5134616 [113] 0.5133406 0.5132194 0.5130979 0.5129761 0.5128540 0.5127316 0.5126089 [120] 0.5124860 0.5123627 0.5122392 0.5121154 0.5119913 0.5118669 0.5117422 [127] 0.5116173 0.5114920 0.5113665 0.5112407 0.5111146 0.5109882 0.5108615 [134] 0.5107346 0.5106074 0.5104798 0.5103520 0.5102240 0.5100956 0.5099669 [141] 0.5098380 0.5097088 0.5095793 0.5094495 0.5093195 0.5091891 0.5090585 [148] 0.5089276 0.5087964 0.5086649 0.5085332 0.5084012 0.5082689 0.5081363 [155] 0.5080034 0.5078703 0.5077369 0.5076031 0.5074692 0.5073349 0.5072004 [162] 0.5070656 0.5069305 0.5067951 0.5066595 0.5065235 0.5063873 0.5062509 [169] 0.5061141 0.5059771 0.5058398 0.5057022 0.5055644 0.5054263 0.5052879 [176] 0.5051492 0.5050102 0.5048710 0.5047315 0.5045918 0.5044517 0.5043114 [183] 0.5041708 0.5040300 0.5038889 0.5037475 0.5036058 0.5034638 0.5033216 [190] 0.5031792 0.5030364 0.5028934 0.5027501 0.5026065 0.5024627 0.5023186 [197] 0.5021743 0.5020296 0.5018847 0.5017396 0.5015941 0.5014484 0.5013025 [204] 0.5011562 0.5010097 0.5008630 0.5007160 0.5005687 0.5004211 0.5002733 [211] 0.5001252 0.4999769 0.4998282 0.4996794 0.4995302 0.4993808 0.4992312 [218] 0.4990813 0.4989311 0.4987806 0.4986299 0.4984790 0.4983277 0.4981762 [225] 0.4980245 0.4978725 0.4977202 0.4975677 0.4974149 0.4972619 0.4971086 [232] 0.4969550 0.4968012 0.4966472 0.4964929 0.4963383 0.4961834 0.4960284 [239] 0.4958730 0.4957174 0.4955616 0.4954055 0.4952491 0.4950925 0.4949356 [246] 0.4947785 0.4946211 0.4944635 0.4943057 0.4941475 0.4939892 0.4938305 [253] 0.4936717 0.4935126 0.4933532 0.4931936 0.4930337 0.4928736 0.4927132 [260] 0.4925526 0.4923918 0.4922307 0.4920693 0.4919077 0.4917459 0.4915838 [267] 0.4914215 0.4912589 0.4910961 0.4909330 0.4907697 0.4906062 0.4904424 [274] 0.4902783 0.4901141 0.4899495 0.4897848 0.4896198 0.4894546 0.4892891 [281] 0.4891234 0.4889574 0.4887912 0.4886248 0.4884581 0.4882912 0.4881241 [288] 0.4879567 0.4877891 0.4876212 0.4874531 0.4872848 0.4871163 0.4869475 [295] 0.4867785 0.4866092 0.4864397 0.4862700 0.4861000 0.4859298 0.4857594 [302] 0.4855888 0.4854179 0.4852468 0.4850755 0.4849039 0.4847321 0.4845601 [309] 0.4843878 0.4842153 0.4840426 0.4838697 0.4836965 0.4835231 0.4833495 [316] 0.4831757 0.4830016 0.4828273 0.4826528 0.4824781 0.4823032 0.4821280 [323] 0.4819526 0.4817770 0.4816011 0.4814250 0.4812488 0.4810723 0.4808955 [330] 0.4807186 0.4805414 0.4803641 0.4801865 0.4800086 0.4798306 0.4796524 [337] 0.4794739 0.4792952 0.4791163 0.4789372 0.4787579 0.4785784 0.4783986 [344] 0.4782186 0.4780385 0.4778581 0.4776775 0.4774967 0.4773157 0.4771344 [351] 0.4769530 0.4767713 0.4765895 0.4764074 0.4762251 0.4760427 0.4758600 [358] 0.4756771 0.4754940 0.4753107 0.4751272 0.4749435 0.4747595 0.4745754 [365] 0.4743911 0.4742066 0.4740218 0.4738369 0.4736518 0.4734664 0.4732809 [372] 0.4730951 0.4729092 0.4727231 0.4725367 0.4723502 0.4721635 0.4719766 [379] 0.4717894 0.4716021 0.4714146 0.4712269 0.4710390 0.4708509 0.4706626 [386] 0.4704741 0.4702854 0.4700966 0.4699075 0.4697182 0.4695288 0.4693392 [393] 0.4691493 0.4689593 0.4687691 0.4685787 0.4683881 0.4681974 0.4680064 [400] 0.4678153 0.4676240 > mx [1] 0.5250612 > 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/1hh3d1194296484.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/2cz6o1194296484.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/31q991194296484.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/408n31194296484.tab") > > system("convert tmp/1hh3d1194296484.ps tmp/1hh3d1194296484.png") > system("convert tmp/2cz6o1194296484.ps tmp/2cz6o1194296484.png") > system("convert tmp/31q991194296484.ps tmp/31q991194296484.png") > > > proc.time() user system elapsed 1.071 0.539 1.275