R version 2.8.1 (2008-12-22) 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(8,8.1,7.7,7.5,7.6,7.8,7.8,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.2,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,7.9,7.7,7.4,7.5,8,8.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.3593010 -0.3592934 -0.3592858 -0.3592780 -0.3592701 -0.3592621 [7] -0.3592541 -0.3592459 -0.3592376 -0.3592293 -0.3592208 -0.3592123 [13] -0.3592036 -0.3591949 -0.3591860 -0.3591771 -0.3591680 -0.3591589 [19] -0.3591496 -0.3591403 -0.3591308 -0.3591213 -0.3591117 -0.3591019 [25] -0.3590921 -0.3590822 -0.3590722 -0.3590620 -0.3590518 -0.3590415 [31] -0.3590311 -0.3590206 -0.3590099 -0.3589992 -0.3589884 -0.3589775 [37] -0.3589665 -0.3589554 -0.3589442 -0.3589329 -0.3589215 -0.3589100 [43] -0.3588984 -0.3588868 -0.3588750 -0.3588631 -0.3588511 -0.3588390 [49] -0.3588269 -0.3588146 -0.3588022 -0.3587898 -0.3587772 -0.3587645 [55] -0.3587518 -0.3587389 -0.3587260 -0.3587129 -0.3586998 -0.3586865 [61] -0.3586732 -0.3586598 -0.3586462 -0.3586326 -0.3586189 -0.3586050 [67] -0.3585911 -0.3585771 -0.3585630 -0.3585488 -0.3585345 -0.3585201 [73] -0.3585056 -0.3584910 -0.3584763 -0.3584615 -0.3584466 -0.3584316 [79] -0.3584165 -0.3584013 -0.3583861 -0.3583707 -0.3583552 -0.3583397 [85] -0.3583240 -0.3583083 -0.3582924 -0.3582765 -0.3582604 -0.3582443 [91] -0.3582280 -0.3582117 -0.3581953 -0.3581788 -0.3581621 -0.3581454 [97] -0.3581286 -0.3581117 -0.3580947 -0.3580776 -0.3580604 -0.3580431 [103] -0.3580257 -0.3580083 -0.3579907 -0.3579730 -0.3579552 -0.3579374 [109] -0.3579194 -0.3579014 -0.3578832 -0.3578650 -0.3578466 -0.3578282 [115] -0.3578097 -0.3577910 -0.3577723 -0.3577535 -0.3577346 -0.3577156 [121] -0.3576965 -0.3576773 -0.3576580 -0.3576386 -0.3576191 -0.3575996 [127] -0.3575799 -0.3575601 -0.3575403 -0.3575203 -0.3575003 -0.3574802 [133] -0.3574599 -0.3574396 -0.3574192 -0.3573986 -0.3573780 -0.3573573 [139] -0.3573365 -0.3573156 -0.3572946 -0.3572736 -0.3572524 -0.3572311 [145] -0.3572098 -0.3571883 -0.3571668 -0.3571451 -0.3571234 -0.3571015 [151] -0.3570796 -0.3570576 -0.3570355 -0.3570133 -0.3569910 -0.3569686 [157] -0.3569461 -0.3569235 -0.3569009 -0.3568781 -0.3568552 -0.3568323 [163] -0.3568092 -0.3567861 -0.3567629 -0.3567396 -0.3567162 -0.3566926 [169] -0.3566690 -0.3566454 -0.3566216 -0.3565977 -0.3565737 -0.3565497 [175] -0.3565255 -0.3565013 -0.3564769 -0.3564525 -0.3564280 -0.3564034 [181] -0.3563787 -0.3563539 -0.3563290 -0.3563040 -0.3562789 -0.3562538 [187] -0.3562285 -0.3562032 -0.3561777 -0.3561522 -0.3561266 -0.3561009 [193] -0.3560751 -0.3560492 -0.3560232 -0.3559971 -0.3559710 -0.3559447 [199] -0.3559183 -0.3558919 -0.3558654 -0.3558388 -0.3558120 -0.3557852 [205] -0.3557584 -0.3557314 -0.3557043 -0.3556771 -0.3556499 -0.3556225 [211] -0.3555951 -0.3555676 -0.3555400 -0.3555123 -0.3554845 -0.3554566 [217] -0.3554286 -0.3554006 -0.3553724 -0.3553442 -0.3553158 -0.3552874 [223] -0.3552589 -0.3552303 -0.3552016 -0.3551728 -0.3551440 -0.3551150 [229] -0.3550860 -0.3550568 -0.3550276 -0.3549983 -0.3549689 -0.3549394 [235] -0.3549098 -0.3548802 -0.3548504 -0.3548206 -0.3547907 -0.3547606 [241] -0.3547305 -0.3547003 -0.3546701 -0.3546397 -0.3546092 -0.3545787 [247] -0.3545480 -0.3545173 -0.3544865 -0.3544556 -0.3544246 -0.3543936 [253] -0.3543624 -0.3543312 -0.3542998 -0.3542684 -0.3542369 -0.3542053 [259] -0.3541736 -0.3541419 -0.3541100 -0.3540781 -0.3540460 -0.3540139 [265] -0.3539817 -0.3539495 -0.3539171 -0.3538846 -0.3538521 -0.3538194 [271] -0.3537867 -0.3537539 -0.3537210 -0.3536881 -0.3536550 -0.3536219 [277] -0.3535886 -0.3535553 -0.3535219 -0.3534884 -0.3534549 -0.3534212 [283] -0.3533875 -0.3533536 -0.3533197 -0.3532857 -0.3532516 -0.3532175 [289] -0.3531832 -0.3531489 -0.3531145 -0.3530800 -0.3530454 -0.3530107 [295] -0.3529759 -0.3529411 -0.3529062 -0.3528712 -0.3528361 -0.3528009 [301] -0.3527656 -0.3527303 -0.3526949 -0.3526593 -0.3526238 -0.3525881 [307] -0.3525523 -0.3525165 -0.3524805 -0.3524445 -0.3524084 -0.3523723 [313] -0.3523360 -0.3522997 -0.3522632 -0.3522267 -0.3521901 -0.3521535 [319] -0.3521167 -0.3520799 -0.3520430 -0.3520060 -0.3519689 -0.3519317 [325] -0.3518945 -0.3518572 -0.3518197 -0.3517823 -0.3517447 -0.3517070 [331] -0.3516693 -0.3516315 -0.3515936 -0.3515556 -0.3515175 -0.3514794 [337] -0.3514412 -0.3514029 -0.3513645 -0.3513260 -0.3512875 -0.3512489 [343] -0.3512102 -0.3511714 -0.3511325 -0.3510936 -0.3510546 -0.3510155 [349] -0.3509763 -0.3509370 -0.3508977 -0.3508583 -0.3508188 -0.3507792 [355] -0.3507395 -0.3506998 -0.3506600 -0.3506201 -0.3505801 -0.3505400 [361] -0.3504999 -0.3504597 -0.3504194 -0.3503790 -0.3503386 -0.3502981 [367] -0.3502575 -0.3502168 -0.3501760 -0.3501352 -0.3500943 -0.3500533 [373] -0.3500122 -0.3499711 -0.3499299 -0.3498885 -0.3498472 -0.3498057 [379] -0.3497642 -0.3497226 -0.3496809 -0.3496391 -0.3495973 -0.3495554 [385] -0.3495134 -0.3494713 -0.3494291 -0.3493869 -0.3493446 -0.3493022 [391] -0.3492598 -0.3492173 -0.3491747 -0.3491320 -0.3490892 -0.3490464 [397] -0.3490035 -0.3489605 -0.3489174 -0.3488743 -0.3488311 > mx [1] 0 > mxli [1] -999 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/rcomp/tmp/1wrgg1257798462.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/rcomp/tmp/2w45u1257798462.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/rcomp/tmp/3xonh1257798462.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/rcomp/tmp/4ijkg1257798462.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/rcomp/tmp/5whfk1257798462.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/60axk1257798462.tab") > > system("convert tmp/1wrgg1257798462.ps tmp/1wrgg1257798462.png") > system("convert tmp/2w45u1257798462.ps tmp/2w45u1257798462.png") > system("convert tmp/3xonh1257798462.ps tmp/3xonh1257798462.png") > system("convert tmp/4ijkg1257798462.ps tmp/4ijkg1257798462.png") > system("convert tmp/5whfk1257798462.ps tmp/5whfk1257798462.png") > > > proc.time() user system elapsed 1.380 1.180 2.303