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(106.8,113.7,102.5,96.6,92.1,95.6,102.3,98.6,98.2,104.5,84,73.8,103.9,106,97.2,102.6,89,93.8,116.7,106.8,98.5,118.7,90,91.9,113.3,113.1,104.1,108.7,96.7,101,116.9,105.8,99,129.4,83,88.9,115.9,104.2,113.4,112.2,100.8,107.3,126.6,102.9,117.9,128.8,87.5,93.8,122.7,126.2,124.6,116.7,115.2,111.1,129.9,113.3,118.5,133.5,102.1,102.4) > #'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.3684084 0.3686197 0.3688308 0.3690416 0.3692523 0.3694626 0.3696728 [8] 0.3698827 0.3700924 0.3703018 0.3705110 0.3707199 0.3709286 0.3711371 [15] 0.3713453 0.3715533 0.3717610 0.3719685 0.3721758 0.3723828 0.3725896 [22] 0.3727961 0.3730024 0.3732084 0.3734142 0.3736197 0.3738250 0.3740300 [29] 0.3742348 0.3744394 0.3746436 0.3748477 0.3750515 0.3752550 0.3754583 [36] 0.3756613 0.3758641 0.3760666 0.3762689 0.3764709 0.3766727 0.3768742 [43] 0.3770754 0.3772764 0.3774771 0.3776776 0.3778778 0.3780778 0.3782775 [50] 0.3784769 0.3786761 0.3788751 0.3790737 0.3792721 0.3794703 0.3796681 [57] 0.3798658 0.3800631 0.3802602 0.3804570 0.3806536 0.3808499 0.3810459 [64] 0.3812417 0.3814372 0.3816324 0.3818274 0.3820221 0.3822165 0.3824107 [71] 0.3826046 0.3827982 0.3829916 0.3831847 0.3833775 0.3835701 0.3837623 [78] 0.3839543 0.3841461 0.3843375 0.3845287 0.3847197 0.3849103 0.3851007 [85] 0.3852908 0.3854806 0.3856702 0.3858595 0.3860485 0.3862372 0.3864256 [92] 0.3866138 0.3868017 0.3869893 0.3871767 0.3873637 0.3875505 0.3877371 [99] 0.3879233 0.3881092 0.3882949 0.3884803 0.3886654 0.3888503 0.3890348 [106] 0.3892191 0.3894031 0.3895868 0.3897702 0.3899534 0.3901362 0.3903188 [113] 0.3905011 0.3906831 0.3908649 0.3910463 0.3912275 0.3914084 0.3915890 [120] 0.3917693 0.3919493 0.3921290 0.3923085 0.3924877 0.3926666 0.3928451 [127] 0.3930235 0.3932015 0.3933792 0.3935567 0.3937338 0.3939107 0.3940873 [134] 0.3942636 0.3944396 0.3946153 0.3947907 0.3949659 0.3951407 0.3953153 [141] 0.3954895 0.3956635 0.3958372 0.3960106 0.3961837 0.3963565 0.3965290 [148] 0.3967012 0.3968732 0.3970448 0.3972162 0.3973872 0.3975580 0.3977285 [155] 0.3978986 0.3980685 0.3982381 0.3984074 0.3985764 0.3987451 0.3989136 [162] 0.3990817 0.3992495 0.3994170 0.3995843 0.3997512 0.3999179 0.4000842 [169] 0.4002503 0.4004160 0.4005815 0.4007466 0.4009115 0.4010761 0.4012404 [176] 0.4014043 0.4015680 0.4017314 0.4018945 0.4020573 0.4022198 0.4023820 [183] 0.4025439 0.4027055 0.4028668 0.4030278 0.4031885 0.4033489 0.4035090 [190] 0.4036688 0.4038283 0.4039875 0.4041464 0.4043050 0.4044633 0.4046214 [197] 0.4047791 0.4049365 0.4050936 0.4052504 0.4054069 0.4055631 0.4057190 [204] 0.4058747 0.4060300 0.4061850 0.4063397 0.4064941 0.4066482 0.4068020 [211] 0.4069555 0.4071087 0.4072617 0.4074143 0.4075666 0.4077186 0.4078703 [218] 0.4080217 0.4081728 0.4083236 0.4084741 0.4086243 0.4087741 0.4089237 [225] 0.4090730 0.4092220 0.4093707 0.4095191 0.4096672 0.4098150 0.4099624 [232] 0.4101096 0.4102565 0.4104031 0.4105493 0.4106953 0.4108410 0.4109863 [239] 0.4111314 0.4112761 0.4114206 0.4115647 0.4117086 0.4118522 0.4119954 [246] 0.4121383 0.4122810 0.4124233 0.4125654 0.4127071 0.4128485 0.4129897 [253] 0.4131305 0.4132710 0.4134112 0.4135512 0.4136908 0.4138301 0.4139691 [260] 0.4141078 0.4142462 0.4143843 0.4145221 0.4146596 0.4147968 0.4149337 [267] 0.4150703 0.4152066 0.4153426 0.4154783 0.4156137 0.4157488 0.4158836 [274] 0.4160181 0.4161522 0.4162861 0.4164197 0.4165530 0.4166859 0.4168186 [281] 0.4169510 0.4170830 0.4172148 0.4173463 0.4174774 0.4176083 0.4177389 [288] 0.4178691 0.4179991 0.4181287 0.4182581 0.4183871 0.4185159 0.4186443 [295] 0.4187725 0.4189003 0.4190279 0.4191551 0.4192821 0.4194087 0.4195351 [302] 0.4196611 0.4197869 0.4199123 0.4200375 0.4201623 0.4202869 0.4204111 [309] 0.4205351 0.4206587 0.4207821 0.4209051 0.4210279 0.4211503 0.4212725 [316] 0.4213943 0.4215159 0.4216371 0.4217581 0.4218787 0.4219991 0.4221191 [323] 0.4222389 0.4223584 0.4224775 0.4225964 0.4227150 0.4228332 0.4229512 [330] 0.4230689 0.4231863 0.4233033 0.4234201 0.4235366 0.4236528 0.4237687 [337] 0.4238843 0.4239996 0.4241146 0.4242293 0.4243437 0.4244578 0.4245717 [344] 0.4246852 0.4247984 0.4249113 0.4250240 0.4251363 0.4252484 0.4253601 [351] 0.4254716 0.4255827 0.4256936 0.4258042 0.4259145 0.4260244 0.4261341 [358] 0.4262435 0.4263526 0.4264614 0.4265700 0.4266782 0.4267861 0.4268938 [365] 0.4270011 0.4271082 0.4272149 0.4273214 0.4274276 0.4275335 0.4276390 [372] 0.4277444 0.4278494 0.4279541 0.4280585 0.4281627 0.4282665 0.4283701 [379] 0.4284733 0.4285763 0.4286790 0.4287814 0.4288835 0.4289853 0.4290868 [386] 0.4291881 0.4292890 0.4293897 0.4294901 0.4295902 0.4296900 0.4297895 [393] 0.4298887 0.4299876 0.4300863 0.4301846 0.4302827 0.4303805 0.4304780 [400] 0.4305752 0.4306721 > mx [1] 0.4306721 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/147ut1195996933.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/2si341195996933.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/31t5f1195996933.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/4tqme1195996933.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/5mgx61195996933.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/6pgp71195996933.tab") > > system("convert tmp/147ut1195996933.ps tmp/147ut1195996933.png") > system("convert tmp/2si341195996933.ps tmp/2si341195996933.png") > system("convert tmp/31t5f1195996933.ps tmp/31t5f1195996933.png") > system("convert tmp/4tqme1195996933.ps tmp/4tqme1195996933.png") > system("convert tmp/5mgx61195996933.ps tmp/5mgx61195996933.png") > > > proc.time() user system elapsed 1.335 0.790 1.580