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(433,344,357,385,392,308,294,302,400,392,373,379,303,324,353,392,327,376,329,359,413,338,422,390,370,367,406,418,346,350,329,318,381,337,372,422,427,426,396,458,314,336,385,351,381,438,397,451,362,363,468,371,407,391,364,366,424,364,366,423) > #'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.2950266 0.2949774 0.2949281 0.2948788 0.2948294 0.2947800 0.2947305 [8] 0.2946810 0.2946314 0.2945817 0.2945320 0.2944822 0.2944324 0.2943825 [15] 0.2943326 0.2942826 0.2942325 0.2941824 0.2941322 0.2940820 0.2940317 [22] 0.2939814 0.2939310 0.2938805 0.2938300 0.2937795 0.2937289 0.2936782 [29] 0.2936275 0.2935767 0.2935259 0.2934750 0.2934240 0.2933730 0.2933220 [36] 0.2932708 0.2932197 0.2931685 0.2931172 0.2930659 0.2930145 0.2929630 [43] 0.2929115 0.2928600 0.2928084 0.2927568 0.2927050 0.2926533 0.2926015 [50] 0.2925496 0.2924977 0.2924457 0.2923937 0.2923416 0.2922895 0.2922373 [57] 0.2921851 0.2921328 0.2920804 0.2920280 0.2919756 0.2919231 0.2918706 [64] 0.2918180 0.2917653 0.2917126 0.2916598 0.2916070 0.2915542 0.2915013 [71] 0.2914483 0.2913953 0.2913422 0.2912891 0.2912360 0.2911827 0.2911295 [78] 0.2910762 0.2910228 0.2909694 0.2909159 0.2908624 0.2908088 0.2907552 [85] 0.2907016 0.2906478 0.2905941 0.2905403 0.2904864 0.2904325 0.2903785 [92] 0.2903245 0.2902705 0.2902164 0.2901622 0.2901080 0.2900538 0.2899995 [99] 0.2899451 0.2898907 0.2898363 0.2897818 0.2897273 0.2896727 0.2896181 [106] 0.2895634 0.2895086 0.2894539 0.2893991 0.2893442 0.2892893 0.2892343 [113] 0.2891793 0.2891243 0.2890692 0.2890140 0.2889588 0.2889036 0.2888483 [120] 0.2887930 0.2887376 0.2886822 0.2886268 0.2885712 0.2885157 0.2884601 [127] 0.2884045 0.2883488 0.2882930 0.2882373 0.2881815 0.2881256 0.2880697 [134] 0.2880137 0.2879577 0.2879017 0.2878456 0.2877895 0.2877333 0.2876771 [141] 0.2876209 0.2875646 0.2875082 0.2874519 0.2873954 0.2873390 0.2872825 [148] 0.2872259 0.2871693 0.2871127 0.2870560 0.2869993 0.2869425 0.2868857 [155] 0.2868289 0.2867720 0.2867151 0.2866581 0.2866011 0.2865441 0.2864870 [162] 0.2864299 0.2863727 0.2863155 0.2862583 0.2862010 0.2861436 0.2860863 [169] 0.2860289 0.2859714 0.2859140 0.2858564 0.2857989 0.2857413 0.2856836 [176] 0.2856260 0.2855682 0.2855105 0.2854527 0.2853949 0.2853370 0.2852791 [183] 0.2852212 0.2851632 0.2851052 0.2850471 0.2849890 0.2849309 0.2848727 [190] 0.2848145 0.2847563 0.2846980 0.2846397 0.2845814 0.2845230 0.2844646 [197] 0.2844061 0.2843476 0.2842891 0.2842305 0.2841719 0.2841133 0.2840546 [204] 0.2839959 0.2839372 0.2838784 0.2838196 0.2837608 0.2837019 0.2836430 [211] 0.2835841 0.2835251 0.2834661 0.2834071 0.2833480 0.2832889 0.2832297 [218] 0.2831706 0.2831114 0.2830521 0.2829929 0.2829336 0.2828742 0.2828149 [225] 0.2827555 0.2826960 0.2826366 0.2825771 0.2825175 0.2824580 0.2823984 [232] 0.2823388 0.2822791 0.2822195 0.2821597 0.2821000 0.2820402 0.2819804 [239] 0.2819206 0.2818607 0.2818008 0.2817409 0.2816810 0.2816210 0.2815610 [246] 0.2815010 0.2814409 0.2813808 0.2813207 0.2812605 0.2812003 0.2811401 [253] 0.2810799 0.2810196 0.2809593 0.2808990 0.2808387 0.2807783 0.2807179 [260] 0.2806575 0.2805970 0.2805365 0.2804760 0.2804155 0.2803549 0.2802943 [267] 0.2802337 0.2801731 0.2801124 0.2800517 0.2799910 0.2799302 0.2798695 [274] 0.2798087 0.2797479 0.2796870 0.2796261 0.2795652 0.2795043 0.2794434 [281] 0.2793824 0.2793214 0.2792604 0.2791994 0.2791383 0.2790772 0.2790161 [288] 0.2789550 0.2788938 0.2788327 0.2787715 0.2787102 0.2786490 0.2785877 [295] 0.2785264 0.2784651 0.2784038 0.2783424 0.2782811 0.2782197 0.2781582 [302] 0.2780968 0.2780353 0.2779739 0.2779124 0.2778508 0.2777893 0.2777277 [309] 0.2776661 0.2776045 0.2775429 0.2774813 0.2774196 0.2773579 0.2772962 [316] 0.2772345 0.2771727 0.2771110 0.2770492 0.2769874 0.2769256 0.2768638 [323] 0.2768019 0.2767400 0.2766781 0.2766162 0.2765543 0.2764924 0.2764304 [330] 0.2763684 0.2763064 0.2762444 0.2761824 0.2761204 0.2760583 0.2759962 [337] 0.2759341 0.2758720 0.2758099 0.2757477 0.2756856 0.2756234 0.2755612 [344] 0.2754990 0.2754368 0.2753746 0.2753123 0.2752501 0.2751878 0.2751255 [351] 0.2750632 0.2750009 0.2749385 0.2748762 0.2748138 0.2747514 0.2746890 [358] 0.2746266 0.2745642 0.2745018 0.2744394 0.2743769 0.2743144 0.2742519 [365] 0.2741895 0.2741270 0.2740644 0.2740019 0.2739394 0.2738768 0.2738143 [372] 0.2737517 0.2736891 0.2736265 0.2735639 0.2735013 0.2734386 0.2733760 [379] 0.2733133 0.2732507 0.2731880 0.2731253 0.2730626 0.2729999 0.2729372 [386] 0.2728745 0.2728118 0.2727490 0.2726863 0.2726235 0.2725608 0.2724980 [393] 0.2724352 0.2723724 0.2723096 0.2722468 0.2721840 0.2721212 0.2720584 [400] 0.2719955 0.2719327 > mx [1] 0.2950266 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/rcomp/tmp/11ta21257700984.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/2er4x1257700984.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/36r411257700984.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/4lgpk1257700984.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/54o961257700984.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/6sksr1257700984.tab") > > system("convert tmp/11ta21257700984.ps tmp/11ta21257700984.png") > system("convert tmp/2er4x1257700984.ps tmp/2er4x1257700984.png") > system("convert tmp/36r411257700984.ps tmp/36r411257700984.png") > system("convert tmp/4lgpk1257700984.ps tmp/4lgpk1257700984.png") > system("convert tmp/54o961257700984.ps tmp/54o961257700984.png") > > > proc.time() user system elapsed 1.420 1.210 2.293