R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(3016,2155,2172,2150,2533,2058,2160,2260,2498,2695,2799,2946,2930,2318,2540,2570,2669,2450,2842,3440,2678,2981,2260,2844,2546,2456,2295,2379,2479,2057,2280,2351,2276,2548,2311,2201,2725,2408,2139,1898,2537,2068,2063,2520,2434,2190,2794,2070,2615,2265,2139,2428,2137,1823,2063,1806,1758,2243,1993,1932,2465) > x <- c(16,15,16,15,17,14,15,16,16,15,13,12,13,13,12,10,14,14,15,16,16,15,15,13,15,15,15,13,16,16,14,16,15,14,15,15,14,13,12,13,12,9,10,8,11,8,8,8,4,6,8,10,5,6,5,9,8,6,9,11,11) > #'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.2164121 0.2171045 0.2177966 0.2184882 0.2191793 0.2198700 0.2205602 [8] 0.2212498 0.2219389 0.2226275 0.2233155 0.2240029 0.2246897 0.2253759 [15] 0.2260615 0.2267463 0.2274306 0.2281141 0.2287969 0.2294790 0.2301604 [22] 0.2308410 0.2315208 0.2321998 0.2328780 0.2335554 0.2342319 0.2349076 [29] 0.2355824 0.2362562 0.2369292 0.2376012 0.2382723 0.2389424 0.2396115 [36] 0.2402796 0.2409467 0.2416127 0.2422777 0.2429416 0.2436044 0.2442661 [43] 0.2449267 0.2455861 0.2462444 0.2469015 0.2475574 0.2482121 0.2488655 [50] 0.2495177 0.2501687 0.2508183 0.2514667 0.2521138 0.2527595 0.2534039 [57] 0.2540469 0.2546885 0.2553288 0.2559676 0.2566050 0.2572410 0.2578755 [64] 0.2585085 0.2591400 0.2597700 0.2603985 0.2610255 0.2616509 0.2622747 [71] 0.2628970 0.2635176 0.2641366 0.2647540 0.2653698 0.2659839 0.2665963 [78] 0.2672070 0.2678160 0.2684233 0.2690288 0.2696326 0.2702347 0.2708349 [85] 0.2714334 0.2720301 0.2726249 0.2732179 0.2738091 0.2743984 0.2749858 [92] 0.2755713 0.2761550 0.2767367 0.2773165 0.2778943 0.2784702 0.2790442 [99] 0.2796161 0.2801861 0.2807541 0.2813200 0.2818840 0.2824459 0.2830057 [106] 0.2835635 0.2841192 0.2846729 0.2852244 0.2857738 0.2863211 0.2868663 [113] 0.2874094 0.2879503 0.2884890 0.2890256 0.2895600 0.2900922 0.2906222 [120] 0.2911501 0.2916756 0.2921990 0.2927202 0.2932390 0.2937557 0.2942701 [127] 0.2947822 0.2952920 0.2957995 0.2963048 0.2968078 0.2973084 0.2978067 [134] 0.2983027 0.2987964 0.2992877 0.2997767 0.3002633 0.3007476 0.3012295 [141] 0.3017090 0.3021862 0.3026609 0.3031333 0.3036033 0.3040709 0.3045361 [148] 0.3049988 0.3054592 0.3059171 0.3063726 0.3068256 0.3072763 0.3077244 [155] 0.3081702 0.3086135 0.3090543 0.3094927 0.3099286 0.3103620 0.3107930 [162] 0.3112215 0.3116476 0.3120711 0.3124922 0.3129108 0.3133269 0.3137406 [169] 0.3141517 0.3145604 0.3149665 0.3153702 0.3157714 0.3161700 0.3165662 [176] 0.3169599 0.3173510 0.3177397 0.3181259 0.3185096 0.3188907 0.3192694 [183] 0.3196455 0.3200192 0.3203903 0.3207590 0.3211251 0.3214888 0.3218499 [190] 0.3222086 0.3225647 0.3229183 0.3232695 0.3236181 0.3239643 0.3243080 [197] 0.3246491 0.3249878 0.3253240 0.3256577 0.3259889 0.3263177 0.3266440 [204] 0.3269677 0.3272891 0.3276079 0.3279243 0.3282382 0.3285497 0.3288587 [211] 0.3291652 0.3294693 0.3297709 0.3300701 0.3303669 0.3306612 0.3309531 [218] 0.3312425 0.3315296 0.3318142 0.3320964 0.3323762 0.3326536 0.3329286 [225] 0.3332011 0.3334713 0.3337391 0.3340046 0.3342676 0.3345283 0.3347866 [232] 0.3350425 0.3352961 0.3355474 0.3357963 0.3360429 0.3362871 0.3365290 [239] 0.3367686 0.3370058 0.3372408 0.3374735 0.3377038 0.3379319 0.3381577 [246] 0.3383812 0.3386024 0.3388214 0.3390381 0.3392526 0.3394648 0.3396748 [253] 0.3398826 0.3400881 0.3402915 0.3404926 0.3406915 0.3408882 0.3410828 [260] 0.3412751 0.3414653 0.3416534 0.3418392 0.3420229 0.3422045 0.3423840 [267] 0.3425613 0.3427365 0.3429096 0.3430806 0.3432495 0.3434163 0.3435810 [274] 0.3437437 0.3439043 0.3440628 0.3442193 0.3443738 0.3445262 0.3446766 [281] 0.3448250 0.3449714 0.3451158 0.3452582 0.3453986 0.3455370 0.3456735 [288] 0.3458081 0.3459406 0.3460713 0.3462000 0.3463268 0.3464517 0.3465746 [295] 0.3466957 0.3468149 0.3469322 0.3470477 0.3471613 0.3472730 0.3473829 [302] 0.3474910 0.3475972 0.3477016 0.3478042 0.3479050 0.3480040 0.3481012 [309] 0.3481967 0.3482904 0.3483823 0.3484725 0.3485610 0.3486477 0.3487327 [316] 0.3488160 0.3488975 0.3489774 0.3490556 0.3491321 0.3492070 0.3492802 [323] 0.3493517 0.3494216 0.3494899 0.3495566 0.3496216 0.3496850 0.3497468 [330] 0.3498071 0.3498657 0.3499228 0.3499783 0.3500323 0.3500847 0.3501356 [337] 0.3501849 0.3502328 0.3502791 0.3503239 0.3503672 0.3504091 0.3504494 [344] 0.3504883 0.3505257 0.3505617 0.3505963 0.3506294 0.3506610 0.3506913 [351] 0.3507202 0.3507476 0.3507737 0.3507984 0.3508217 0.3508436 0.3508642 [358] 0.3508834 0.3509013 0.3509179 0.3509331 0.3509470 0.3509596 0.3509709 [365] 0.3509810 0.3509897 0.3509972 0.3510033 0.3510083 0.3510120 0.3510144 [372] 0.3510156 0.3510156 0.3510143 0.3510119 0.3510082 0.3510034 0.3509973 [379] 0.3509901 0.3509817 0.3509722 0.3509615 0.3509496 0.3509366 0.3509225 [386] 0.3509072 0.3508908 0.3508733 0.3508548 0.3508351 0.3508143 0.3507925 [393] 0.3507695 0.3507455 0.3507205 0.3506944 0.3506673 0.3506391 0.3506099 [400] 0.3505797 0.3505484 > mx [1] 0.3510156 > mxli [1] 1.71 > 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/1v2xy1258123335.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/2zow41258123335.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/3if8s1258123335.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/4j3111258123335.tab") > > system("convert tmp/1v2xy1258123335.ps tmp/1v2xy1258123335.png") > system("convert tmp/2zow41258123335.ps tmp/2zow41258123335.png") > system("convert tmp/3if8s1258123335.ps tmp/3if8s1258123335.png") > > > proc.time() user system elapsed 0.801 0.512 1.087