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(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.0,103.6,94.1,98.7,119.5,112.7,104.4,124.7,89.1,97.0,121.6,118.8,114.0,111.5,97.2,102.5,113.4,109.8,104.9,126.1,80.0,96.8,117.2,112.3,117.3,111.1,102.2,104.3,122.9,107.6,121.3,131.5,89.0,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.3404810 0.3407908 0.3411005 0.3414101 0.3417194 0.3420286 0.3423377 [8] 0.3426465 0.3429552 0.3432637 0.3435721 0.3438803 0.3441883 0.3444961 [15] 0.3448038 0.3451113 0.3454186 0.3457258 0.3460327 0.3463395 0.3466461 [22] 0.3469525 0.3472588 0.3475648 0.3478707 0.3481764 0.3484819 0.3487872 [29] 0.3490924 0.3493973 0.3497021 0.3500067 0.3503111 0.3506153 0.3509193 [36] 0.3512231 0.3515267 0.3518301 0.3521334 0.3524364 0.3527393 0.3530419 [43] 0.3533444 0.3536466 0.3539487 0.3542505 0.3545522 0.3548536 0.3551548 [50] 0.3554559 0.3557567 0.3560574 0.3563578 0.3566580 0.3569580 0.3572578 [57] 0.3575574 0.3578568 0.3581560 0.3584549 0.3587537 0.3590522 0.3593505 [64] 0.3596486 0.3599465 0.3602442 0.3605416 0.3608389 0.3611359 0.3614327 [71] 0.3617292 0.3620256 0.3623217 0.3626176 0.3629133 0.3632088 0.3635040 [78] 0.3637990 0.3640938 0.3643883 0.3646826 0.3649767 0.3652706 0.3655642 [85] 0.3658576 0.3661508 0.3664437 0.3667364 0.3670289 0.3673211 0.3676131 [92] 0.3679048 0.3681964 0.3684876 0.3687787 0.3690695 0.3693600 0.3696503 [99] 0.3699404 0.3702302 0.3705198 0.3708091 0.3710982 0.3713871 0.3716757 [106] 0.3719640 0.3722521 0.3725399 0.3728275 0.3731149 0.3734020 0.3736888 [113] 0.3739754 0.3742617 0.3745478 0.3748336 0.3751192 0.3754045 0.3756896 [120] 0.3759744 0.3762589 0.3765432 0.3768272 0.3771109 0.3773944 0.3776776 [127] 0.3779606 0.3782433 0.3785257 0.3788079 0.3790898 0.3793714 0.3796528 [134] 0.3799338 0.3802147 0.3804952 0.3807755 0.3810555 0.3813352 0.3816147 [141] 0.3818939 0.3821728 0.3824515 0.3827298 0.3830079 0.3832857 0.3835632 [148] 0.3838405 0.3841175 0.3843942 0.3846706 0.3849467 0.3852226 0.3854981 [155] 0.3857734 0.3860484 0.3863231 0.3865975 0.3868717 0.3871455 0.3874191 [162] 0.3876924 0.3879654 0.3882381 0.3885105 0.3887826 0.3890544 0.3893259 [169] 0.3895972 0.3898681 0.3901388 0.3904091 0.3906792 0.3909489 0.3912184 [176] 0.3914876 0.3917565 0.3920250 0.3922933 0.3925613 0.3928289 0.3930963 [183] 0.3933634 0.3936301 0.3938966 0.3941628 0.3944286 0.3946942 0.3949594 [190] 0.3952243 0.3954890 0.3957533 0.3960173 0.3962810 0.3965444 0.3968075 [197] 0.3970703 0.3973327 0.3975949 0.3978567 0.3981182 0.3983794 0.3986403 [204] 0.3989009 0.3991612 0.3994211 0.3996807 0.3999400 0.4001990 0.4004577 [211] 0.4007161 0.4009741 0.4012318 0.4014892 0.4017463 0.4020030 0.4022595 [218] 0.4025156 0.4027713 0.4030268 0.4032819 0.4035367 0.4037912 0.4040454 [225] 0.4042992 0.4045527 0.4048058 0.4050587 0.4053112 0.4055634 0.4058152 [232] 0.4060667 0.4063179 0.4065688 0.4068193 0.4070695 0.4073193 0.4075689 [239] 0.4078180 0.4080669 0.4083154 0.4085636 0.4088114 0.4090589 0.4093061 [246] 0.4095529 0.4097994 0.4100455 0.4102913 0.4105368 0.4107819 0.4110267 [253] 0.4112711 0.4115152 0.4117589 0.4120023 0.4122454 0.4124881 0.4127305 [260] 0.4129725 0.4132142 0.4134555 0.4136965 0.4139371 0.4141774 0.4144174 [267] 0.4146569 0.4148962 0.4151351 0.4153736 0.4156118 0.4158496 0.4160871 [274] 0.4163242 0.4165610 0.4167974 0.4170335 0.4172692 0.4175046 0.4177396 [281] 0.4179742 0.4182085 0.4184424 0.4186760 0.4189092 0.4191421 0.4193746 [288] 0.4196067 0.4198385 0.4200699 0.4203010 0.4205317 0.4207620 0.4209920 [295] 0.4212216 0.4214508 0.4216797 0.4219082 0.4221364 0.4223642 0.4225916 [302] 0.4228187 0.4230454 0.4232717 0.4234977 0.4237233 0.4239485 0.4241734 [309] 0.4243979 0.4246220 0.4248458 0.4250691 0.4252922 0.4255148 0.4257371 [316] 0.4259590 0.4261805 0.4264017 0.4266225 0.4268429 0.4270629 0.4272826 [323] 0.4275019 0.4277208 0.4279394 0.4281575 0.4283753 0.4285928 0.4288098 [330] 0.4290265 0.4292428 0.4294587 0.4296742 0.4298894 0.4301042 0.4303186 [337] 0.4305326 0.4307462 0.4309595 0.4311724 0.4313849 0.4315970 0.4318087 [344] 0.4320201 0.4322311 0.4324417 0.4326519 0.4328617 0.4330712 0.4332803 [351] 0.4334889 0.4336972 0.4339051 0.4341127 0.4343198 0.4345266 0.4347329 [358] 0.4349389 0.4351445 0.4353498 0.4355546 0.4357590 0.4359631 0.4361667 [365] 0.4363700 0.4365729 0.4367754 0.4369775 0.4371792 0.4373806 0.4375815 [372] 0.4377820 0.4379822 0.4381820 0.4383814 0.4385803 0.4387789 0.4389771 [379] 0.4391750 0.4393724 0.4395694 0.4397660 0.4399623 0.4401581 0.4403536 [386] 0.4405486 0.4407433 0.4409376 0.4411314 0.4413249 0.4415180 0.4417107 [393] 0.4419030 0.4420949 0.4422864 0.4424775 0.4426682 0.4428585 0.4430484 [400] 0.4432379 0.4434270 > mx [1] 0.443427 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/19z301194296445.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/21e7j1194296445.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/38zxl1194296445.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/4x7hr1194296445.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/57zqj1194296445.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/6jael1194296445.tab") > > system("convert tmp/19z301194296445.ps tmp/19z301194296445.png") > system("convert tmp/21e7j1194296445.ps tmp/21e7j1194296445.png") > system("convert tmp/38zxl1194296445.ps tmp/38zxl1194296445.png") > system("convert tmp/4x7hr1194296445.ps tmp/4x7hr1194296445.png") > system("convert tmp/57zqj1194296445.ps tmp/57zqj1194296445.png") > > > proc.time() user system elapsed 1.353 0.797 1.619