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(4.5,5.6,5.4,5.4,5.2,5.3,5.3,5.3,5.2,5.2,5.0,5.0,5.0,6.5,6.5,6.6,6.2,6.2,6.2,6.1,6.1,6.1,5.9,5.9,5.9,6.2,6.1,6.2,6.6,6.6,6.7,5.8,5.7,5.7,6.1,6.2,6.2,6.2,6.1,6.2,6.5,6.5,6.5,6.0,6.3,6.0,6.1,6.1,6.1,6.2,6.1,6.2,6.8,6.8,6.8,6.7,6.7,6.7,5.7,5.6,5.6,5.8,5.7,5.7,6.1,6.1,5.9,5.9,5.8,5.6,5.5,5.5,5.4) > #'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.3513930 0.3512178 0.3510424 0.3508670 0.3506915 0.3505160 0.3503403 [8] 0.3501645 0.3499887 0.3498128 0.3496368 0.3494607 0.3492846 0.3491083 [15] 0.3489320 0.3487556 0.3485791 0.3484026 0.3482259 0.3480492 0.3478724 [22] 0.3476955 0.3475186 0.3473415 0.3471644 0.3469873 0.3468100 0.3466327 [29] 0.3464553 0.3462778 0.3461003 0.3459227 0.3457450 0.3455672 0.3453894 [36] 0.3452115 0.3450335 0.3448555 0.3446774 0.3444992 0.3443210 0.3441426 [43] 0.3439643 0.3437858 0.3436073 0.3434288 0.3432501 0.3430714 0.3428927 [50] 0.3427138 0.3425349 0.3423560 0.3421770 0.3419979 0.3418188 0.3416396 [57] 0.3414603 0.3412810 0.3411017 0.3409222 0.3407427 0.3405632 0.3403836 [64] 0.3402040 0.3400242 0.3398445 0.3396647 0.3394848 0.3393049 0.3391249 [71] 0.3389449 0.3387648 0.3385846 0.3384045 0.3382242 0.3380439 0.3378636 [78] 0.3376832 0.3375028 0.3373223 0.3371418 0.3369612 0.3367806 0.3365999 [85] 0.3364192 0.3362385 0.3360577 0.3358768 0.3356959 0.3355150 0.3353340 [92] 0.3351530 0.3349719 0.3347908 0.3346097 0.3344285 0.3342473 0.3340660 [99] 0.3338847 0.3337034 0.3335220 0.3333406 0.3331592 0.3329777 0.3327962 [106] 0.3326146 0.3324330 0.3322514 0.3320697 0.3318880 0.3317063 0.3315245 [113] 0.3313428 0.3311609 0.3309791 0.3307972 0.3306153 0.3304333 0.3302514 [120] 0.3300694 0.3298873 0.3297053 0.3295232 0.3293411 0.3291589 0.3289768 [127] 0.3287946 0.3286124 0.3284301 0.3282478 0.3280656 0.3278832 0.3277009 [134] 0.3275185 0.3273362 0.3271538 0.3269713 0.3267889 0.3266064 0.3264240 [141] 0.3262415 0.3260589 0.3258764 0.3256938 0.3255113 0.3253287 0.3251461 [148] 0.3249634 0.3247808 0.3245981 0.3244155 0.3242328 0.3240501 0.3238674 [155] 0.3236847 0.3235019 0.3233192 0.3231364 0.3229536 0.3227709 0.3225881 [162] 0.3224053 0.3222225 0.3220396 0.3218568 0.3216740 0.3214911 0.3213083 [169] 0.3211254 0.3209426 0.3207597 0.3205768 0.3203939 0.3202111 0.3200282 [176] 0.3198453 0.3196624 0.3194795 0.3192966 0.3191137 0.3189308 0.3187479 [183] 0.3185650 0.3183821 0.3181991 0.3180162 0.3178333 0.3176504 0.3174675 [190] 0.3172846 0.3171017 0.3169188 0.3167359 0.3165531 0.3163702 0.3161873 [197] 0.3160044 0.3158216 0.3156387 0.3154558 0.3152730 0.3150902 0.3149073 [204] 0.3147245 0.3145417 0.3143589 0.3141761 0.3139933 0.3138105 0.3136277 [211] 0.3134450 0.3132622 0.3130795 0.3128968 0.3127141 0.3125314 0.3123487 [218] 0.3121660 0.3119834 0.3118007 0.3116181 0.3114355 0.3112529 0.3110703 [225] 0.3108877 0.3107052 0.3105227 0.3103402 0.3101577 0.3099752 0.3097927 [232] 0.3096103 0.3094279 0.3092455 0.3090631 0.3088807 0.3086984 0.3085161 [239] 0.3083338 0.3081515 0.3079693 0.3077871 0.3076049 0.3074227 0.3072405 [246] 0.3070584 0.3068763 0.3066942 0.3065122 0.3063302 0.3061482 0.3059662 [253] 0.3057842 0.3056023 0.3054204 0.3052386 0.3050568 0.3048749 0.3046932 [260] 0.3045114 0.3043297 0.3041480 0.3039664 0.3037848 0.3036032 0.3034216 [267] 0.3032401 0.3030586 0.3028771 0.3026957 0.3025143 0.3023330 0.3021517 [274] 0.3019704 0.3017891 0.3016079 0.3014267 0.3012456 0.3010645 0.3008834 [281] 0.3007024 0.3005214 0.3003404 0.3001595 0.2999786 0.2997978 0.2996170 [288] 0.2994362 0.2992555 0.2990748 0.2988942 0.2987136 0.2985330 0.2983525 [295] 0.2981720 0.2979916 0.2978112 0.2976308 0.2974505 0.2972703 0.2970901 [302] 0.2969099 0.2967298 0.2965497 0.2963697 0.2961897 0.2960097 0.2958299 [309] 0.2956500 0.2954702 0.2952905 0.2951108 0.2949311 0.2947515 0.2945719 [316] 0.2943924 0.2942130 0.2940336 0.2938542 0.2936749 0.2934956 0.2933164 [323] 0.2931373 0.2929582 0.2927791 0.2926001 0.2924212 0.2922423 0.2920634 [330] 0.2918846 0.2917059 0.2915272 0.2913486 0.2911700 0.2909915 0.2908131 [337] 0.2906347 0.2904563 0.2902780 0.2900998 0.2899216 0.2897435 0.2895654 [344] 0.2893874 0.2892095 0.2890316 0.2888538 0.2886760 0.2884983 0.2883207 [351] 0.2881431 0.2879655 0.2877881 0.2876107 0.2874333 0.2872560 0.2870788 [358] 0.2869017 0.2867246 0.2865475 0.2863706 0.2861937 0.2860168 0.2858400 [365] 0.2856633 0.2854867 0.2853101 0.2851336 0.2849571 0.2847807 0.2846044 [372] 0.2844281 0.2842519 0.2840758 0.2838998 0.2837238 0.2835478 0.2833720 [379] 0.2831962 0.2830205 0.2828448 0.2826692 0.2824937 0.2823183 0.2821429 [386] 0.2819676 0.2817924 0.2816172 0.2814421 0.2812671 0.2810922 0.2809173 [393] 0.2807425 0.2805677 0.2803931 0.2802185 0.2800440 0.2798695 0.2796952 [400] 0.2795209 0.2793467 > mx [1] 0.351393 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1v7xs1194297162.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/2r5hh1194297162.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/397ky1194297162.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/4ufns1194297162.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/55jjv1194297162.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/684u01194297162.tab") > > system("convert tmp/1v7xs1194297162.ps tmp/1v7xs1194297162.png") > system("convert tmp/2r5hh1194297162.ps tmp/2r5hh1194297162.png") > system("convert tmp/397ky1194297162.ps tmp/397ky1194297162.png") > system("convert tmp/4ufns1194297162.ps tmp/4ufns1194297162.png") > system("convert tmp/55jjv1194297162.ps tmp/55jjv1194297162.png") > > > proc.time() user system elapsed 2.370 1.319 2.557