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(106.7,110.2,125.9,100.1,106.4,114.8,81.3,87,104.2,108,105,94.5,92,95.9,108.8,103.4,102.1,110.1,83.2,82.7,106.8,113.7,102.5,96.6,92.1,95.6,102.3,98.6,98.2,104.5,84,73.8,103.9,106,97.2,102.6,89,93.8,116.7,106.8,98.5,118.7,90,91.9,113.3,113.1,104.1,108.7,96.7,101,116.9,105.8,99,129.4,83,88.9,115.9,104.2,113.4,112.2,100.8,107.3,126.6,102.9,117.9,128.8,87.5,93.8,122.7,126.2,124.6,116.7,115.2,111.1,129.9,113.3,118.5,133.5,102.1,102.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.2836740 0.2838440 0.2840140 0.2841838 0.2843536 0.2845232 0.2846928 [8] 0.2848623 0.2850317 0.2852010 0.2853702 0.2855393 0.2857083 0.2858772 [15] 0.2860460 0.2862147 0.2863833 0.2865519 0.2867203 0.2868886 0.2870568 [22] 0.2872249 0.2873929 0.2875609 0.2877287 0.2878964 0.2880640 0.2882315 [29] 0.2883989 0.2885662 0.2887334 0.2889005 0.2890675 0.2892344 0.2894011 [36] 0.2895678 0.2897344 0.2899008 0.2900672 0.2902334 0.2903995 0.2905655 [43] 0.2907315 0.2908973 0.2910630 0.2912285 0.2913940 0.2915594 0.2917246 [50] 0.2918898 0.2920548 0.2922197 0.2923845 0.2925492 0.2927138 0.2928782 [57] 0.2930426 0.2932068 0.2933709 0.2935349 0.2936988 0.2938625 0.2940262 [64] 0.2941897 0.2943531 0.2945164 0.2946796 0.2948426 0.2950056 0.2951684 [71] 0.2953311 0.2954936 0.2956561 0.2958184 0.2959806 0.2961427 0.2963047 [78] 0.2964665 0.2966282 0.2967898 0.2969513 0.2971126 0.2972738 0.2974349 [85] 0.2975959 0.2977567 0.2979175 0.2980780 0.2982385 0.2983988 0.2985590 [92] 0.2987191 0.2988791 0.2990389 0.2991986 0.2993581 0.2995175 0.2996768 [99] 0.2998360 0.2999950 0.3001539 0.3003127 0.3004713 0.3006298 0.3007882 [106] 0.3009464 0.3011045 0.3012625 0.3014203 0.3015780 0.3017356 0.3018930 [113] 0.3020503 0.3022074 0.3023644 0.3025213 0.3026780 0.3028346 0.3029911 [120] 0.3031474 0.3033036 0.3034596 0.3036156 0.3037713 0.3039269 0.3040824 [127] 0.3042377 0.3043929 0.3045480 0.3047029 0.3048577 0.3050123 0.3051668 [134] 0.3053211 0.3054753 0.3056294 0.3057833 0.3059370 0.3060906 0.3062441 [141] 0.3063974 0.3065506 0.3067036 0.3068565 0.3070092 0.3071618 0.3073142 [148] 0.3074665 0.3076187 0.3077706 0.3079225 0.3080742 0.3082257 0.3083771 [155] 0.3085283 0.3086794 0.3088303 0.3089811 0.3091317 0.3092822 0.3094325 [162] 0.3095827 0.3097327 0.3098826 0.3100323 0.3101818 0.3103312 0.3104805 [169] 0.3106295 0.3107785 0.3109272 0.3110759 0.3112243 0.3113726 0.3115208 [176] 0.3116687 0.3118166 0.3119642 0.3121117 0.3122591 0.3124063 0.3125533 [183] 0.3127002 0.3128469 0.3129935 0.3131398 0.3132861 0.3134321 0.3135780 [190] 0.3137238 0.3138694 0.3140148 0.3141600 0.3143051 0.3144501 0.3145948 [197] 0.3147394 0.3148839 0.3150281 0.3151722 0.3153162 0.3154599 0.3156036 [204] 0.3157470 0.3158903 0.3160334 0.3161763 0.3163191 0.3164617 0.3166041 [211] 0.3167464 0.3168885 0.3170304 0.3171722 0.3173138 0.3174552 0.3175965 [218] 0.3177376 0.3178785 0.3180192 0.3181598 0.3183002 0.3184404 0.3185805 [225] 0.3187204 0.3188601 0.3189997 0.3191390 0.3192782 0.3194173 0.3195561 [232] 0.3196948 0.3198333 0.3199716 0.3201098 0.3202477 0.3203856 0.3205232 [239] 0.3206606 0.3207979 0.3209350 0.3210719 0.3212087 0.3213453 0.3214817 [246] 0.3216179 0.3217539 0.3218898 0.3220255 0.3221610 0.3222963 0.3224315 [253] 0.3225665 0.3227012 0.3228359 0.3229703 0.3231046 0.3232386 0.3233725 [260] 0.3235062 0.3236398 0.3237731 0.3239063 0.3240393 0.3241721 0.3243047 [267] 0.3244372 0.3245695 0.3247015 0.3248334 0.3249652 0.3250967 0.3252280 [274] 0.3253592 0.3254902 0.3256210 0.3257516 0.3258820 0.3260123 0.3261424 [281] 0.3262722 0.3264019 0.3265314 0.3266608 0.3267899 0.3269189 0.3270476 [288] 0.3271762 0.3273046 0.3274328 0.3275608 0.3276887 0.3278163 0.3279438 [295] 0.3280710 0.3281981 0.3283250 0.3284517 0.3285783 0.3287046 0.3288307 [302] 0.3289567 0.3290825 0.3292080 0.3293334 0.3294586 0.3295836 0.3297085 [309] 0.3298331 0.3299575 0.3300818 0.3302059 0.3303297 0.3304534 0.3305769 [316] 0.3307002 0.3308233 0.3309462 0.3310689 0.3311915 0.3313138 0.3314360 [323] 0.3315579 0.3316797 0.3318013 0.3319226 0.3320438 0.3321648 0.3322856 [330] 0.3324062 0.3325267 0.3326469 0.3327669 0.3328868 0.3330064 0.3331258 [337] 0.3332451 0.3333642 0.3334830 0.3336017 0.3337202 0.3338385 0.3339566 [344] 0.3340745 0.3341922 0.3343097 0.3344270 0.3345441 0.3346610 0.3347777 [351] 0.3348943 0.3350106 0.3351267 0.3352427 0.3353584 0.3354740 0.3355893 [358] 0.3357045 0.3358194 0.3359342 0.3360487 0.3361631 0.3362773 0.3363913 [365] 0.3365050 0.3366186 0.3367320 0.3368452 0.3369582 0.3370710 0.3371836 [372] 0.3372960 0.3374082 0.3375202 0.3376320 0.3377436 0.3378550 0.3379662 [379] 0.3380772 0.3381880 0.3382986 0.3384090 0.3385192 0.3386292 0.3387391 [386] 0.3388487 0.3389581 0.3390673 0.3391763 0.3392852 0.3393938 0.3395022 [393] 0.3396104 0.3397184 0.3398263 0.3399339 0.3400413 0.3401485 0.3402556 [400] 0.3403624 0.3404690 > mx [1] 0.340469 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1vies1194297012.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/2x7mw1194297012.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/3tvhf1194297012.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/45drc1194297012.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/5vpj51194297012.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/6758j1194297012.tab") > > system("convert tmp/1vies1194297012.ps tmp/1vies1194297012.png") > system("convert tmp/2x7mw1194297012.ps tmp/2x7mw1194297012.png") > system("convert tmp/3tvhf1194297012.ps tmp/3tvhf1194297012.png") > system("convert tmp/45drc1194297012.ps tmp/45drc1194297012.png") > system("convert tmp/5vpj51194297012.ps tmp/5vpj51194297012.png") > > > proc.time() user system elapsed 2.397 1.314 2.592