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(17,18,23.8,25.5,25.6,23.7,22,21.3,20.7,20.4,20.3,20.4,19.8,19.5,23.1,23.5,23.5,22.9,21.9,21.5,20.5,20.2,19.4,19.2,18.8,18.8,22.6,23.3,23,21.4,19.9,18.8,18.6,18.4,18.6,19.9,19.2,18.4,21.1,20.5,19.1,18.1,17,17.1,17.4,16.8,15.3,14.3,13.4,15.3,22.1,23.7,22.2,19.5,16.6,17.3,19.8,21.2,21.5,20.6) > #'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.3277620 -0.3278668 -0.3279713 -0.3280758 -0.3281800 -0.3282841 [7] -0.3283881 -0.3284919 -0.3285955 -0.3286989 -0.3288022 -0.3289053 [13] -0.3290083 -0.3291111 -0.3292137 -0.3293162 -0.3294185 -0.3295207 [19] -0.3296226 -0.3297245 -0.3298261 -0.3299276 -0.3300289 -0.3301301 [25] -0.3302311 -0.3303319 -0.3304326 -0.3305331 -0.3306334 -0.3307336 [31] -0.3308336 -0.3309335 -0.3310332 -0.3311327 -0.3312320 -0.3313312 [37] -0.3314302 -0.3315291 -0.3316278 -0.3317263 -0.3318246 -0.3319228 [43] -0.3320208 -0.3321187 -0.3322164 -0.3323139 -0.3324113 -0.3325085 [49] -0.3326055 -0.3327024 -0.3327990 -0.3328956 -0.3329919 -0.3330881 [55] -0.3331842 -0.3332800 -0.3333757 -0.3334712 -0.3335666 -0.3336618 [61] -0.3337568 -0.3338517 -0.3339464 -0.3340409 -0.3341353 -0.3342295 [67] -0.3343235 -0.3344174 -0.3345111 -0.3346046 -0.3346980 -0.3347912 [73] -0.3348842 -0.3349770 -0.3350697 -0.3351623 -0.3352546 -0.3353468 [79] -0.3354388 -0.3355307 -0.3356224 -0.3357139 -0.3358053 -0.3358965 [85] -0.3359875 -0.3360784 -0.3361691 -0.3362596 -0.3363500 -0.3364402 [91] -0.3365302 -0.3366201 -0.3367098 -0.3367993 -0.3368886 -0.3369778 [97] -0.3370669 -0.3371557 -0.3372444 -0.3373330 -0.3374214 -0.3375096 [103] -0.3375976 -0.3376855 -0.3377732 -0.3378607 -0.3379481 -0.3380353 [109] -0.3381223 -0.3382092 -0.3382959 -0.3383825 -0.3384689 -0.3385551 [115] -0.3386412 -0.3387270 -0.3388128 -0.3388983 -0.3389837 -0.3390690 [121] -0.3391540 -0.3392389 -0.3393237 -0.3394082 -0.3394927 -0.3395769 [127] -0.3396610 -0.3397449 -0.3398287 -0.3399123 -0.3399957 -0.3400790 [133] -0.3401621 -0.3402450 -0.3403278 -0.3404104 -0.3404929 -0.3405752 [139] -0.3406573 -0.3407393 -0.3408211 -0.3409027 -0.3409842 -0.3410655 [145] -0.3411467 -0.3412277 -0.3413085 -0.3413892 -0.3414697 -0.3415501 [151] -0.3416303 -0.3417103 -0.3417902 -0.3418699 -0.3419495 -0.3420289 [157] -0.3421081 -0.3421872 -0.3422661 -0.3423448 -0.3424234 -0.3425019 [163] -0.3425802 -0.3426583 -0.3427363 -0.3428141 -0.3428917 -0.3429692 [169] -0.3430465 -0.3431237 -0.3432007 -0.3432776 -0.3433543 -0.3434309 [175] -0.3435073 -0.3435835 -0.3436596 -0.3437355 -0.3438113 -0.3438869 [181] -0.3439623 -0.3440376 -0.3441128 -0.3441878 -0.3442626 -0.3443373 [187] -0.3444118 -0.3444862 -0.3445604 -0.3446345 -0.3447084 -0.3447822 [193] -0.3448558 -0.3449292 -0.3450025 -0.3450757 -0.3451487 -0.3452215 [199] -0.3452942 -0.3453668 -0.3454392 -0.3455114 -0.3455835 -0.3456554 [205] -0.3457272 -0.3457989 -0.3458703 -0.3459417 -0.3460129 -0.3460839 [211] -0.3461548 -0.3462255 -0.3462961 -0.3463666 -0.3464369 -0.3465070 [217] -0.3465770 -0.3466469 -0.3467166 -0.3467861 -0.3468556 -0.3469248 [223] -0.3469939 -0.3470629 -0.3471317 -0.3472004 -0.3472690 -0.3473373 [229] -0.3474056 -0.3474737 -0.3475416 -0.3476095 -0.3476771 -0.3477447 [235] -0.3478120 -0.3478793 -0.3479464 -0.3480133 -0.3480801 -0.3481468 [241] -0.3482133 -0.3482797 -0.3483459 -0.3484120 -0.3484780 -0.3485438 [247] -0.3486095 -0.3486750 -0.3487404 -0.3488057 -0.3488708 -0.3489358 [253] -0.3490006 -0.3490653 -0.3491299 -0.3491943 -0.3492586 -0.3493227 [259] -0.3493867 -0.3494506 -0.3495144 -0.3495780 -0.3496414 -0.3497047 [265] -0.3497679 -0.3498310 -0.3498939 -0.3499567 -0.3500193 -0.3500819 [271] -0.3501442 -0.3502065 -0.3502686 -0.3503306 -0.3503924 -0.3504541 [277] -0.3505157 -0.3505772 -0.3506385 -0.3506997 -0.3507607 -0.3508216 [283] -0.3508824 -0.3509431 -0.3510036 -0.3510640 -0.3511243 -0.3511844 [289] -0.3512444 -0.3513043 -0.3513640 -0.3514237 -0.3514832 -0.3515425 [295] -0.3516018 -0.3516609 -0.3517198 -0.3517787 -0.3518374 -0.3518960 [301] -0.3519545 -0.3520128 -0.3520711 -0.3521292 -0.3521871 -0.3522450 [307] -0.3523027 -0.3523603 -0.3524178 -0.3524751 -0.3525323 -0.3525894 [313] -0.3526464 -0.3527033 -0.3527600 -0.3528166 -0.3528731 -0.3529295 [319] -0.3529857 -0.3530418 -0.3530978 -0.3531537 -0.3532095 -0.3532651 [325] -0.3533206 -0.3533760 -0.3534313 -0.3534865 -0.3535415 -0.3535964 [331] -0.3536512 -0.3537059 -0.3537605 -0.3538150 -0.3538693 -0.3539235 [337] -0.3539776 -0.3540316 -0.3540855 -0.3541392 -0.3541929 -0.3542464 [343] -0.3542998 -0.3543531 -0.3544063 -0.3544593 -0.3545123 -0.3545651 [349] -0.3546179 -0.3546705 -0.3547230 -0.3547753 -0.3548276 -0.3548798 [355] -0.3549318 -0.3549838 -0.3550356 -0.3550873 -0.3551389 -0.3551904 [361] -0.3552418 -0.3552931 -0.3553442 -0.3553953 -0.3554462 -0.3554971 [367] -0.3555478 -0.3555984 -0.3556489 -0.3556993 -0.3557496 -0.3557998 [373] -0.3558499 -0.3558999 -0.3559497 -0.3559995 -0.3560491 -0.3560987 [379] -0.3561481 -0.3561975 -0.3562467 -0.3562958 -0.3563448 -0.3563938 [385] -0.3564426 -0.3564913 -0.3565399 -0.3565884 -0.3566368 -0.3566851 [391] -0.3567333 -0.3567814 -0.3568294 -0.3568773 -0.3569251 -0.3569727 [397] -0.3570203 -0.3570678 -0.3571152 -0.3571625 -0.3572097 > mx [1] 0 > mxli [1] -999 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/rcomp/tmp/1ix021257610951.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/249vr1257610951.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/3sidm1257610951.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/4epo71257610951.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/5wvht1257610952.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/69sp91257610952.tab") > > system("convert tmp/1ix021257610951.ps tmp/1ix021257610951.png") > system("convert tmp/249vr1257610951.ps tmp/249vr1257610951.png") > system("convert tmp/3sidm1257610951.ps tmp/3sidm1257610951.png") > system("convert tmp/4epo71257610951.ps tmp/4epo71257610951.png") > system("convert tmp/5wvht1257610952.ps tmp/5wvht1257610952.png") > > > proc.time() user system elapsed 1.320 1.220 1.928