R version 2.7.2 (2008-08-25) 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(77.9,60,99.5,95,105.6,102.5,93.3,97.3,127,111.7,96.4,133,72.2,95.8,124.1,127.6,110.7,104.6,112.7,115.3,139.4,119,97.4,154,81.5,88.8,127.7,105.1,114.9,106.4,104.5,121.6,141.4,99,126.7,134.1,81.3,88.6,132.7,132.9,134.4,103.7,119.7,115,132.9,108.5,113.9,142,97.7,92.2,128.8,134.9,128.2,114.8,117.9,119.1,120.7,129.1,117.6,129.2,99.1) > #'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.4298482 0.4298749 0.4299006 0.4299251 0.4299485 0.4299708 0.4299920 [8] 0.4300120 0.4300310 0.4300488 0.4300656 0.4300812 0.4300957 0.4301091 [15] 0.4301213 0.4301325 0.4301425 0.4301514 0.4301592 0.4301659 0.4301715 [22] 0.4301760 0.4301793 0.4301816 0.4301827 0.4301827 0.4301816 0.4301793 [29] 0.4301760 0.4301715 0.4301660 0.4301593 0.4301515 0.4301426 0.4301325 [36] 0.4301214 0.4301091 0.4300958 0.4300813 0.4300657 0.4300490 0.4300312 [43] 0.4300123 0.4299923 0.4299712 0.4299490 0.4299256 0.4299012 0.4298757 [50] 0.4298490 0.4298213 0.4297924 0.4297625 0.4297315 0.4296993 0.4296661 [57] 0.4296317 0.4295963 0.4295598 0.4295222 0.4294835 0.4294437 0.4294028 [64] 0.4293608 0.4293177 0.4292736 0.4292284 0.4291821 0.4291347 0.4290862 [71] 0.4290366 0.4289860 0.4289343 0.4288815 0.4288277 0.4287728 0.4287168 [78] 0.4286597 0.4286016 0.4285424 0.4284822 0.4284209 0.4283585 0.4282951 [85] 0.4282306 0.4281651 0.4280985 0.4280309 0.4279622 0.4278925 0.4278217 [92] 0.4277499 0.4276770 0.4276031 0.4275282 0.4274523 0.4273753 0.4272972 [99] 0.4272182 0.4271381 0.4270570 0.4269749 0.4268917 0.4268076 0.4267224 [106] 0.4266362 0.4265490 0.4264608 0.4263716 0.4262814 0.4261902 0.4260979 [113] 0.4260047 0.4259105 0.4258153 0.4257191 0.4256219 0.4255238 0.4254246 [120] 0.4253245 0.4252234 0.4251213 0.4250183 0.4249143 0.4248093 0.4247033 [127] 0.4245964 0.4244885 0.4243797 0.4242699 0.4241592 0.4240475 0.4239348 [134] 0.4238213 0.4237067 0.4235913 0.4234749 0.4233576 0.4232393 0.4231201 [141] 0.4230000 0.4228790 0.4227570 0.4226342 0.4225104 0.4223857 0.4222601 [148] 0.4221336 0.4220062 0.4218779 0.4217487 0.4216186 0.4214876 0.4213557 [155] 0.4212229 0.4210893 0.4209547 0.4208193 0.4206831 0.4205459 0.4204079 [162] 0.4202690 0.4201293 0.4199887 0.4198472 0.4197049 0.4195618 0.4194178 [169] 0.4192729 0.4191272 0.4189807 0.4188333 0.4186851 0.4185361 0.4183863 [176] 0.4182356 0.4180841 0.4179318 0.4177786 0.4176247 0.4174700 0.4173144 [183] 0.4171581 0.4170009 0.4168430 0.4166842 0.4165247 0.4163644 0.4162033 [190] 0.4160414 0.4158788 0.4157154 0.4155512 0.4153862 0.4152205 0.4150540 [197] 0.4148867 0.4147187 0.4145500 0.4143805 0.4142102 0.4140392 0.4138675 [204] 0.4136950 0.4135218 0.4133479 0.4131732 0.4129978 0.4128217 0.4126449 [211] 0.4124673 0.4122891 0.4121101 0.4119304 0.4117501 0.4115690 0.4113872 [218] 0.4112048 0.4110216 0.4108378 0.4106532 0.4104680 0.4102821 0.4100956 [225] 0.4099083 0.4097204 0.4095319 0.4093426 0.4091527 0.4089622 0.4087710 [232] 0.4085791 0.4083866 0.4081935 0.4079997 0.4078053 0.4076102 0.4074145 [239] 0.4072182 0.4070212 0.4068237 0.4066255 0.4064266 0.4062272 0.4060272 [246] 0.4058265 0.4056253 0.4054234 0.4052210 0.4050179 0.4048143 0.4046100 [253] 0.4044052 0.4041998 0.4039938 0.4037872 0.4035800 0.4033723 0.4031640 [260] 0.4029552 0.4027457 0.4025358 0.4023252 0.4021141 0.4019024 0.4016902 [267] 0.4014775 0.4012642 0.4010503 0.4008360 0.4006210 0.4004056 0.4001896 [274] 0.3999731 0.3997561 0.3995385 0.3993204 0.3991018 0.3988827 0.3986631 [281] 0.3984430 0.3982224 0.3980012 0.3977796 0.3975575 0.3973348 0.3971117 [288] 0.3968881 0.3966640 0.3964394 0.3962144 0.3959888 0.3957628 0.3955363 [295] 0.3953094 0.3950819 0.3948540 0.3946257 0.3943969 0.3941676 0.3939379 [302] 0.3937077 0.3934771 0.3932460 0.3930145 0.3927825 0.3925501 0.3923172 [309] 0.3920840 0.3918503 0.3916161 0.3913815 0.3911466 0.3909111 0.3906753 [316] 0.3904391 0.3902024 0.3899653 0.3897278 0.3894899 0.3892516 0.3890129 [323] 0.3887738 0.3885343 0.3882944 0.3880541 0.3878135 0.3875724 0.3873309 [330] 0.3870891 0.3868469 0.3866043 0.3863613 0.3861179 0.3858742 0.3856301 [337] 0.3853857 0.3851408 0.3848956 0.3846501 0.3844042 0.3841579 0.3839113 [344] 0.3836643 0.3834170 0.3831693 0.3829213 0.3826729 0.3824242 0.3821752 [351] 0.3819258 0.3816761 0.3814260 0.3811756 0.3809249 0.3806739 0.3804225 [358] 0.3801709 0.3799189 0.3796665 0.3794139 0.3791610 0.3789077 0.3786541 [365] 0.3784002 0.3781461 0.3778916 0.3776368 0.3773817 0.3771263 0.3768706 [372] 0.3766146 0.3763583 0.3761018 0.3758449 0.3755878 0.3753304 0.3750727 [379] 0.3748147 0.3745564 0.3742979 0.3740390 0.3737799 0.3735206 0.3732609 [386] 0.3730010 0.3727409 0.3724804 0.3722197 0.3719588 0.3716976 0.3714361 [393] 0.3711744 0.3709124 0.3706502 0.3703877 0.3701249 0.3698620 0.3695987 [400] 0.3693353 0.3690716 > mx [1] 0.4301827 > mxli [1] -1.75 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1uk891226262666.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/2pbfv1226262666.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/3v61r1226262666.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/45y2q1226262666.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/5gi401226262666.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/6ckp11226262667.tab") > > system("convert tmp/1uk891226262666.ps tmp/1uk891226262666.png") > system("convert tmp/2pbfv1226262666.ps tmp/2pbfv1226262666.png") > system("convert tmp/3v61r1226262666.ps tmp/3v61r1226262666.png") > system("convert tmp/45y2q1226262666.ps tmp/45y2q1226262666.png") > system("convert tmp/5gi401226262666.ps tmp/5gi401226262666.png") > > > proc.time() user system elapsed 1.409 0.861 1.715