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(98.50,96.70,113.10,100.00,104.70,108.50,90.50,88.60,105.40,119.90,107.20,84.10,101.40,105.10,118.70,113.80,113.80,118.90,98.50,91.00,120.70,127.90,112.40,93.10,107.50,107.30,114.80,120.80,112.20,123.30,100.60,86.70,123.60,125.30,111.10,98.40,102.30,105.00,128.20,124.70,116.10,131.20,97.70,88.80,132.80,113.90,112.60,104.30,107.50,106.00,117.30,123.10,114.30,132.00,92.30,93.70,121.30,113.60,116.30,98.30,111.90,109.30,133.20,118.00,131.60,134.10,96.70,99.80,128.30,134.90,130.70,107.30,121.60,120.60,140.50,124.80,129.90,145.60,109.70,105.30) > #'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.3914805 0.3916055 0.3917304 0.3918553 0.3919801 0.3921048 0.3922294 [8] 0.3923539 0.3924784 0.3926027 0.3927270 0.3928512 0.3929753 0.3930993 [15] 0.3932233 0.3933471 0.3934709 0.3935945 0.3937181 0.3938416 0.3939650 [22] 0.3940883 0.3942116 0.3943347 0.3944578 0.3945808 0.3947036 0.3948264 [29] 0.3949491 0.3950717 0.3951942 0.3953167 0.3954390 0.3955612 0.3956834 [36] 0.3958055 0.3959274 0.3960493 0.3961711 0.3962928 0.3964144 0.3965359 [43] 0.3966573 0.3967786 0.3968998 0.3970210 0.3971420 0.3972629 0.3973838 [50] 0.3975045 0.3976252 0.3977457 0.3978662 0.3979866 0.3981068 0.3982270 [57] 0.3983471 0.3984670 0.3985869 0.3987067 0.3988264 0.3989459 0.3990654 [64] 0.3991848 0.3993041 0.3994232 0.3995423 0.3996613 0.3997802 0.3998990 [71] 0.4000176 0.4001362 0.4002547 0.4003731 0.4004913 0.4006095 0.4007276 [78] 0.4008455 0.4009634 0.4010811 0.4011988 0.4013163 0.4014338 0.4015511 [85] 0.4016683 0.4017855 0.4019025 0.4020194 0.4021362 0.4022529 0.4023695 [92] 0.4024860 0.4026024 0.4027187 0.4028349 0.4029509 0.4030669 0.4031827 [99] 0.4032985 0.4034141 0.4035296 0.4036450 0.4037603 0.4038755 0.4039906 [106] 0.4041056 0.4042204 0.4043352 0.4044498 0.4045644 0.4046788 0.4047931 [113] 0.4049073 0.4050214 0.4051353 0.4052492 0.4053629 0.4054766 0.4055901 [120] 0.4057035 0.4058168 0.4059300 0.4060430 0.4061560 0.4062688 0.4063815 [127] 0.4064941 0.4066066 0.4067190 0.4068313 0.4069434 0.4070554 0.4071673 [134] 0.4072791 0.4073908 0.4075024 0.4076138 0.4077251 0.4078363 0.4079474 [141] 0.4080584 0.4081692 0.4082800 0.4083906 0.4085011 0.4086114 0.4087217 [148] 0.4088318 0.4089418 0.4090517 0.4091615 0.4092711 0.4093807 0.4094901 [155] 0.4095994 0.4097085 0.4098176 0.4099265 0.4100353 0.4101440 0.4102525 [162] 0.4103609 0.4104692 0.4105774 0.4106855 0.4107934 0.4109012 0.4110089 [169] 0.4111165 0.4112239 0.4113312 0.4114384 0.4115455 0.4116524 0.4117592 [176] 0.4118659 0.4119724 0.4120789 0.4121852 0.4122913 0.4123974 0.4125033 [183] 0.4126091 0.4127147 0.4128203 0.4129257 0.4130310 0.4131361 0.4132411 [190] 0.4133460 0.4134508 0.4135554 0.4136599 0.4137643 0.4138685 0.4139726 [197] 0.4140766 0.4141805 0.4142842 0.4143878 0.4144912 0.4145946 0.4146978 [204] 0.4148008 0.4149038 0.4150066 0.4151092 0.4152118 0.4153141 0.4154164 [211] 0.4155185 0.4156205 0.4157224 0.4158241 0.4159257 0.4160272 0.4161285 [218] 0.4162297 0.4163308 0.4164317 0.4165325 0.4166332 0.4167337 0.4168340 [225] 0.4169343 0.4170344 0.4171344 0.4172342 0.4173339 0.4174335 0.4175329 [232] 0.4176322 0.4177313 0.4178304 0.4179292 0.4180280 0.4181266 0.4182250 [239] 0.4183234 0.4184215 0.4185196 0.4186175 0.4187153 0.4188129 0.4189104 [246] 0.4190077 0.4191049 0.4192020 0.4192989 0.4193957 0.4194924 0.4195889 [253] 0.4196852 0.4197815 0.4198775 0.4199735 0.4200693 0.4201649 0.4202604 [260] 0.4203558 0.4204510 0.4205461 0.4206411 0.4207359 0.4208305 0.4209251 [267] 0.4210194 0.4211137 0.4212078 0.4213017 0.4213955 0.4214892 0.4215827 [274] 0.4216760 0.4217692 0.4218623 0.4219553 0.4220480 0.4221407 0.4222332 [281] 0.4223255 0.4224177 0.4225098 0.4226017 0.4226935 0.4227851 0.4228766 [288] 0.4229679 0.4230591 0.4231501 0.4232410 0.4233317 0.4234223 0.4235128 [295] 0.4236031 0.4236932 0.4237832 0.4238731 0.4239628 0.4240524 0.4241418 [302] 0.4242310 0.4243201 0.4244091 0.4244979 0.4245866 0.4246751 0.4247635 [309] 0.4248517 0.4249398 0.4250277 0.4251154 0.4252031 0.4252905 0.4253778 [316] 0.4254650 0.4255520 0.4256389 0.4257256 0.4258122 0.4258986 0.4259848 [323] 0.4260710 0.4261569 0.4262427 0.4263284 0.4264139 0.4264992 0.4265844 [330] 0.4266695 0.4267544 0.4268391 0.4269237 0.4270081 0.4270924 0.4271765 [337] 0.4272605 0.4273443 0.4274280 0.4275115 0.4275949 0.4276781 0.4277612 [344] 0.4278441 0.4279268 0.4280094 0.4280918 0.4281741 0.4282563 0.4283382 [351] 0.4284200 0.4285017 0.4285832 0.4286646 0.4287458 0.4288268 0.4289077 [358] 0.4289885 0.4290690 0.4291495 0.4292297 0.4293098 0.4293898 0.4294696 [365] 0.4295492 0.4296287 0.4297080 0.4297872 0.4298662 0.4299451 0.4300238 [372] 0.4301023 0.4301807 0.4302590 0.4303370 0.4304150 0.4304927 0.4305703 [379] 0.4306478 0.4307250 0.4308022 0.4308791 0.4309560 0.4310326 0.4311091 [386] 0.4311854 0.4312616 0.4313376 0.4314135 0.4314892 0.4315648 0.4316401 [393] 0.4317154 0.4317904 0.4318653 0.4319401 0.4320147 0.4320891 0.4321634 [400] 0.4322375 0.4323115 > mx [1] 0.4323115 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1o5xd1194255994.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/27noi1194255994.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/3w7b01194255994.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/4zbxu1194255994.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/59dsc1194255994.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/6eg6d1194255994.tab") > > system("convert tmp/1o5xd1194255994.ps tmp/1o5xd1194255994.png") > system("convert tmp/27noi1194255994.ps tmp/27noi1194255994.png") > system("convert tmp/3w7b01194255994.ps tmp/3w7b01194255994.png") > system("convert tmp/4zbxu1194255994.ps tmp/4zbxu1194255994.png") > system("convert tmp/59dsc1194255994.ps tmp/59dsc1194255994.png") > > > proc.time() user system elapsed 1.360 0.804 2.290