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(94.70,90.20,104.30,96.00,96.60,103.50,79.90,88.50,103.30,113.50,100.80,95.30,92.60,89.00,98.70,94.50,96.90,98.10,82.10,86.50,104.10,110.90,114.50,112.20,96.40,92.00,102.00,99.70,102.00,98.90,87.40,94.40,109.30,116.40,101.00,105.50,97.80,95.50,113.70,103.70,100.80,113.80,84.60,95.30,110.00,107.50,107.60,116.00,96.90,97.00,108.10,101.90,107.20,110.20,78.70,96.50,115.20,104.70,109.10,108.40,95.50,97.80,115.10,96.20,112.00,111.80,82.50,100.80,116.00,116.30,116.60,112.90,100.90,104.10,117.40,103.30,111.60,115.20,92.60,106.90) > #'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.3376150 0.3377549 0.3378945 0.3380340 0.3381734 0.3383125 0.3384516 [8] 0.3385904 0.3387291 0.3388676 0.3390059 0.3391441 0.3392821 0.3394200 [15] 0.3395576 0.3396951 0.3398325 0.3399697 0.3401067 0.3402435 0.3403802 [22] 0.3405167 0.3406530 0.3407892 0.3409252 0.3410610 0.3411967 0.3413321 [29] 0.3414675 0.3416026 0.3417376 0.3418724 0.3420070 0.3421415 0.3422758 [36] 0.3424099 0.3425439 0.3426776 0.3428112 0.3429447 0.3430779 0.3432110 [43] 0.3433439 0.3434767 0.3436093 0.3437417 0.3438739 0.3440059 0.3441378 [50] 0.3442695 0.3444011 0.3445324 0.3446636 0.3447946 0.3449254 0.3450561 [57] 0.3451866 0.3453169 0.3454470 0.3455770 0.3457068 0.3458364 0.3459658 [64] 0.3460951 0.3462241 0.3463530 0.3464818 0.3466103 0.3467387 0.3468669 [71] 0.3469949 0.3471227 0.3472504 0.3473779 0.3475052 0.3476323 0.3477593 [78] 0.3478860 0.3480126 0.3481391 0.3482653 0.3483913 0.3485172 0.3486429 [85] 0.3487684 0.3488938 0.3490190 0.3491439 0.3492687 0.3493934 0.3495178 [92] 0.3496421 0.3497662 0.3498901 0.3500138 0.3501373 0.3502607 0.3503839 [99] 0.3505069 0.3506297 0.3507523 0.3508748 0.3509970 0.3511191 0.3512410 [106] 0.3513628 0.3514843 0.3516057 0.3517269 0.3518478 0.3519687 0.3520893 [113] 0.3522098 0.3523300 0.3524501 0.3525700 0.3526897 0.3528093 0.3529286 [120] 0.3530478 0.3531668 0.3532856 0.3534042 0.3535226 0.3536409 0.3537589 [127] 0.3538768 0.3539945 0.3541120 0.3542294 0.3543465 0.3544635 0.3545803 [134] 0.3546969 0.3548133 0.3549295 0.3550455 0.3551614 0.3552770 0.3553925 [141] 0.3555078 0.3556229 0.3557379 0.3558526 0.3559672 0.3560815 0.3561957 [148] 0.3563097 0.3564235 0.3565371 0.3566506 0.3567638 0.3568769 0.3569898 [155] 0.3571025 0.3572150 0.3573273 0.3574395 0.3575514 0.3576632 0.3577747 [162] 0.3578861 0.3579973 0.3581084 0.3582192 0.3583298 0.3584403 0.3585506 [169] 0.3586606 0.3587705 0.3588802 0.3589898 0.3590991 0.3592082 0.3593172 [176] 0.3594260 0.3595346 0.3596430 0.3597512 0.3598592 0.3599670 0.3600747 [183] 0.3601821 0.3602894 0.3603965 0.3605034 0.3606101 0.3607166 0.3608229 [190] 0.3609291 0.3610350 0.3611408 0.3612464 0.3613518 0.3614570 0.3615620 [197] 0.3616668 0.3617715 0.3618759 0.3619802 0.3620843 0.3621881 0.3622918 [204] 0.3623954 0.3624987 0.3626018 0.3627048 0.3628075 0.3629101 0.3630125 [211] 0.3631147 0.3632167 0.3633185 0.3634201 0.3635216 0.3636228 0.3637239 [218] 0.3638248 0.3639254 0.3640259 0.3641262 0.3642264 0.3643263 0.3644260 [225] 0.3645256 0.3646250 0.3647242 0.3648231 0.3649220 0.3650206 0.3651190 [232] 0.3652172 0.3653153 0.3654132 0.3655108 0.3656083 0.3657056 0.3658027 [239] 0.3658996 0.3659964 0.3660929 0.3661893 0.3662854 0.3663814 0.3664772 [246] 0.3665728 0.3666682 0.3667635 0.3668585 0.3669534 0.3670480 0.3671425 [253] 0.3672368 0.3673309 0.3674248 0.3675186 0.3676121 0.3677054 0.3677986 [260] 0.3678916 0.3679844 0.3680770 0.3681694 0.3682616 0.3683536 0.3684455 [267] 0.3685372 0.3686286 0.3687199 0.3688110 0.3689019 0.3689927 0.3690832 [274] 0.3691736 0.3692637 0.3693537 0.3694435 0.3695331 0.3696225 0.3697118 [281] 0.3698008 0.3698897 0.3699784 0.3700668 0.3701551 0.3702433 0.3703312 [288] 0.3704189 0.3705065 0.3705938 0.3706810 0.3707680 0.3708548 0.3709415 [295] 0.3710279 0.3711141 0.3712002 0.3712861 0.3713718 0.3714573 0.3715426 [302] 0.3716278 0.3717127 0.3717975 0.3718821 0.3719665 0.3720507 0.3721347 [309] 0.3722186 0.3723022 0.3723857 0.3724690 0.3725521 0.3726350 0.3727178 [316] 0.3728003 0.3728827 0.3729649 0.3730469 0.3731287 0.3732103 0.3732918 [323] 0.3733730 0.3734541 0.3735350 0.3736157 0.3736962 0.3737766 0.3738567 [330] 0.3739367 0.3740165 0.3740961 0.3741756 0.3742548 0.3743339 0.3744128 [337] 0.3744915 0.3745700 0.3746483 0.3747265 0.3748045 0.3748822 0.3749598 [344] 0.3750373 0.3751145 0.3751916 0.3752685 0.3753452 0.3754217 0.3754980 [351] 0.3755742 0.3756502 0.3757259 0.3758016 0.3758770 0.3759522 0.3760273 [358] 0.3761022 0.3761769 0.3762515 0.3763258 0.3764000 0.3764740 0.3765478 [365] 0.3766214 0.3766949 0.3767681 0.3768412 0.3769142 0.3769869 0.3770594 [372] 0.3771318 0.3772040 0.3772760 0.3773479 0.3774196 0.3774910 0.3775624 [379] 0.3776335 0.3777044 0.3777752 0.3778458 0.3779162 0.3779865 0.3780565 [386] 0.3781264 0.3781961 0.3782657 0.3783350 0.3784042 0.3784732 0.3785421 [393] 0.3786107 0.3786792 0.3787475 0.3788156 0.3788836 0.3789513 0.3790189 [400] 0.3790864 0.3791536 > mx [1] 0.3791536 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1qu3t1194256105.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/2rpdq1194256105.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/3gf9j1194256105.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/4g3et1194256105.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/50oaa1194256105.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/618xb1194256106.tab") > > system("convert tmp/1qu3t1194256105.ps tmp/1qu3t1194256105.png") > system("convert tmp/2rpdq1194256105.ps tmp/2rpdq1194256105.png") > system("convert tmp/3gf9j1194256105.ps tmp/3gf9j1194256105.png") > system("convert tmp/4g3et1194256105.ps tmp/4g3et1194256105.png") > system("convert tmp/50oaa1194256105.ps tmp/50oaa1194256105.png") > > > proc.time() user system elapsed 1.344 0.788 1.651