R version 2.8.0 (2008-10-20) 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(117.1,118.7,126.5,127.5,134.6,131.8,135.9,142.7,141.7,153.4,145,137.7,148.3,152.2,169.4,168.6,161.1,174.1,179,190.6,190,181.6,174.8,180.5,196.8,193.8,197,216.3,221.4,217.9,229.7,227.4,204.2,196.6,198.8,207.5,190.7,201.6,210.5,223.5,223.8,231.2,244,234.7,250.2,265.7,287.6,283.3,295.4,312.3,333.8,347.7,383.2,407.1,413.6,362.7,321.9,239.4,191,159.7,163.4) > x <- c(95.1,97,112.7,102.9,97.4,111.4,87.4,96.8,114.1,110.3,103.9,101.6,94.6,95.9,104.7,102.8,98.1,113.9,80.9,95.7,113.2,105.9,108.8,102.3,99,100.7,115.5,100.7,109.9,114.6,85.4,100.5,114.8,116.5,112.9,102,106,105.3,118.8,106.1,109.3,117.2,92.5,104.2,112.5,122.4,113.3,100,110.7,112.8,109.8,117.3,109.1,115.9,96,99.8,116.8,115.7,99.4,94.3,91) > #'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.2812098 0.2812995 0.2813889 0.2814783 0.2815676 0.2816567 0.2817457 [8] 0.2818346 0.2819234 0.2820121 0.2821007 0.2821891 0.2822774 0.2823656 [15] 0.2824537 0.2825416 0.2826295 0.2827172 0.2828048 0.2828923 0.2829797 [22] 0.2830669 0.2831540 0.2832411 0.2833280 0.2834147 0.2835014 0.2835879 [29] 0.2836744 0.2837607 0.2838468 0.2839329 0.2840189 0.2841047 0.2841904 [36] 0.2842760 0.2843615 0.2844468 0.2845321 0.2846172 0.2847022 0.2847871 [43] 0.2848718 0.2849565 0.2850410 0.2851254 0.2852097 0.2852938 0.2853779 [50] 0.2854618 0.2855456 0.2856293 0.2857129 0.2857963 0.2858797 0.2859629 [57] 0.2860460 0.2861290 0.2862118 0.2862946 0.2863772 0.2864597 0.2865421 [64] 0.2866243 0.2867065 0.2867885 0.2868704 0.2869522 0.2870339 0.2871154 [71] 0.2871968 0.2872781 0.2873593 0.2874404 0.2875214 0.2876022 0.2876829 [78] 0.2877635 0.2878440 0.2879243 0.2880046 0.2880847 0.2881647 0.2882446 [85] 0.2883243 0.2884040 0.2884835 0.2885629 0.2886422 0.2887213 0.2888004 [92] 0.2888793 0.2889581 0.2890368 0.2891154 0.2891938 0.2892722 0.2893504 [99] 0.2894285 0.2895064 0.2895843 0.2896620 0.2897397 0.2898172 0.2898945 [106] 0.2899718 0.2900489 0.2901260 0.2902029 0.2902797 0.2903563 0.2904329 [113] 0.2905093 0.2905856 0.2906618 0.2907379 0.2908138 0.2908897 0.2909654 [120] 0.2910410 0.2911164 0.2911918 0.2912670 0.2913422 0.2914172 0.2914921 [127] 0.2915668 0.2916415 0.2917160 0.2917904 0.2918647 0.2919389 0.2920129 [134] 0.2920869 0.2921607 0.2922344 0.2923080 0.2923814 0.2924548 0.2925280 [141] 0.2926011 0.2926741 0.2927470 0.2928197 0.2928924 0.2929649 0.2930373 [148] 0.2931096 0.2931817 0.2932538 0.2933257 0.2933975 0.2934692 0.2935408 [155] 0.2936123 0.2936836 0.2937548 0.2938259 0.2938969 0.2939678 0.2940385 [162] 0.2941092 0.2941797 0.2942501 0.2943204 0.2943905 0.2944606 0.2945305 [169] 0.2946003 0.2946700 0.2947396 0.2948091 0.2948784 0.2949477 0.2950168 [176] 0.2950858 0.2951546 0.2952234 0.2952920 0.2953606 0.2954290 0.2954973 [183] 0.2955655 0.2956335 0.2957015 0.2957693 0.2958370 0.2959046 0.2959721 [190] 0.2960394 0.2961067 0.2961738 0.2962408 0.2963077 0.2963745 0.2964412 [197] 0.2965077 0.2965742 0.2966405 0.2967067 0.2967728 0.2968388 0.2969046 [204] 0.2969704 0.2970360 0.2971015 0.2971669 0.2972322 0.2972973 0.2973624 [211] 0.2974273 0.2974921 0.2975568 0.2976214 0.2976859 0.2977503 0.2978145 [218] 0.2978786 0.2979427 0.2980066 0.2980703 0.2981340 0.2981976 0.2982610 [225] 0.2983243 0.2983876 0.2984507 0.2985136 0.2985765 0.2986393 0.2987019 [232] 0.2987645 0.2988269 0.2988892 0.2989514 0.2990134 0.2990754 0.2991372 [239] 0.2991990 0.2992606 0.2993221 0.2993835 0.2994448 0.2995060 0.2995670 [246] 0.2996280 0.2996888 0.2997495 0.2998101 0.2998706 0.2999310 0.2999912 [253] 0.3000514 0.3001114 0.3001714 0.3002312 0.3002909 0.3003505 0.3004100 [260] 0.3004693 0.3005286 0.3005877 0.3006468 0.3007057 0.3007645 0.3008232 [267] 0.3008818 0.3009403 0.3009986 0.3010569 0.3011150 0.3011730 0.3012310 [274] 0.3012888 0.3013465 0.3014041 0.3014615 0.3015189 0.3015762 0.3016333 [281] 0.3016903 0.3017473 0.3018041 0.3018608 0.3019174 0.3019738 0.3020302 [288] 0.3020865 0.3021426 0.3021987 0.3022546 0.3023104 0.3023661 0.3024217 [295] 0.3024772 0.3025326 0.3025879 0.3026431 0.3026981 0.3027531 0.3028079 [302] 0.3028626 0.3029173 0.3029718 0.3030262 0.3030805 0.3031347 0.3031887 [309] 0.3032427 0.3032966 0.3033503 0.3034040 0.3034575 0.3035109 0.3035643 [316] 0.3036175 0.3036706 0.3037236 0.3037765 0.3038293 0.3038819 0.3039345 [323] 0.3039870 0.3040393 0.3040916 0.3041437 0.3041958 0.3042477 0.3042995 [330] 0.3043512 0.3044028 0.3044543 0.3045057 0.3045570 0.3046082 0.3046593 [337] 0.3047103 0.3047611 0.3048119 0.3048625 0.3049131 0.3049635 0.3050139 [344] 0.3050641 0.3051142 0.3051643 0.3052142 0.3052640 0.3053137 0.3053633 [351] 0.3054128 0.3054622 0.3055115 0.3055607 0.3056097 0.3056587 0.3057076 [358] 0.3057563 0.3058050 0.3058536 0.3059020 0.3059504 0.3059986 0.3060468 [365] 0.3060948 0.3061427 0.3061906 0.3062383 0.3062859 0.3063334 0.3063809 [372] 0.3064282 0.3064754 0.3065225 0.3065695 0.3066164 0.3066632 0.3067099 [379] 0.3067565 0.3068030 0.3068494 0.3068957 0.3069419 0.3069880 0.3070340 [386] 0.3070799 0.3071257 0.3071713 0.3072169 0.3072624 0.3073078 0.3073531 [393] 0.3073982 0.3074433 0.3074883 0.3075332 0.3075779 0.3076226 0.3076672 [400] 0.3077117 0.3077560 > mx [1] 0.307756 > 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/freestat/rcomp/tmp/1uzoi1258035956.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/freestat/rcomp/tmp/2qyav1258035956.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/freestat/rcomp/tmp/3c4nf1258035956.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/467bc1258035956.tab") > > system("convert tmp/1uzoi1258035956.ps tmp/1uzoi1258035956.png") > system("convert tmp/2qyav1258035956.ps tmp/2qyav1258035956.png") > system("convert tmp/3c4nf1258035956.ps tmp/3c4nf1258035956.png") > > > proc.time() user system elapsed 1.223 0.813 1.397