R version 2.8.0 (2008-10-20) 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(255843,254490,251995,246339,244019,245953,279806,283111,281097,275964,270694,271901,274412,272433,268361,268586,264768,269974,304744,309365,308347,298427,289231,291975,294912,293488,290555,284736,281818,287854,316263,325412,326011,328282,317480,317539,313737,312276,309391,302950,300316,304035,333476,337698,335932,323931,313927,314485,313218,309664,302963,298989,298423,301631,329765,335083,327616,309119,295916,291413,291542,284678,276475,272566,264981,263290,296806,303598,286994,276427,266424,267153) > #'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.3782567 0.3781494 0.3780293 0.3779263 0.3778166 0.3777024 0.3775931 [8] 0.3774800 0.3773710 0.3772588 0.3771473 0.3770380 0.3769266 0.3768144 [15] 0.3767029 0.3765927 0.3764809 0.3763698 0.3762584 0.3761469 0.3760357 [22] 0.3759241 0.3758131 0.3757016 0.3755894 0.3754780 0.3753663 0.3752548 [29] 0.3751429 0.3750306 0.3749189 0.3748072 0.3746951 0.3745831 0.3744712 [36] 0.3743591 0.3742470 0.3741348 0.3740226 0.3739104 0.3737981 0.3736858 [43] 0.3735735 0.3734610 0.3733486 0.3732361 0.3731236 0.3730110 0.3728984 [50] 0.3727858 0.3726731 0.3725604 0.3724476 0.3723348 0.3722219 0.3721091 [57] 0.3719961 0.3718832 0.3717702 0.3716571 0.3715441 0.3714310 0.3713178 [64] 0.3712046 0.3710914 0.3709781 0.3708648 0.3707515 0.3706381 0.3705247 [71] 0.3704112 0.3702977 0.3701842 0.3700706 0.3699570 0.3698434 0.3697297 [78] 0.3696160 0.3695023 0.3693885 0.3692747 0.3691608 0.3690469 0.3689330 [85] 0.3688190 0.3687050 0.3685910 0.3684769 0.3683628 0.3682487 0.3681345 [92] 0.3680203 0.3679061 0.3677918 0.3676775 0.3675631 0.3674488 0.3673343 [99] 0.3672199 0.3671054 0.3669909 0.3668763 0.3667618 0.3666472 0.3665325 [106] 0.3664178 0.3663031 0.3661884 0.3660736 0.3659588 0.3658439 0.3657291 [113] 0.3656142 0.3654992 0.3653842 0.3652692 0.3651542 0.3650391 0.3649240 [120] 0.3648089 0.3646938 0.3645786 0.3644634 0.3643481 0.3642328 0.3641175 [127] 0.3640022 0.3638868 0.3637714 0.3636560 0.3635405 0.3634250 0.3633095 [134] 0.3631939 0.3630784 0.3629627 0.3628471 0.3627314 0.3626157 0.3625000 [141] 0.3623843 0.3622685 0.3621527 0.3620368 0.3619210 0.3618051 0.3616892 [148] 0.3615732 0.3614572 0.3613412 0.3612252 0.3611092 0.3609931 0.3608770 [155] 0.3607608 0.3606447 0.3605285 0.3604123 0.3602960 0.3601797 0.3600634 [162] 0.3599471 0.3598308 0.3597144 0.3595980 0.3594816 0.3593651 0.3592487 [169] 0.3591322 0.3590156 0.3588991 0.3587825 0.3586659 0.3585493 0.3584327 [176] 0.3583160 0.3581993 0.3580826 0.3579658 0.3578491 0.3577323 0.3576155 [183] 0.3574987 0.3573818 0.3572649 0.3571480 0.3570311 0.3569141 0.3567972 [190] 0.3566802 0.3565632 0.3564461 0.3563291 0.3562120 0.3560949 0.3559778 [197] 0.3558606 0.3557435 0.3556263 0.3555091 0.3553918 0.3552746 0.3551573 [204] 0.3550400 0.3549227 0.3548054 0.3546881 0.3545707 0.3544533 0.3543359 [211] 0.3542185 0.3541010 0.3539835 0.3538660 0.3537485 0.3536310 0.3535135 [218] 0.3533959 0.3532783 0.3531607 0.3530431 0.3529255 0.3528078 0.3526901 [225] 0.3525725 0.3524547 0.3523370 0.3522193 0.3521015 0.3519837 0.3518660 [232] 0.3517481 0.3516303 0.3515125 0.3513946 0.3512767 0.3511588 0.3510409 [239] 0.3509230 0.3508051 0.3506871 0.3505691 0.3504511 0.3503331 0.3502151 [246] 0.3500971 0.3499790 0.3498610 0.3497429 0.3496248 0.3495067 0.3493886 [253] 0.3492704 0.3491523 0.3490341 0.3489159 0.3487977 0.3486795 0.3485613 [260] 0.3484431 0.3483248 0.3482066 0.3480883 0.3479700 0.3478517 0.3477334 [267] 0.3476151 0.3474967 0.3473784 0.3472600 0.3471416 0.3470233 0.3469049 [274] 0.3467864 0.3466680 0.3465496 0.3464312 0.3463127 0.3461942 0.3460758 [281] 0.3459573 0.3458388 0.3457203 0.3456017 0.3454832 0.3453647 0.3452461 [288] 0.3451276 0.3450090 0.3448904 0.3447718 0.3446532 0.3445346 0.3444160 [295] 0.3442974 0.3441788 0.3440601 0.3439415 0.3438228 0.3437041 0.3435854 [302] 0.3434668 0.3433481 0.3432294 0.3431107 0.3429919 0.3428732 0.3427545 [309] 0.3426357 0.3425170 0.3423982 0.3422795 0.3421607 0.3420419 0.3419232 [316] 0.3418044 0.3416856 0.3415668 0.3414480 0.3413292 0.3412103 0.3410915 [323] 0.3409727 0.3408539 0.3407350 0.3406162 0.3404973 0.3403785 0.3402596 [330] 0.3401407 0.3400219 0.3399030 0.3397841 0.3396652 0.3395463 0.3394274 [337] 0.3393086 0.3391897 0.3390707 0.3389518 0.3388329 0.3387140 0.3385951 [344] 0.3384762 0.3383573 0.3382383 0.3381194 0.3380005 0.3378815 0.3377626 [351] 0.3376437 0.3375247 0.3374058 0.3372868 0.3371679 0.3370489 0.3369300 [358] 0.3368110 0.3366921 0.3365731 0.3364542 0.3363352 0.3362163 0.3360973 [365] 0.3359783 0.3358594 0.3357404 0.3356215 0.3355025 0.3353835 0.3352646 [372] 0.3351456 0.3350267 0.3349077 0.3347887 0.3346698 0.3345508 0.3344319 [379] 0.3343129 0.3341940 0.3340750 0.3339561 0.3338371 0.3337182 0.3335992 [386] 0.3334803 0.3333613 0.3332424 0.3331234 0.3330045 0.3328856 0.3327666 [393] 0.3326477 0.3325288 0.3324099 0.3322909 0.3321720 0.3320531 0.3319342 [400] 0.3318153 0.3316964 > mx [1] 0.3782567 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/freestat/rcomp/tmp/1n9q91226425525.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/freestat/rcomp/tmp/2ewsp1226425525.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/freestat/rcomp/tmp/33p1n1226425525.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/freestat/rcomp/tmp/4gdqq1226425525.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/freestat/rcomp/tmp/5iwpw1226425525.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x1) > grid() > mtext('Transformed Data') > dev.off() null device 1 > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/6hznx1226425525.tab") > > system("convert tmp/1n9q91226425525.ps tmp/1n9q91226425525.png") > system("convert tmp/2ewsp1226425525.ps tmp/2ewsp1226425525.png") > system("convert tmp/33p1n1226425525.ps tmp/33p1n1226425525.png") > system("convert tmp/4gdqq1226425525.ps tmp/4gdqq1226425525.png") > system("convert tmp/5iwpw1226425525.ps tmp/5iwpw1226425525.png") > > > proc.time() user system elapsed 1.720 1.277 2.327