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(109.57,107.08,110.33,110.36,106.5,104.3,107.21,109.34,108.2,109.86,108.68,113.38,117.12,116.23,114.75,115.81,115.86,117.8,117.11,116.31,118.38,121.57,121.65,124.2,126.12,128.6,128.16,130.12,135.83,138.05,134.99,132.38,128.94,128.12,127.84,132.43,134.13,134.78,133.13,129.08,134.48,132.86,134.08,134.54,134.51,135.97,136.09,139.14,135.63,136.55,138.83,138.84,135.37,132.22,134.75,135.98,136.06,138.05,139.59,140.58) > x <- c(156.4,143.1,148.9,134,118,125.3,138,114,109.9,151.5,129.1,121.7,126.1,114.3,124.7,111.9,120,119.5,137.8,105.4,135.4,182.5,129.6,147.5,128.9,119.7,149.4,136.6,118.6,121.4,138.9,109.5,131.7,160.3,138.1,136.7,126.6,138,152,137,134.9,154.4,145.2,133.1,169.6,159.3,124.9,138.1,162.5,136.6,148.1,142,137.9,152.5,182.8,135.3,141.8,151.7,140.6,128) > #'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.3318339 0.3317605 0.3316868 0.3316128 0.3315386 0.3314641 0.3313893 [8] 0.3313142 0.3312389 0.3311633 0.3310875 0.3310113 0.3309350 0.3308583 [15] 0.3307814 0.3307042 0.3306267 0.3305490 0.3304710 0.3303927 0.3303141 [22] 0.3302353 0.3301562 0.3300769 0.3299973 0.3299174 0.3298372 0.3297568 [29] 0.3296761 0.3295951 0.3295139 0.3294324 0.3293506 0.3292686 0.3291862 [36] 0.3291037 0.3290208 0.3289377 0.3288543 0.3287706 0.3286867 0.3286025 [43] 0.3285180 0.3284333 0.3283483 0.3282630 0.3281774 0.3280916 0.3280055 [50] 0.3279191 0.3278325 0.3277456 0.3276584 0.3275710 0.3274833 0.3273953 [57] 0.3273070 0.3272185 0.3271297 0.3270407 0.3269513 0.3268617 0.3267719 [64] 0.3266817 0.3265913 0.3265006 0.3264097 0.3263185 0.3262270 0.3261352 [71] 0.3260432 0.3259509 0.3258583 0.3257655 0.3256724 0.3255790 0.3254854 [78] 0.3253915 0.3252973 0.3252028 0.3251081 0.3250131 0.3249178 0.3248223 [85] 0.3247265 0.3246304 0.3245341 0.3244375 0.3243406 0.3242435 0.3241461 [92] 0.3240484 0.3239504 0.3238522 0.3237537 0.3236550 0.3235559 0.3234567 [99] 0.3233571 0.3232573 0.3231572 0.3230568 0.3229562 0.3228553 0.3227541 [106] 0.3226527 0.3225509 0.3224490 0.3223467 0.3222442 0.3221415 0.3220384 [113] 0.3219351 0.3218315 0.3217277 0.3216236 0.3215192 0.3214146 0.3213096 [120] 0.3212045 0.3210990 0.3209933 0.3208873 0.3207811 0.3206746 0.3205678 [127] 0.3204608 0.3203535 0.3202459 0.3201381 0.3200300 0.3199216 0.3198130 [134] 0.3197041 0.3195949 0.3194855 0.3193758 0.3192659 0.3191556 0.3190452 [141] 0.3189344 0.3188234 0.3187121 0.3186006 0.3184888 0.3183767 0.3182644 [148] 0.3181518 0.3180390 0.3179259 0.3178125 0.3176989 0.3175850 0.3174708 [155] 0.3173564 0.3172417 0.3171268 0.3170115 0.3168961 0.3167804 0.3166644 [162] 0.3165481 0.3164316 0.3163148 0.3161978 0.3160805 0.3159630 0.3158452 [169] 0.3157271 0.3156088 0.3154902 0.3153713 0.3152522 0.3151329 0.3150133 [176] 0.3148934 0.3147732 0.3146529 0.3145322 0.3144113 0.3142901 0.3141687 [183] 0.3140471 0.3139251 0.3138029 0.3136805 0.3135578 0.3134348 0.3133116 [190] 0.3131882 0.3130645 0.3129405 0.3128163 0.3126918 0.3125670 0.3124421 [197] 0.3123168 0.3121913 0.3120656 0.3119396 0.3118133 0.3116868 0.3115601 [204] 0.3114331 0.3113058 0.3111783 0.3110506 0.3109226 0.3107943 0.3106658 [211] 0.3105370 0.3104080 0.3102788 0.3101493 0.3100195 0.3098895 0.3097593 [218] 0.3096288 0.3094980 0.3093671 0.3092358 0.3091043 0.3089726 0.3088406 [225] 0.3087084 0.3085759 0.3084432 0.3083103 0.3081771 0.3080436 0.3079100 [232] 0.3077760 0.3076418 0.3075074 0.3073728 0.3072379 0.3071027 0.3069673 [239] 0.3068317 0.3066959 0.3065597 0.3064234 0.3062868 0.3061500 0.3060129 [246] 0.3058756 0.3057381 0.3056003 0.3054623 0.3053240 0.3051855 0.3050468 [253] 0.3049078 0.3047686 0.3046292 0.3044895 0.3043496 0.3042094 0.3040690 [260] 0.3039284 0.3037876 0.3036465 0.3035052 0.3033636 0.3032218 0.3030798 [267] 0.3029376 0.3027951 0.3026524 0.3025095 0.3023663 0.3022229 0.3020793 [274] 0.3019354 0.3017913 0.3016470 0.3015025 0.3013577 0.3012127 0.3010675 [281] 0.3009220 0.3007764 0.3006305 0.3004843 0.3003380 0.3001914 0.3000446 [288] 0.2998976 0.2997504 0.2996029 0.2994552 0.2993073 0.2991592 0.2990108 [295] 0.2988622 0.2987134 0.2985644 0.2984152 0.2982657 0.2981161 0.2979662 [302] 0.2978161 0.2976658 0.2975152 0.2973645 0.2972135 0.2970623 0.2969109 [309] 0.2967593 0.2966075 0.2964554 0.2963032 0.2961507 0.2959980 0.2958451 [316] 0.2956920 0.2955387 0.2953852 0.2952314 0.2950775 0.2949233 0.2947690 [323] 0.2946144 0.2944596 0.2943047 0.2941495 0.2939941 0.2938385 0.2936826 [330] 0.2935266 0.2933704 0.2932140 0.2930574 0.2929005 0.2927435 0.2925863 [337] 0.2924288 0.2922712 0.2921134 0.2919553 0.2917971 0.2916387 0.2914800 [344] 0.2913212 0.2911622 0.2910030 0.2908435 0.2906839 0.2905241 0.2903641 [351] 0.2902039 0.2900435 0.2898829 0.2897221 0.2895612 0.2894000 0.2892386 [358] 0.2890771 0.2889154 0.2887534 0.2885913 0.2884290 0.2882665 0.2881038 [365] 0.2879410 0.2877779 0.2876147 0.2874513 0.2872876 0.2871238 0.2869599 [372] 0.2867957 0.2866314 0.2864668 0.2863021 0.2861372 0.2859722 0.2858069 [379] 0.2856415 0.2854759 0.2853101 0.2851441 0.2849780 0.2848117 0.2846452 [386] 0.2844785 0.2843117 0.2841446 0.2839775 0.2838101 0.2836425 0.2834748 [393] 0.2833070 0.2831389 0.2829707 0.2828023 0.2826337 0.2824650 0.2822961 [400] 0.2821270 0.2819578 > mx [1] 0.3318339 > 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/1v9tl1226521176.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/230d61226521176.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/36gbc1226521176.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/44dk71226521176.tab") > > system("convert tmp/1v9tl1226521176.ps tmp/1v9tl1226521176.png") > system("convert tmp/230d61226521176.ps tmp/230d61226521176.png") > system("convert tmp/36gbc1226521176.ps tmp/36gbc1226521176.png") > > > proc.time() user system elapsed 0.982 0.499 1.272