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. > x <- c(97.3,101,113.2,101,105.7,113.9,86.4,96.5,103.3,114.9,105.8,94.2,98.4,99.4,108.8,112.6,104.4,112.2,81.1,97.1,112.6,113.8,107.8,103.2,103.3,101.2,107.7,110.4,101.9,115.9,89.9,88.6,117.2,123.9,100,103.6,94.1,98.7,119.5,112.7,104.4,124.7,89.1,97,121.6,118.8,114,111.5,97.2,102.5,113.4,109.8,104.9,126.1,80,96.8,117.2,112.3,117.3,111.1,102.2,104.3,122.9,107.6,121.3,131.5,89,104.4,128.9,135.9,133.3,121.3,120.5,120.4,137.9,126.1,133.2,146.6,103.4,117.2) > #'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 Normality Plot (v1.0.4) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxnorm.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(qnorm(ppoints(x), mean=0, sd=1),x1) + if (mx < c[i]) + { + mx <- c[i] + mxli <- l[i] + } + } > c [1] 0.4048308 0.4051407 0.4054505 0.4057600 0.4060693 0.4063784 0.4066872 [8] 0.4069959 0.4073043 0.4076124 0.4079204 0.4082281 0.4085355 0.4088428 [15] 0.4091498 0.4094565 0.4097631 0.4100693 0.4103754 0.4106812 0.4109868 [22] 0.4112921 0.4115972 0.4119021 0.4122067 0.4125110 0.4128151 0.4131190 [29] 0.4134226 0.4137260 0.4140291 0.4143319 0.4146346 0.4149369 0.4152390 [36] 0.4155409 0.4158425 0.4161438 0.4164449 0.4167457 0.4170463 0.4173466 [43] 0.4176466 0.4179464 0.4182459 0.4185451 0.4188441 0.4191428 0.4194413 [50] 0.4197394 0.4200373 0.4203350 0.4206324 0.4209294 0.4212263 0.4215228 [57] 0.4218191 0.4221151 0.4224108 0.4227062 0.4230014 0.4232963 0.4235909 [64] 0.4238852 0.4241792 0.4244730 0.4247665 0.4250596 0.4253525 0.4256451 [71] 0.4259375 0.4262295 0.4265212 0.4268127 0.4271039 0.4273947 0.4276853 [78] 0.4279756 0.4282656 0.4285552 0.4288446 0.4291337 0.4294225 0.4297110 [85] 0.4299992 0.4302871 0.4305747 0.4308620 0.4311489 0.4314356 0.4317220 [92] 0.4320081 0.4322938 0.4325793 0.4328644 0.4331492 0.4334337 0.4337179 [99] 0.4340018 0.4342854 0.4345687 0.4348516 0.4351342 0.4354165 0.4356985 [106] 0.4359802 0.4362616 0.4365426 0.4368233 0.4371037 0.4373837 0.4376635 [113] 0.4379429 0.4382220 0.4385008 0.4387792 0.4390573 0.4393351 0.4396125 [120] 0.4398896 0.4401664 0.4404429 0.4407190 0.4409948 0.4412702 0.4415453 [127] 0.4418201 0.4420946 0.4423687 0.4426424 0.4429159 0.4431889 0.4434617 [134] 0.4437341 0.4440061 0.4442778 0.4445492 0.4448202 0.4450909 0.4453612 [141] 0.4456312 0.4459008 0.4461701 0.4464391 0.4467076 0.4469759 0.4472437 [148] 0.4475113 0.4477784 0.4480453 0.4483117 0.4485778 0.4488436 0.4491090 [155] 0.4493740 0.4496387 0.4499030 0.4501669 0.4504305 0.4506937 0.4509566 [162] 0.4512191 0.4514812 0.4517430 0.4520044 0.4522654 0.4525261 0.4527864 [169] 0.4530463 0.4533059 0.4535651 0.4538239 0.4540824 0.4543404 0.4545981 [176] 0.4548555 0.4551124 0.4553690 0.4556252 0.4558810 0.4561365 0.4563916 [183] 0.4566463 0.4569006 0.4571545 0.4574081 0.4576612 0.4579140 0.4581664 [190] 0.4584184 0.4586701 0.4589213 0.4591722 0.4594227 0.4596728 0.4599225 [197] 0.4601718 0.4604207 0.4606693 0.4609174 0.4611652 0.4614125 0.4616595 [204] 0.4619061 0.4621523 0.4623981 0.4626435 0.4628885 0.4631331 0.4633773 [211] 0.4636211 0.4638645 0.4641075 0.4643501 0.4645924 0.4648342 0.4650756 [218] 0.4653166 0.4655572 0.4657974 0.4660372 0.4662766 0.4665156 0.4667542 [225] 0.4669924 0.4672302 0.4674675 0.4677045 0.4679411 0.4681772 0.4684129 [232] 0.4686483 0.4688832 0.4691177 0.4693518 0.4695855 0.4698187 0.4700516 [239] 0.4702840 0.4705161 0.4707477 0.4709789 0.4712096 0.4714400 0.4716699 [246] 0.4718995 0.4721286 0.4723573 0.4725855 0.4728134 0.4730408 0.4732678 [253] 0.4734944 0.4737206 0.4739463 0.4741716 0.4743965 0.4746210 0.4748450 [260] 0.4750687 0.4752919 0.4755146 0.4757370 0.4759589 0.4761804 0.4764014 [267] 0.4766221 0.4768423 0.4770620 0.4772814 0.4775003 0.4777187 0.4779368 [274] 0.4781544 0.4783716 0.4785883 0.4788046 0.4790205 0.4792360 0.4794510 [281] 0.4796656 0.4798797 0.4800934 0.4803067 0.4805195 0.4807319 0.4809438 [288] 0.4811553 0.4813664 0.4815770 0.4817872 0.4819970 0.4822063 0.4824152 [295] 0.4826236 0.4828316 0.4830391 0.4832462 0.4834529 0.4836591 0.4838649 [302] 0.4840702 0.4842751 0.4844795 0.4846835 0.4848871 0.4850902 0.4852928 [309] 0.4854950 0.4856968 0.4858981 0.4860989 0.4862993 0.4864993 0.4866988 [316] 0.4868979 0.4870965 0.4872946 0.4874923 0.4876896 0.4878864 0.4880827 [323] 0.4882786 0.4884741 0.4886691 0.4888636 0.4890577 0.4892513 0.4894445 [330] 0.4896372 0.4898295 0.4900213 0.4902126 0.4904035 0.4905940 0.4907839 [337] 0.4909735 0.4911625 0.4913511 0.4915393 0.4917270 0.4919142 0.4921010 [344] 0.4922873 0.4924731 0.4926585 0.4928435 0.4930279 0.4932119 0.4933955 [351] 0.4935786 0.4937612 0.4939433 0.4941250 0.4943063 0.4944871 0.4946674 [358] 0.4948472 0.4950266 0.4952055 0.4953840 0.4955619 0.4957395 0.4959165 [365] 0.4960931 0.4962692 0.4964449 0.4966201 0.4967948 0.4969691 0.4971429 [372] 0.4973162 0.4974890 0.4976614 0.4978333 0.4980048 0.4981758 0.4983463 [379] 0.4985163 0.4986859 0.4988550 0.4990237 0.4991918 0.4993595 0.4995268 [386] 0.4996935 0.4998598 0.5000256 0.5001910 0.5003558 0.5005202 0.5006842 [393] 0.5008476 0.5010106 0.5011731 0.5013352 0.5014967 0.5016578 0.5018185 [400] 0.5019786 0.5021383 > mx [1] 0.5021383 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1or8h1194257394.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(l,c,main='Box-Cox Normality Plot',xlab='Lambda',ylab='correlation') > mtext(paste('Optimal Lambda =',mxli)) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/2padi1194257394.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(x,main='Histogram of Original Data',xlab='X',ylab='frequency') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/32asz1194257394.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(x1,main='Histogram of Transformed Data',xlab='X',ylab='frequency') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/4ozdw1194257394.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x) > grid() > mtext('Original Data') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/5r7nt1194257394.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x1) > grid() > mtext('Transformed Data') > 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 Normality 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',header=TRUE) > a<-table.element(a,mxli) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/6ls3v1194257395.tab") > > system("convert tmp/1or8h1194257394.ps tmp/1or8h1194257394.png") > system("convert tmp/2padi1194257394.ps tmp/2padi1194257394.png") > system("convert tmp/32asz1194257394.ps tmp/32asz1194257394.png") > system("convert tmp/4ozdw1194257394.ps tmp/4ozdw1194257394.png") > system("convert tmp/5r7nt1194257394.ps tmp/5r7nt1194257394.png") > > > proc.time() user system elapsed 1.341 0.817 1.573