R version 2.7.0 (2008-04-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(58.972,59.249,63.955,53.785,52.760,44.795,37.348,32.370,32.717,40.974,33.591,21.124,58.608,46.865,51.378,46.235,47.206,45.382,41.227,33.795,31.295,42.625,33.625,21.538,56.421,53.152,53.536,52.408,41.454,38.271,35.306,26.414,31.917,38.030,27.534,18.387,50.556,43.901,48.572,43.899,37.532,40.357,35.489,29.027,34.485,42.598,30.306,26.451,47.460,50.104,61.465,53.726,39.477,43.895,31.481,29.896,33.842,39.120,33.702,25.094) > #'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.2133853 -0.2139628 -0.2145403 -0.2151180 -0.2156957 -0.2162734 [7] -0.2168513 -0.2174291 -0.2180070 -0.2185850 -0.2191629 -0.2197408 [13] -0.2203188 -0.2208967 -0.2214746 -0.2220525 -0.2226303 -0.2232080 [19] -0.2237857 -0.2243633 -0.2249409 -0.2255183 -0.2260957 -0.2266729 [25] -0.2272500 -0.2278269 -0.2284038 -0.2289804 -0.2295569 -0.2301332 [31] -0.2307094 -0.2312853 -0.2318611 -0.2324366 -0.2330119 -0.2335870 [37] -0.2341618 -0.2347364 -0.2353107 -0.2358847 -0.2364585 -0.2370320 [43] -0.2376051 -0.2381780 -0.2387505 -0.2393227 -0.2398945 -0.2404660 [49] -0.2410372 -0.2416079 -0.2421783 -0.2427483 -0.2433179 -0.2438871 [55] -0.2444558 -0.2450242 -0.2455921 -0.2461595 -0.2467265 -0.2472930 [61] -0.2478591 -0.2484246 -0.2489897 -0.2495543 -0.2501183 -0.2506818 [67] -0.2512448 -0.2518073 -0.2523691 -0.2529305 -0.2534912 -0.2540514 [73] -0.2546110 -0.2551700 -0.2557284 -0.2562862 -0.2568433 -0.2573998 [79] -0.2579557 -0.2585109 -0.2590655 -0.2596194 -0.2601726 -0.2607251 [85] -0.2612769 -0.2618280 -0.2623784 -0.2629281 -0.2634771 -0.2640253 [91] -0.2645728 -0.2651195 -0.2656654 -0.2662106 -0.2667550 -0.2672986 [97] -0.2678414 -0.2683834 -0.2689246 -0.2694650 -0.2700045 -0.2705432 [103] -0.2710811 -0.2716181 -0.2721543 -0.2726895 -0.2732239 -0.2737574 [109] -0.2742901 -0.2748218 -0.2753526 -0.2758825 -0.2764115 -0.2769395 [115] -0.2774667 -0.2779928 -0.2785180 -0.2790423 -0.2795656 -0.2800879 [121] -0.2806093 -0.2811296 -0.2816490 -0.2821674 -0.2826847 -0.2832011 [127] -0.2837164 -0.2842307 -0.2847440 -0.2852562 -0.2857674 -0.2862776 [133] -0.2867866 -0.2872946 -0.2878016 -0.2883075 -0.2888122 -0.2893159 [139] -0.2898185 -0.2903200 -0.2908204 -0.2913197 -0.2918179 -0.2923149 [145] -0.2928108 -0.2933056 -0.2937993 -0.2942918 -0.2947831 -0.2952733 [151] -0.2957623 -0.2962502 -0.2967369 -0.2972224 -0.2977067 -0.2981899 [157] -0.2986718 -0.2991526 -0.2996322 -0.3001105 -0.3005877 -0.3010636 [163] -0.3015384 -0.3020119 -0.3024841 -0.3029552 -0.3034250 -0.3038936 [169] -0.3043609 -0.3048270 -0.3052918 -0.3057554 -0.3062177 -0.3066788 [175] -0.3071385 -0.3075971 -0.3080543 -0.3085103 -0.3089650 -0.3094184 [181] -0.3098705 -0.3103213 -0.3107709 -0.3112191 -0.3116660 -0.3121117 [187] -0.3125560 -0.3129990 -0.3134407 -0.3138811 -0.3143202 -0.3147580 [193] -0.3151944 -0.3156296 -0.3160634 -0.3164958 -0.3169269 -0.3173567 [199] -0.3177852 -0.3182123 -0.3186381 -0.3190626 -0.3194857 -0.3199074 [205] -0.3203278 -0.3207469 -0.3211646 -0.3215809 -0.3219959 -0.3224095 [211] -0.3228218 -0.3232327 -0.3236423 -0.3240505 -0.3244573 -0.3248628 [217] -0.3252669 -0.3256696 -0.3260710 -0.3264710 -0.3268696 -0.3272669 [223] -0.3276627 -0.3280573 -0.3284504 -0.3288421 -0.3292325 -0.3296215 [229] -0.3300092 -0.3303954 -0.3307803 -0.3311638 -0.3315459 -0.3319266 [235] -0.3323060 -0.3326839 -0.3330605 -0.3334358 -0.3338096 -0.3341821 [241] -0.3345531 -0.3349228 -0.3352911 -0.3356581 -0.3360236 -0.3363878 [247] -0.3367506 -0.3371120 -0.3374720 -0.3378307 -0.3381880 -0.3385439 [253] -0.3388984 -0.3392515 -0.3396033 -0.3399537 -0.3403027 -0.3406503 [259] -0.3409966 -0.3413415 -0.3416850 -0.3420272 -0.3423680 -0.3427074 [265] -0.3430454 -0.3433821 -0.3437174 -0.3440514 -0.3443839 -0.3447152 [271] -0.3450450 -0.3453735 -0.3457006 -0.3460264 -0.3463508 -0.3466739 [277] -0.3469956 -0.3473160 -0.3476350 -0.3479526 -0.3482689 -0.3485839 [283] -0.3488975 -0.3492098 -0.3495207 -0.3498303 -0.3501385 -0.3504454 [289] -0.3507510 -0.3510553 -0.3513582 -0.3516597 -0.3519600 -0.3522589 [295] -0.3525565 -0.3528528 -0.3531477 -0.3534414 -0.3537337 -0.3540247 [301] -0.3543144 -0.3546028 -0.3548899 -0.3551756 -0.3554601 -0.3557433 [307] -0.3560251 -0.3563057 -0.3565850 -0.3568629 -0.3571396 -0.3574150 [313] -0.3576891 -0.3579620 -0.3582335 -0.3585038 -0.3587728 -0.3590405 [319] -0.3593069 -0.3595721 -0.3598360 -0.3600986 -0.3603600 -0.3606201 [325] -0.3608790 -0.3611366 -0.3613930 -0.3616481 -0.3619019 -0.3621545 [331] -0.3624059 -0.3626560 -0.3629049 -0.3631526 -0.3633990 -0.3636442 [337] -0.3638882 -0.3641310 -0.3643725 -0.3646128 -0.3648519 -0.3650898 [343] -0.3653265 -0.3655620 -0.3657963 -0.3660293 -0.3662612 -0.3664919 [349] -0.3667214 -0.3669497 -0.3671768 -0.3674027 -0.3676275 -0.3678510 [355] -0.3680734 -0.3682947 -0.3685147 -0.3687336 -0.3689513 -0.3691679 [361] -0.3693833 -0.3695976 -0.3698107 -0.3700226 -0.3702334 -0.3704431 [367] -0.3706516 -0.3708590 -0.3710653 -0.3712704 -0.3714744 -0.3716773 [373] -0.3718790 -0.3720796 -0.3722792 -0.3724776 -0.3726749 -0.3728711 [379] -0.3730661 -0.3732601 -0.3734530 -0.3736448 -0.3738355 -0.3740251 [385] -0.3742137 -0.3744011 -0.3745875 -0.3747728 -0.3749570 -0.3751401 [391] -0.3753222 -0.3755032 -0.3756832 -0.3758621 -0.3760400 -0.3762167 [397] -0.3763925 -0.3765672 -0.3767409 -0.3769135 -0.3770851 > mx [1] 0 > mxli [1] -999 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/104q51229675770.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/2c5q91229675770.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/3pr1q1229675770.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/4nr131229675770.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/5iut71229675770.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > 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/6dzk71229675770.tab") > > system("convert tmp/104q51229675770.ps tmp/104q51229675770.png") > system("convert tmp/2c5q91229675770.ps tmp/2c5q91229675770.png") > system("convert tmp/3pr1q1229675770.ps tmp/3pr1q1229675770.png") > system("convert tmp/4nr131229675770.ps tmp/4nr131229675770.png") > system("convert tmp/5iut71229675770.ps tmp/5iut71229675770.png") > > > proc.time() user system elapsed 2.375 1.296 2.561