R version 2.7.2 (2008-08-25) 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. > y <- c(5.5,10.5,15.8,13.3,12,10.3,15,14.7,12.2,10.4,11.8) > x <- c(248.4,268,267.9,263.2,263.2,333.8,312.3,295.4,283.3,287.6,265.7) > #'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(x1,y) + if (mx < abs(c[i])) + { + mx <- abs(c[i]) + mxli <- l[i] + } + } > c [1] 0.3507593 0.3504920 0.3502246 0.3499572 0.3496898 0.3494223 0.3491548 [8] 0.3488872 0.3486197 0.3483520 0.3480844 0.3478167 0.3475490 0.3472812 [15] 0.3470134 0.3467456 0.3464778 0.3462099 0.3459420 0.3456740 0.3454060 [22] 0.3451380 0.3448700 0.3446019 0.3443338 0.3440657 0.3437975 0.3435293 [29] 0.3432610 0.3429928 0.3427245 0.3424562 0.3421878 0.3419194 0.3416510 [36] 0.3413826 0.3411141 0.3408456 0.3405771 0.3403085 0.3400399 0.3397713 [43] 0.3395027 0.3392340 0.3389653 0.3386966 0.3384278 0.3381590 0.3378902 [50] 0.3376214 0.3373525 0.3370836 0.3368147 0.3365458 0.3362768 0.3360078 [57] 0.3357388 0.3354697 0.3352007 0.3349316 0.3346625 0.3343933 0.3341242 [64] 0.3338550 0.3335858 0.3333165 0.3330473 0.3327780 0.3325087 0.3322394 [71] 0.3319700 0.3317006 0.3314312 0.3311618 0.3308924 0.3306229 0.3303534 [78] 0.3300839 0.3298144 0.3295449 0.3292753 0.3290057 0.3287361 0.3284665 [85] 0.3281968 0.3279272 0.3276575 0.3273878 0.3271181 0.3268483 0.3265786 [92] 0.3263088 0.3260390 0.3257692 0.3254993 0.3252295 0.3249596 0.3246897 [99] 0.3244198 0.3241499 0.3238800 0.3236100 0.3233401 0.3230701 0.3228001 [106] 0.3225301 0.3222600 0.3219900 0.3217199 0.3214498 0.3211798 0.3209096 [113] 0.3206395 0.3203694 0.3200992 0.3198291 0.3195589 0.3192887 0.3190185 [120] 0.3187483 0.3184781 0.3182078 0.3179376 0.3176673 0.3173971 0.3171268 [127] 0.3168565 0.3165862 0.3163158 0.3160455 0.3157752 0.3155048 0.3152345 [134] 0.3149641 0.3146937 0.3144233 0.3141529 0.3138825 0.3136121 0.3133417 [141] 0.3130712 0.3128008 0.3125303 0.3122599 0.3119894 0.3117189 0.3114484 [148] 0.3111780 0.3109075 0.3106370 0.3103664 0.3100959 0.3098254 0.3095549 [155] 0.3092843 0.3090138 0.3087433 0.3084727 0.3082022 0.3079316 0.3076610 [162] 0.3073905 0.3071199 0.3068493 0.3065787 0.3063081 0.3060376 0.3057670 [169] 0.3054964 0.3052258 0.3049552 0.3046846 0.3044140 0.3041434 0.3038728 [176] 0.3036021 0.3033315 0.3030609 0.3027903 0.3025197 0.3022491 0.3019785 [183] 0.3017079 0.3014372 0.3011666 0.3008960 0.3006254 0.3003548 0.3000842 [190] 0.2998136 0.2995430 0.2992724 0.2990018 0.2987312 0.2984606 0.2981900 [197] 0.2979194 0.2976488 0.2973782 0.2971076 0.2968370 0.2965664 0.2962959 [204] 0.2960253 0.2957547 0.2954842 0.2952136 0.2949431 0.2946725 0.2944020 [211] 0.2941315 0.2938609 0.2935904 0.2933199 0.2930494 0.2927789 0.2925084 [218] 0.2922379 0.2919674 0.2916969 0.2914265 0.2911560 0.2908856 0.2906151 [225] 0.2903447 0.2900743 0.2898038 0.2895334 0.2892630 0.2889926 0.2887223 [232] 0.2884519 0.2881815 0.2879112 0.2876408 0.2873705 0.2871002 0.2868299 [239] 0.2865596 0.2862893 0.2860190 0.2857488 0.2854785 0.2852083 0.2849381 [246] 0.2846679 0.2843977 0.2841275 0.2838573 0.2835871 0.2833170 0.2830469 [253] 0.2827768 0.2825066 0.2822366 0.2819665 0.2816964 0.2814264 0.2811564 [260] 0.2808863 0.2806163 0.2803464 0.2800764 0.2798065 0.2795365 0.2792666 [267] 0.2789967 0.2787268 0.2784570 0.2781871 0.2779173 0.2776475 0.2773777 [274] 0.2771079 0.2768382 0.2765684 0.2762987 0.2760290 0.2757593 0.2754897 [281] 0.2752200 0.2749504 0.2746808 0.2744112 0.2741417 0.2738721 0.2736026 [288] 0.2733331 0.2730636 0.2727942 0.2725247 0.2722553 0.2719859 0.2717166 [295] 0.2714472 0.2711779 0.2709086 0.2706393 0.2703701 0.2701008 0.2698316 [302] 0.2695625 0.2692933 0.2690242 0.2687551 0.2684860 0.2682169 0.2679479 [309] 0.2676789 0.2674099 0.2671409 0.2668720 0.2666031 0.2663342 0.2660654 [316] 0.2657966 0.2655278 0.2652590 0.2649902 0.2647215 0.2644528 0.2641842 [323] 0.2639155 0.2636469 0.2633784 0.2631098 0.2628413 0.2625728 0.2623043 [330] 0.2620359 0.2617675 0.2614991 0.2612308 0.2609625 0.2606942 0.2604260 [337] 0.2601577 0.2598895 0.2596214 0.2593533 0.2590852 0.2588171 0.2585491 [344] 0.2582811 0.2580131 0.2577452 0.2574773 0.2572094 0.2569416 0.2566738 [351] 0.2564060 0.2561383 0.2558706 0.2556029 0.2553353 0.2550677 0.2548001 [358] 0.2545326 0.2542651 0.2539977 0.2537302 0.2534628 0.2531955 0.2529282 [365] 0.2526609 0.2523937 0.2521265 0.2518593 0.2515922 0.2513251 0.2510580 [372] 0.2507910 0.2505240 0.2502571 0.2499902 0.2497233 0.2494565 0.2491897 [379] 0.2489230 0.2486562 0.2483896 0.2481229 0.2478564 0.2475898 0.2473233 [386] 0.2470568 0.2467904 0.2465240 0.2462577 0.2459914 0.2457251 0.2454589 [393] 0.2451927 0.2449265 0.2446604 0.2443944 0.2441284 0.2438624 0.2435965 [400] 0.2433306 0.2430647 > mx [1] 0.3507593 > mxli [1] -2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > r<-lm(y~x) > se <- sqrt(var(r$residuals)) > r1 <- lm(y~x1) > se1 <- sqrt(var(r1$residuals)) > postscript(file="/var/www/html/rcomp/tmp/1hbir1226600042.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(l,c,main='Box-Cox Linearity Plot',xlab='Lambda',ylab='correlation') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/2bq181226600042.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x,y,main='Linear Fit of Original Data',xlab='x',ylab='y') > abline(r) > grid() > mtext(paste('Residual Standard Deviation = ',se)) > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/31f6r1226600042.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x1,y,main='Linear Fit of Transformed Data',xlab='x',ylab='y') > abline(r1) > grid() > mtext(paste('Residual Standard Deviation = ',se1)) > 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 Linearity 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(x)',header=TRUE) > a<-table.element(a,mxli) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Residual SD (orginial)',header=TRUE) > a<-table.element(a,se) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Residual SD (transformed)',header=TRUE) > a<-table.element(a,se1) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/4vh2k1226600042.tab") > > system("convert tmp/1hbir1226600042.ps tmp/1hbir1226600042.png") > system("convert tmp/2bq181226600042.ps tmp/2bq181226600042.png") > system("convert tmp/31f6r1226600042.ps tmp/31f6r1226600042.png") > > > proc.time() user system elapsed 1.014 0.537 1.416