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(108.4,117,103.8,100.8,110.6,104,112.6,107.3,98.9,109.8,104.9,102.2,123.9,124.9,112.7,121.9,100.6,104.3,120.4,107.5,102.9,125.6,107.5,108.8,128.4,121.1,119.5,128.7,108.7,105.5,119.8,111.3,110.6,120.1,97.5,107.7,127.3,117.2,119.8,116.2,111,112.4,130.6,109.1,118.8,123.9,101.6,112.8,128,129.6,125.8,119.5,115.7,113.6,129.7,112,116.8,126.3,112.9,115.9) > #'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.3911763 0.3911598 0.3911433 0.3911267 0.3911099 0.3910931 0.3910762 [8] 0.3910593 0.3910422 0.3910251 0.3910078 0.3909905 0.3909731 0.3909556 [15] 0.3909381 0.3909204 0.3909027 0.3908849 0.3908670 0.3908490 0.3908309 [22] 0.3908127 0.3907945 0.3907762 0.3907578 0.3907393 0.3907207 0.3907020 [29] 0.3906833 0.3906644 0.3906455 0.3906265 0.3906074 0.3905883 0.3905690 [36] 0.3905497 0.3905303 0.3905108 0.3904912 0.3904715 0.3904518 0.3904319 [43] 0.3904120 0.3903920 0.3903719 0.3903518 0.3903315 0.3903112 0.3902908 [50] 0.3902703 0.3902497 0.3902290 0.3902083 0.3901875 0.3901666 0.3901456 [57] 0.3901245 0.3901033 0.3900821 0.3900608 0.3900394 0.3900179 0.3899963 [64] 0.3899747 0.3899529 0.3899311 0.3899092 0.3898872 0.3898652 0.3898430 [71] 0.3898208 0.3897985 0.3897761 0.3897537 0.3897311 0.3897085 0.3896858 [78] 0.3896630 0.3896401 0.3896172 0.3895941 0.3895710 0.3895478 0.3895245 [85] 0.3895012 0.3894777 0.3894542 0.3894306 0.3894069 0.3893832 0.3893593 [92] 0.3893354 0.3893114 0.3892873 0.3892632 0.3892389 0.3892146 0.3891902 [99] 0.3891657 0.3891412 0.3891165 0.3890918 0.3890670 0.3890421 0.3890172 [106] 0.3889922 0.3889670 0.3889418 0.3889166 0.3888912 0.3888658 0.3888403 [113] 0.3888147 0.3887890 0.3887633 0.3887374 0.3887115 0.3886856 0.3886595 [120] 0.3886334 0.3886071 0.3885808 0.3885545 0.3885280 0.3885015 0.3884749 [127] 0.3884482 0.3884214 0.3883946 0.3883677 0.3883407 0.3883136 0.3882864 [134] 0.3882592 0.3882319 0.3882045 0.3881770 0.3881495 0.3881219 0.3880942 [141] 0.3880664 0.3880386 0.3880107 0.3879827 0.3879546 0.3879264 0.3878982 [148] 0.3878699 0.3878415 0.3878131 0.3877845 0.3877559 0.3877272 0.3876985 [155] 0.3876696 0.3876407 0.3876117 0.3875826 0.3875535 0.3875243 0.3874950 [162] 0.3874656 0.3874362 0.3874067 0.3873771 0.3873474 0.3873177 0.3872878 [169] 0.3872579 0.3872280 0.3871979 0.3871678 0.3871376 0.3871074 0.3870770 [176] 0.3870466 0.3870161 0.3869855 0.3869549 0.3869242 0.3868934 0.3868625 [183] 0.3868316 0.3868006 0.3867695 0.3867384 0.3867071 0.3866758 0.3866445 [190] 0.3866130 0.3865815 0.3865499 0.3865182 0.3864865 0.3864547 0.3864228 [197] 0.3863908 0.3863588 0.3863267 0.3862945 0.3862623 0.3862299 0.3861976 [204] 0.3861651 0.3861325 0.3860999 0.3860673 0.3860345 0.3860017 0.3859688 [211] 0.3859358 0.3859028 0.3858697 0.3858365 0.3858032 0.3857699 0.3857365 [218] 0.3857030 0.3856695 0.3856359 0.3856022 0.3855684 0.3855346 0.3855007 [225] 0.3854668 0.3854327 0.3853986 0.3853645 0.3853302 0.3852959 0.3852615 [232] 0.3852271 0.3851925 0.3851579 0.3851233 0.3850885 0.3850537 0.3850189 [239] 0.3849839 0.3849489 0.3849138 0.3848787 0.3848435 0.3848082 0.3847728 [246] 0.3847374 0.3847019 0.3846664 0.3846307 0.3845950 0.3845593 0.3845234 [253] 0.3844875 0.3844516 0.3844155 0.3843794 0.3843432 0.3843070 0.3842707 [260] 0.3842343 0.3841979 0.3841613 0.3841248 0.3840881 0.3840514 0.3840146 [267] 0.3839778 0.3839409 0.3839039 0.3838668 0.3838297 0.3837925 0.3837553 [274] 0.3837180 0.3836806 0.3836431 0.3836056 0.3835681 0.3835304 0.3834927 [281] 0.3834549 0.3834171 0.3833792 0.3833412 0.3833032 0.3832651 0.3832269 [288] 0.3831887 0.3831504 0.3831120 0.3830736 0.3830351 0.3829965 0.3829579 [295] 0.3829192 0.3828805 0.3828416 0.3828028 0.3827638 0.3827248 0.3826857 [302] 0.3826466 0.3826074 0.3825681 0.3825288 0.3824894 0.3824500 0.3824104 [309] 0.3823709 0.3823312 0.3822915 0.3822517 0.3822119 0.3821720 0.3821320 [316] 0.3820920 0.3820519 0.3820118 0.3819716 0.3819313 0.3818910 0.3818506 [323] 0.3818101 0.3817696 0.3817290 0.3816884 0.3816477 0.3816069 0.3815661 [330] 0.3815252 0.3814843 0.3814432 0.3814022 0.3813610 0.3813198 0.3812786 [337] 0.3812373 0.3811959 0.3811545 0.3811130 0.3810714 0.3810298 0.3809881 [344] 0.3809464 0.3809046 0.3808627 0.3808208 0.3807788 0.3807368 0.3806947 [351] 0.3806525 0.3806103 0.3805680 0.3805257 0.3804833 0.3804409 0.3803984 [358] 0.3803558 0.3803132 0.3802705 0.3802277 0.3801849 0.3801421 0.3800991 [365] 0.3800562 0.3800131 0.3799700 0.3799269 0.3798837 0.3798404 0.3797971 [372] 0.3797537 0.3797103 0.3796668 0.3796232 0.3795796 0.3795359 0.3794922 [379] 0.3794484 0.3794046 0.3793607 0.3793167 0.3792727 0.3792287 0.3791846 [386] 0.3791404 0.3790961 0.3790519 0.3790075 0.3789631 0.3789187 0.3788741 [393] 0.3788296 0.3787850 0.3787403 0.3786956 0.3786508 0.3786059 0.3785610 [400] 0.3785161 0.3784711 > mx [1] 0.3911763 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1m56f1194300417.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/2jnsf1194300417.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/3cd8u1194300417.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/4r29d1194300417.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/5c16q1194300417.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/6i57v1194300417.tab") > > system("convert tmp/1m56f1194300417.ps tmp/1m56f1194300417.png") > system("convert tmp/2jnsf1194300417.ps tmp/2jnsf1194300417.png") > system("convert tmp/3cd8u1194300417.ps tmp/3cd8u1194300417.png") > system("convert tmp/4r29d1194300417.ps tmp/4r29d1194300417.png") > system("convert tmp/5c16q1194300417.ps tmp/5c16q1194300417.png") > > > proc.time() user system elapsed 1.381 0.803 1.640