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(2218,1855,2187,1852,1570,1851,1954,1828,2251,2277,2085,2282,2266,1878,2267,2069,1746,2299,2360,2214,2825,2355,2333,3016,2155,2172,2150,2533,2058,2160,2259,2498,2695,2799,2945,2930,2318,2540,2570,2669,2450,2842,3439,2677,2979,2257,2842,2546,2455,2293,2379,2478,2054,2272,2351,2271,2542,2304,2194,2722,2395,2146,1894,2548,2087,2063,2481,2476,2212,2834,2148,2598) > x <- c(22780,17351,21382,24561,17409,11514,31514,27071,29462,26105,22397,23843,21705,18089,20764,25316,17704,15548,28029,29383,36438,32034,22679,24319,18004,17537,20366,22782,19169,13807,29743,25591,29096,26482,22405,27044,17970,18730,19684,19785,18479,10698,31956,29506,34506,27165,26736,23691,18157,17328,18205,20995,17382,9367,31124,26551,30651,25859,25100,25778,20418,18688,20424,24776,19814,12738,31566,30111,30019,31934,25826,26835) > #'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.2308418 0.2315635 0.2322855 0.2330077 0.2337303 0.2344530 0.2351760 [8] 0.2358992 0.2366227 0.2373462 0.2380700 0.2387939 0.2395179 0.2402421 [15] 0.2409663 0.2416906 0.2424150 0.2431394 0.2438638 0.2445882 0.2453127 [22] 0.2460371 0.2467614 0.2474857 0.2482099 0.2489341 0.2496581 0.2503819 [29] 0.2511056 0.2518292 0.2525525 0.2532757 0.2539986 0.2547213 0.2554437 [36] 0.2561659 0.2568878 0.2576093 0.2583305 0.2590514 0.2597719 0.2604920 [43] 0.2612118 0.2619311 0.2626499 0.2633683 0.2640863 0.2648037 0.2655207 [50] 0.2662371 0.2669530 0.2676683 0.2683830 0.2690971 0.2698107 0.2705236 [57] 0.2712358 0.2719474 0.2726583 0.2733684 0.2740779 0.2747866 0.2754946 [64] 0.2762018 0.2769082 0.2776138 0.2783186 0.2790225 0.2797256 0.2804278 [71] 0.2811291 0.2818295 0.2825290 0.2832276 0.2839251 0.2846217 0.2853173 [78] 0.2860119 0.2867055 0.2873980 0.2880895 0.2887798 0.2894691 0.2901573 [85] 0.2908444 0.2915303 0.2922151 0.2928987 0.2935811 0.2942623 0.2949423 [92] 0.2956210 0.2962985 0.2969747 0.2976497 0.2983233 0.2989957 0.2996667 [99] 0.3003364 0.3010047 0.3016717 0.3023372 0.3030014 0.3036642 0.3043255 [106] 0.3049854 0.3056438 0.3063008 0.3069563 0.3076102 0.3082627 0.3089137 [113] 0.3095631 0.3102109 0.3108572 0.3115020 0.3121451 0.3127867 0.3134266 [120] 0.3140649 0.3147015 0.3153365 0.3159699 0.3166016 0.3172315 0.3178598 [127] 0.3184864 0.3191113 0.3197344 0.3203558 0.3209754 0.3215933 0.3222093 [134] 0.3228237 0.3234362 0.3240469 0.3246557 0.3252628 0.3258680 0.3264714 [141] 0.3270729 0.3276725 0.3282703 0.3288662 0.3294602 0.3300523 0.3306424 [148] 0.3312307 0.3318170 0.3324014 0.3329839 0.3335644 0.3341429 0.3347195 [155] 0.3352941 0.3358667 0.3364373 0.3370059 0.3375726 0.3381372 0.3386997 [162] 0.3392603 0.3398188 0.3403753 0.3409298 0.3414822 0.3420325 0.3425808 [169] 0.3431270 0.3436712 0.3442132 0.3447532 0.3452911 0.3458269 0.3463606 [176] 0.3468922 0.3474217 0.3479490 0.3484743 0.3489974 0.3495185 0.3500374 [183] 0.3505541 0.3510687 0.3515812 0.3520916 0.3525998 0.3531058 0.3536097 [190] 0.3541115 0.3546111 0.3551085 0.3556038 0.3560969 0.3565879 0.3570766 [197] 0.3575633 0.3580477 0.3585300 0.3590101 0.3594880 0.3599638 0.3604374 [204] 0.3609088 0.3613780 0.3618450 0.3623099 0.3627726 0.3632331 0.3636914 [211] 0.3641475 0.3646015 0.3650533 0.3655029 0.3659503 0.3663956 0.3668386 [218] 0.3672795 0.3677182 0.3681548 0.3685891 0.3690213 0.3694513 0.3698792 [225] 0.3703048 0.3707283 0.3711497 0.3715688 0.3719858 0.3724007 0.3728134 [232] 0.3732239 0.3736323 0.3740385 0.3744426 0.3748445 0.3752443 0.3756419 [239] 0.3760374 0.3764308 0.3768220 0.3772111 0.3775980 0.3779829 0.3783656 [246] 0.3787462 0.3791247 0.3795011 0.3798753 0.3802475 0.3806175 0.3809855 [253] 0.3813514 0.3817152 0.3820769 0.3824365 0.3827940 0.3831495 0.3835029 [260] 0.3838542 0.3842035 0.3845507 0.3848959 0.3852390 0.3855801 0.3859191 [267] 0.3862562 0.3865911 0.3869241 0.3872551 0.3875840 0.3879109 0.3882359 [274] 0.3885588 0.3888797 0.3891987 0.3895157 0.3898307 0.3901437 0.3904547 [281] 0.3907639 0.3910710 0.3913762 0.3916795 0.3919808 0.3922802 0.3925776 [288] 0.3928732 0.3931668 0.3934585 0.3937484 0.3940363 0.3943223 0.3946065 [295] 0.3948887 0.3951691 0.3954476 0.3957243 0.3959991 0.3962721 0.3965432 [302] 0.3968125 0.3970800 0.3973456 0.3976094 0.3978714 0.3981316 0.3983900 [309] 0.3986467 0.3989015 0.3991545 0.3994058 0.3996553 0.3999031 0.4001491 [316] 0.4003933 0.4006358 0.4008766 0.4011157 0.4013530 0.4015886 0.4018225 [323] 0.4020547 0.4022852 0.4025140 0.4027412 0.4029666 0.4031904 0.4034126 [330] 0.4036331 0.4038519 0.4040691 0.4042846 0.4044986 0.4047109 0.4049215 [337] 0.4051306 0.4053381 0.4055440 0.4057483 0.4059510 0.4061521 0.4063517 [344] 0.4065497 0.4067461 0.4069410 0.4071344 0.4073262 0.4075165 0.4077052 [351] 0.4078925 0.4080782 0.4082625 0.4084452 0.4086265 0.4088062 0.4089845 [358] 0.4091613 0.4093367 0.4095106 0.4096830 0.4098540 0.4100236 0.4101917 [365] 0.4103584 0.4105237 0.4106876 0.4108501 0.4110112 0.4111708 0.4113291 [372] 0.4114861 0.4116416 0.4117958 0.4119486 0.4121001 0.4122502 0.4123989 [379] 0.4125464 0.4126925 0.4128373 0.4129807 0.4131229 0.4132638 0.4134033 [386] 0.4135416 0.4136786 0.4138143 0.4139487 0.4140818 0.4142137 0.4143444 [393] 0.4144738 0.4146019 0.4147288 0.4148545 0.4149790 0.4151022 0.4152243 [400] 0.4153451 0.4154647 > mx [1] 0.4154647 > 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/16lrs1226399049.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/2orxf1226399049.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/3lkkt1226399049.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/4nfpv1226399049.tab") > > system("convert tmp/16lrs1226399049.ps tmp/16lrs1226399049.png") > system("convert tmp/2orxf1226399049.ps tmp/2orxf1226399049.png") > system("convert tmp/3lkkt1226399049.ps tmp/3lkkt1226399049.png") > > > proc.time() user system elapsed 1.021 0.503 1.187