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(1258,1199,1158,1427,934,709,1186,986,1033,1257,1105,1179,1092,1092,1087,2028,2039,2010,754,760,715,855,971,815,915,843,761,1858,2968,4061,3661,3269,2857,2568,2274,1987,683,381,71,1772,3485,5181,4479,3782,3067,2489,1903,1330,736,483,242,1334,2423,3523,2986,2462,1908,1575,1237,904) > x <- c(280,557,831,1081,1318,1578,1859,2141,2428,2715,3004,3309,269,537,813,1068,1411,1675,1958,2242,2524,2836,3143,3522,285,574,865,1147,1516,1789,2087,2372,2669,2966,3270,3652,329,658,988,1303,1603,1929,2235,2544,2872,3198,3544,3903,332,665,1001,1329,1639,1975,2304,2640,2992,3330,3690,4063) > #'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.2779422 0.2785078 0.2790751 0.2796441 0.2802147 0.2807869 0.2813606 [8] 0.2819358 0.2825126 0.2830908 0.2836704 0.2842514 0.2848338 0.2854175 [15] 0.2860025 0.2865888 0.2871762 0.2877649 0.2883547 0.2889455 0.2895374 [22] 0.2901304 0.2907242 0.2913190 0.2919147 0.2925112 0.2931085 0.2937065 [29] 0.2943052 0.2949045 0.2955043 0.2961047 0.2967056 0.2973068 0.2979084 [36] 0.2985103 0.2991125 0.2997148 0.3003172 0.3009197 0.3015221 0.3021245 [43] 0.3027267 0.3033288 0.3039305 0.3045319 0.3051328 0.3057333 0.3063332 [50] 0.3069325 0.3075310 0.3081287 0.3087256 0.3093215 0.3099164 0.3105102 [57] 0.3111028 0.3116941 0.3122841 0.3128725 0.3134595 0.3140448 0.3146285 [64] 0.3152103 0.3157902 0.3163681 0.3169439 0.3175176 0.3180890 0.3186580 [71] 0.3192245 0.3197885 0.3203498 0.3209083 0.3214639 0.3220166 0.3225662 [78] 0.3231126 0.3236557 0.3241954 0.3247315 0.3252641 0.3257929 0.3263179 [85] 0.3268389 0.3273559 0.3278687 0.3283771 0.3288812 0.3293808 0.3298757 [92] 0.3303658 0.3308511 0.3313314 0.3318066 0.3322765 0.3327412 0.3332003 [99] 0.3336538 0.3341017 0.3345437 0.3349798 0.3354098 0.3358336 0.3362511 [106] 0.3366621 0.3370666 0.3374645 0.3378555 0.3382396 0.3386167 0.3389866 [113] 0.3393492 0.3397045 0.3400522 0.3403922 0.3407246 0.3410490 0.3413654 [120] 0.3416737 0.3419738 0.3422656 0.3425489 0.3428236 0.3430896 0.3433468 [127] 0.3435952 0.3438344 0.3440646 0.3442855 0.3444971 0.3446992 0.3448918 [134] 0.3450747 0.3452478 0.3454111 0.3455644 0.3457076 0.3458407 0.3459635 [141] 0.3460761 0.3461781 0.3462697 0.3463506 0.3464209 0.3464804 0.3465290 [148] 0.3465667 0.3465934 0.3466090 0.3466135 0.3466067 0.3465887 0.3465593 [155] 0.3465184 0.3464661 0.3464023 0.3463268 0.3462398 0.3461410 0.3460304 [162] 0.3459081 0.3457740 0.3456279 0.3454700 0.3453001 0.3451183 0.3449244 [169] 0.3447185 0.3445005 0.3442705 0.3440284 0.3437741 0.3435077 0.3432292 [176] 0.3429386 0.3426358 0.3423208 0.3419938 0.3416545 0.3413032 0.3409397 [183] 0.3405641 0.3401764 0.3397766 0.3393647 0.3389409 0.3385050 0.3380571 [190] 0.3375973 0.3371256 0.3366420 0.3361465 0.3356393 0.3351203 0.3345896 [197] 0.3340473 0.3334933 0.3329279 0.3323509 0.3317625 0.3311627 0.3305516 [204] 0.3299293 0.3292959 0.3286513 0.3279957 0.3273292 0.3266518 0.3259636 [211] 0.3252646 0.3245551 0.3238350 0.3231045 0.3223636 0.3216124 0.3208511 [218] 0.3200796 0.3192982 0.3185069 0.3177057 0.3168949 0.3160745 0.3152445 [225] 0.3144052 0.3135566 0.3126988 0.3118320 0.3109562 0.3100715 0.3091781 [232] 0.3082761 0.3073655 0.3064465 0.3055193 0.3045838 0.3036403 0.3026889 [239] 0.3017296 0.3007626 0.2997881 0.2988060 0.2978166 0.2968200 0.2958162 [246] 0.2948054 0.2937878 0.2927634 0.2917324 0.2906948 0.2896508 0.2886006 [253] 0.2875442 0.2864818 0.2854134 0.2843393 0.2832594 0.2821741 0.2810832 [260] 0.2799871 0.2788857 0.2777793 0.2766679 0.2755517 0.2744307 0.2733051 [267] 0.2721750 0.2710405 0.2699018 0.2687589 0.2676119 0.2664611 0.2653064 [274] 0.2641480 0.2629861 0.2618206 0.2606518 0.2594797 0.2583045 0.2571262 [281] 0.2559450 0.2547609 0.2535741 0.2523847 0.2511928 0.2499985 0.2488018 [288] 0.2476029 0.2464019 0.2451989 0.2439940 0.2427872 0.2415787 0.2403686 [295] 0.2391570 0.2379438 0.2367294 0.2355137 0.2342968 0.2330788 0.2318598 [302] 0.2306399 0.2294192 0.2281977 0.2269756 0.2257529 0.2245297 0.2233061 [309] 0.2220822 0.2208580 0.2196336 0.2184092 0.2171847 0.2159603 0.2147360 [316] 0.2135118 0.2122880 0.2110645 0.2098414 0.2086188 0.2073967 0.2061752 [323] 0.2049544 0.2037344 0.2025151 0.2012968 0.2000793 0.1988628 0.1976474 [330] 0.1964331 0.1952199 0.1940080 0.1927973 0.1915880 0.1903801 0.1891736 [337] 0.1879685 0.1867651 0.1855632 0.1843629 0.1831643 0.1819675 0.1807725 [344] 0.1795793 0.1783879 0.1771985 0.1760110 0.1748255 0.1736421 0.1724608 [351] 0.1712815 0.1701045 0.1689296 0.1677570 0.1665867 0.1654187 0.1642530 [358] 0.1630897 0.1619288 0.1607704 0.1596144 0.1584610 0.1573101 0.1561618 [365] 0.1550161 0.1538730 0.1527326 0.1515949 0.1504599 0.1493276 0.1481981 [372] 0.1470714 0.1459475 0.1448264 0.1437082 0.1425929 0.1414805 0.1403711 [379] 0.1392645 0.1381610 0.1370604 0.1359629 0.1348683 0.1337769 0.1326884 [386] 0.1316031 0.1305209 0.1294417 0.1283657 0.1272929 0.1262232 0.1251566 [393] 0.1240933 0.1230332 0.1219762 0.1209225 0.1198720 0.1188248 0.1177808 [400] 0.1167401 0.1157026 > mx [1] 0.3466135 > mxli [1] -0.5 > 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/1yj7h1258141446.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/2toxq1258141446.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/3o5nf1258141446.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/4g5rw1258141446.tab") > > system("convert tmp/1yj7h1258141446.ps tmp/1yj7h1258141446.png") > system("convert tmp/2toxq1258141446.ps tmp/2toxq1258141446.png") > system("convert tmp/3o5nf1258141446.ps tmp/3o5nf1258141446.png") > > > proc.time() user system elapsed 0.834 0.531 1.032