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(108.01,101.21,119.93,94.76,95.26,117.96,115.86,111.44,108.16,108.77,109.45,124.83,115.31,109.49,124.24,92.85,98.42,120.88,111.72,116.1,109.37,111.65,114.29,133.68,114.27,126.49,131,104,108.88,128.48,132.44,128.04,116.35,120.93,118.59,133.1,121.05,127.62,135.44,114.88,114.34,128.85,138.9,129.44,114.96,127.98,127.03,128.75,137.91,128.37,135.9,122.19,113.08,136.2,138,115.24,110.95,99.23,102.39,112.67) > #'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.3481994 0.3482470 0.3482945 0.3483420 0.3483893 0.3484366 0.3484839 [8] 0.3485310 0.3485781 0.3486251 0.3486720 0.3487189 0.3487657 0.3488124 [15] 0.3488590 0.3489055 0.3489520 0.3489984 0.3490447 0.3490910 0.3491372 [22] 0.3491833 0.3492293 0.3492752 0.3493211 0.3493669 0.3494126 0.3494582 [29] 0.3495038 0.3495493 0.3495947 0.3496400 0.3496852 0.3497304 0.3497755 [36] 0.3498205 0.3498655 0.3499104 0.3499551 0.3499999 0.3500445 0.3500891 [43] 0.3501335 0.3501779 0.3502223 0.3502665 0.3503107 0.3503548 0.3503988 [50] 0.3504427 0.3504866 0.3505304 0.3505741 0.3506177 0.3506613 0.3507047 [57] 0.3507481 0.3507914 0.3508347 0.3508778 0.3509209 0.3509639 0.3510068 [64] 0.3510497 0.3510925 0.3511351 0.3511778 0.3512203 0.3512627 0.3513051 [71] 0.3513474 0.3513896 0.3514318 0.3514738 0.3515158 0.3515577 0.3515995 [78] 0.3516413 0.3516829 0.3517245 0.3517660 0.3518074 0.3518488 0.3518900 [85] 0.3519312 0.3519723 0.3520134 0.3520543 0.3520952 0.3521360 0.3521767 [92] 0.3522173 0.3522579 0.3522983 0.3523387 0.3523790 0.3524193 0.3524594 [99] 0.3524995 0.3525395 0.3525794 0.3526193 0.3526590 0.3526987 0.3527383 [106] 0.3527778 0.3528172 0.3528566 0.3528959 0.3529351 0.3529742 0.3530132 [113] 0.3530522 0.3530910 0.3531298 0.3531685 0.3532072 0.3532457 0.3532842 [120] 0.3533226 0.3533609 0.3533991 0.3534373 0.3534754 0.3535134 0.3535513 [127] 0.3535891 0.3536268 0.3536645 0.3537021 0.3537396 0.3537770 0.3538144 [134] 0.3538517 0.3538888 0.3539260 0.3539630 0.3539999 0.3540368 0.3540736 [141] 0.3541103 0.3541469 0.3541834 0.3542199 0.3542563 0.3542926 0.3543288 [148] 0.3543650 0.3544010 0.3544370 0.3544729 0.3545087 0.3545444 0.3545801 [155] 0.3546157 0.3546512 0.3546866 0.3547219 0.3547572 0.3547923 0.3548274 [162] 0.3548624 0.3548974 0.3549322 0.3549670 0.3550017 0.3550363 0.3550708 [169] 0.3551053 0.3551396 0.3551739 0.3552081 0.3552422 0.3552763 0.3553102 [176] 0.3553441 0.3553779 0.3554117 0.3554453 0.3554789 0.3555123 0.3555457 [183] 0.3555790 0.3556123 0.3556454 0.3556785 0.3557115 0.3557444 0.3557773 [190] 0.3558100 0.3558427 0.3558753 0.3559078 0.3559402 0.3559726 0.3560048 [197] 0.3560370 0.3560691 0.3561012 0.3561331 0.3561650 0.3561968 0.3562285 [204] 0.3562601 0.3562917 0.3563231 0.3563545 0.3563858 0.3564171 0.3564482 [211] 0.3564793 0.3565102 0.3565412 0.3565720 0.3566027 0.3566334 0.3566640 [218] 0.3566945 0.3567249 0.3567553 0.3567855 0.3568157 0.3568458 0.3568758 [225] 0.3569058 0.3569356 0.3569654 0.3569951 0.3570248 0.3570543 0.3570838 [232] 0.3571132 0.3571425 0.3571717 0.3572009 0.3572299 0.3572589 0.3572878 [239] 0.3573166 0.3573454 0.3573741 0.3574027 0.3574312 0.3574596 0.3574880 [246] 0.3575162 0.3575444 0.3575726 0.3576006 0.3576285 0.3576564 0.3576842 [253] 0.3577119 0.3577396 0.3577672 0.3577946 0.3578220 0.3578494 0.3578766 [260] 0.3579038 0.3579309 0.3579579 0.3579848 0.3580117 0.3580384 0.3580651 [267] 0.3580918 0.3581183 0.3581448 0.3581711 0.3581974 0.3582237 0.3582498 [274] 0.3582759 0.3583019 0.3583278 0.3583536 0.3583794 0.3584051 0.3584307 [281] 0.3584562 0.3584816 0.3585070 0.3585323 0.3585575 0.3585826 0.3586077 [288] 0.3586327 0.3586576 0.3586824 0.3587072 0.3587318 0.3587564 0.3587809 [295] 0.3588054 0.3588297 0.3588540 0.3588782 0.3589024 0.3589264 0.3589504 [302] 0.3589743 0.3589981 0.3590218 0.3590455 0.3590691 0.3590926 0.3591161 [309] 0.3591394 0.3591627 0.3591859 0.3592090 0.3592321 0.3592551 0.3592780 [316] 0.3593008 0.3593236 0.3593462 0.3593688 0.3593914 0.3594138 0.3594362 [323] 0.3594585 0.3594807 0.3595028 0.3595249 0.3595469 0.3595688 0.3595907 [330] 0.3596124 0.3596341 0.3596557 0.3596773 0.3596987 0.3597201 0.3597414 [337] 0.3597627 0.3597838 0.3598049 0.3598260 0.3598469 0.3598678 0.3598886 [344] 0.3599093 0.3599299 0.3599505 0.3599710 0.3599914 0.3600117 0.3600320 [351] 0.3600522 0.3600723 0.3600924 0.3601124 0.3601323 0.3601521 0.3601718 [358] 0.3601915 0.3602111 0.3602307 0.3602501 0.3602695 0.3602888 0.3603081 [365] 0.3603272 0.3603463 0.3603653 0.3603843 0.3604032 0.3604220 0.3604407 [372] 0.3604594 0.3604779 0.3604965 0.3605149 0.3605333 0.3605516 0.3605698 [379] 0.3605879 0.3606060 0.3606240 0.3606419 0.3606598 0.3606776 0.3606953 [386] 0.3607130 0.3607305 0.3607480 0.3607655 0.3607828 0.3608001 0.3608173 [393] 0.3608345 0.3608515 0.3608686 0.3608855 0.3609023 0.3609191 0.3609359 [400] 0.3609525 0.3609691 > mx [1] 0.3609691 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/rcomp/tmp/1sy5o1257763926.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/2ox9m1257763926.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/3yoat1257763926.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/4yd1g1257763926.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/511d01257763926.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/6yfvo1257763926.tab") > > system("convert tmp/1sy5o1257763926.ps tmp/1sy5o1257763926.png") > system("convert tmp/2ox9m1257763926.ps tmp/2ox9m1257763926.png") > system("convert tmp/3yoat1257763926.ps tmp/3yoat1257763926.png") > system("convert tmp/4yd1g1257763926.ps tmp/4yd1g1257763926.png") > system("convert tmp/511d01257763926.ps tmp/511d01257763926.png") > > > proc.time() user system elapsed 1.410 1.390 2.477