R version 2.8.0 (2008-10-20) Copyright (C) 2008 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(93.0,99.2,112.2,112.1,103.3,108.2,90.4,72.8,111.0,117.9,111.3,110.5,94.8,100.4,132.1,114.6,101.9,130.2,84.0,86.4,122.3,120.9,110.2,112.6,102.0,105.0,130.5,115.5,103.7,130.9,89.1,93.8,123.8,111.9,118.3,116.9,103.6,116.6,141.3,107.0,125.2,136.4,91.6,95.3,132.3,130.6,131.9,118.6,114.3,111.3,126.5,112.1,119.3,142.4,101.1,97.4,129.1,136.9,129.8,123.9) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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.3924699 0.3926533 0.3928363 0.3930190 0.3932013 0.3933833 0.3935649 [8] 0.3937463 0.3939272 0.3941079 0.3942882 0.3944681 0.3946478 0.3948270 [15] 0.3950060 0.3951846 0.3953628 0.3955408 0.3957183 0.3958956 0.3960724 [22] 0.3962490 0.3964252 0.3966010 0.3967765 0.3969517 0.3971265 0.3973010 [29] 0.3974751 0.3976489 0.3978223 0.3979954 0.3981681 0.3983405 0.3985126 [36] 0.3986842 0.3988556 0.3990266 0.3991972 0.3993675 0.3995374 0.3997070 [43] 0.3998762 0.4000451 0.4002136 0.4003818 0.4005496 0.4007171 0.4008842 [50] 0.4010510 0.4012174 0.4013835 0.4015491 0.4017145 0.4018795 0.4020441 [57] 0.4022084 0.4023723 0.4025359 0.4026991 0.4028619 0.4030244 0.4031866 [64] 0.4033484 0.4035098 0.4036708 0.4038315 0.4039919 0.4041519 0.4043115 [71] 0.4044708 0.4046297 0.4047883 0.4049464 0.4051043 0.4052618 0.4054189 [78] 0.4055756 0.4057320 0.4058880 0.4060437 0.4061990 0.4063540 0.4065086 [85] 0.4066628 0.4068166 0.4069701 0.4071233 0.4072761 0.4074285 0.4075805 [92] 0.4077322 0.4078835 0.4080345 0.4081851 0.4083353 0.4084852 0.4086347 [99] 0.4087839 0.4089327 0.4090811 0.4092291 0.4093768 0.4095242 0.4096711 [106] 0.4098177 0.4099640 0.4101098 0.4102553 0.4104005 0.4105452 0.4106897 [113] 0.4108337 0.4109774 0.4111207 0.4112637 0.4114062 0.4115485 0.4116903 [120] 0.4118318 0.4119729 0.4121137 0.4122541 0.4123941 0.4125338 0.4126731 [127] 0.4128120 0.4129506 0.4130888 0.4132266 0.4133641 0.4135012 0.4136380 [134] 0.4137743 0.4139103 0.4140460 0.4141813 0.4143162 0.4144507 0.4145849 [141] 0.4147187 0.4148522 0.4149853 0.4151180 0.4152504 0.4153823 0.4155140 [148] 0.4156452 0.4157761 0.4159067 0.4160368 0.4161666 0.4162961 0.4164251 [155] 0.4165538 0.4166822 0.4168102 0.4169378 0.4170650 0.4171919 0.4173184 [162] 0.4174446 0.4175703 0.4176958 0.4178208 0.4179455 0.4180699 0.4181938 [169] 0.4183174 0.4184407 0.4185635 0.4186861 0.4188082 0.4189300 0.4190514 [176] 0.4191725 0.4192932 0.4194135 0.4195335 0.4196531 0.4197723 0.4198912 [183] 0.4200097 0.4201279 0.4202457 0.4203631 0.4204802 0.4205969 0.4207132 [190] 0.4208292 0.4209448 0.4210601 0.4211750 0.4212895 0.4214037 0.4215175 [197] 0.4216310 0.4217441 0.4218568 0.4219692 0.4220812 0.4221929 0.4223042 [204] 0.4224151 0.4225257 0.4226359 0.4227458 0.4228553 0.4229644 0.4230732 [211] 0.4231817 0.4232897 0.4233974 0.4235048 0.4236118 0.4237184 0.4238247 [218] 0.4239306 0.4240362 0.4241414 0.4242463 0.4243508 0.4244549 0.4245587 [225] 0.4246622 0.4247652 0.4248680 0.4249703 0.4250723 0.4251740 0.4252753 [232] 0.4253763 0.4254769 0.4255771 0.4256770 0.4257765 0.4258757 0.4259745 [239] 0.4260730 0.4261712 0.4262689 0.4263664 0.4264634 0.4265601 0.4266565 [246] 0.4267525 0.4268482 0.4269435 0.4270385 0.4271331 0.4272274 0.4273213 [253] 0.4274149 0.4275081 0.4276009 0.4276935 0.4277856 0.4278775 0.4279690 [260] 0.4280601 0.4281509 0.4282413 0.4283314 0.4284211 0.4285105 0.4285996 [267] 0.4286883 0.4287767 0.4288647 0.4289524 0.4290397 0.4291267 0.4292133 [274] 0.4292996 0.4293856 0.4294712 0.4295564 0.4296414 0.4297259 0.4298102 [281] 0.4298941 0.4299776 0.4300608 0.4301437 0.4302262 0.4303084 0.4303903 [288] 0.4304718 0.4305530 0.4306338 0.4307143 0.4307945 0.4308743 0.4309538 [295] 0.4310329 0.4311117 0.4311902 0.4312683 0.4313461 0.4314236 0.4315007 [302] 0.4315775 0.4316539 0.4317301 0.4318058 0.4318813 0.4319564 0.4320312 [309] 0.4321056 0.4321797 0.4322535 0.4323270 0.4324001 0.4324729 0.4325453 [316] 0.4326175 0.4326892 0.4327607 0.4328318 0.4329026 0.4329731 0.4330432 [323] 0.4331131 0.4331825 0.4332517 0.4333205 0.4333890 0.4334572 0.4335250 [330] 0.4335926 0.4336597 0.4337266 0.4337932 0.4338594 0.4339253 0.4339908 [337] 0.4340561 0.4341210 0.4341856 0.4342498 0.4343138 0.4343774 0.4344407 [344] 0.4345037 0.4345663 0.4346287 0.4346907 0.4347524 0.4348138 0.4348748 [351] 0.4349355 0.4349960 0.4350560 0.4351158 0.4351753 0.4352344 0.4352932 [358] 0.4353517 0.4354099 0.4354678 0.4355254 0.4355826 0.4356395 0.4356961 [365] 0.4357524 0.4358084 0.4358641 0.4359194 0.4359744 0.4360292 0.4360836 [372] 0.4361377 0.4361915 0.4362449 0.4362981 0.4363509 0.4364035 0.4364557 [379] 0.4365076 0.4365592 0.4366105 0.4366615 0.4367122 0.4367626 0.4368127 [386] 0.4368624 0.4369119 0.4369610 0.4370099 0.4370584 0.4371066 0.4371546 [393] 0.4372022 0.4372495 0.4372965 0.4373432 0.4373896 0.4374357 0.4374815 [400] 0.4375270 0.4375722 > mx [1] 0.4375722 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/10yn31229086852.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/2da4p1229086852.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/38t5m1229086852.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/4ga5g1229086852.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x) > qqline(x) > grid() > mtext('Original Data') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/59e431229086852.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x1) > qqline(x1) > grid() > mtext('Transformed Data') > dev.off() null device 1 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > 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/6z4b61229086852.tab") > > system("convert tmp/10yn31229086852.ps tmp/10yn31229086852.png") > system("convert tmp/2da4p1229086852.ps tmp/2da4p1229086852.png") > system("convert tmp/38t5m1229086852.ps tmp/38t5m1229086852.png") > system("convert tmp/4ga5g1229086852.ps tmp/4ga5g1229086852.png") > system("convert tmp/59e431229086852.ps tmp/59e431229086852.png") > > > proc.time() user system elapsed 1.078 0.785 1.313