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(3922,3759,4138,4634,3996,4308,4143,4429,5219,4929,5755,5592,4163,4962,5208,4755,4491,5732,5731,5040,6102,4904,5369,5578,4619,4731,5011,5299,4146,4625,4736,4219,5116,4205,4121,5103,4300,4578,3809,5526,4247,3830,4394,4826,4409,4569,4106,4794,3914,3793,4405,4022,4100,4788,3163,3585,3903,4178,3863,4187) > x <- c(10.9,10,9.2,9.2,9.5,9.6,9.5,9.1,8.9,9,10.1,10.3,10.2,9.6,9.2,9.3,9.4,9.4,9.2,9,9,9,9.8,10,9.8,9.3,9,9,9.1,9.1,9.1,9.2,8.8,8.3,8.4,8.1,7.7,7.9,7.9,8,7.9,7.6,7.1,6.8,6.5,6.9,8.2,8.7,8.3,7.9,7.5,7.8,8.3,8.4,8.2,7.7,7.2,7.3,8.1,8.5) > #'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.3165803 0.3166729 0.3167652 0.3168572 0.3169488 0.3170402 0.3171311 [8] 0.3172218 0.3173121 0.3174021 0.3174917 0.3175810 0.3176700 0.3177587 [15] 0.3178470 0.3179350 0.3180226 0.3181100 0.3181969 0.3182836 0.3183699 [22] 0.3184559 0.3185415 0.3186268 0.3187118 0.3187964 0.3188807 0.3189646 [29] 0.3190482 0.3191315 0.3192144 0.3192970 0.3193793 0.3194612 0.3195427 [36] 0.3196240 0.3197049 0.3197854 0.3198656 0.3199455 0.3200250 0.3201041 [43] 0.3201830 0.3202615 0.3203396 0.3204174 0.3204949 0.3205720 0.3206487 [50] 0.3207251 0.3208012 0.3208769 0.3209523 0.3210273 0.3211020 0.3211763 [57] 0.3212503 0.3213240 0.3213973 0.3214702 0.3215428 0.3216150 0.3216869 [64] 0.3217585 0.3218296 0.3219005 0.3219710 0.3220411 0.3221109 0.3221803 [71] 0.3222494 0.3223181 0.3223865 0.3224545 0.3225222 0.3225895 0.3226565 [78] 0.3227231 0.3227893 0.3228552 0.3229208 0.3229860 0.3230508 0.3231153 [85] 0.3231794 0.3232431 0.3233066 0.3233696 0.3234323 0.3234946 0.3235566 [92] 0.3236182 0.3236795 0.3237404 0.3238009 0.3238611 0.3239209 0.3239804 [99] 0.3240395 0.3240982 0.3241566 0.3242147 0.3242723 0.3243296 0.3243866 [106] 0.3244431 0.3244994 0.3245552 0.3246107 0.3246658 0.3247206 0.3247750 [113] 0.3248291 0.3248827 0.3249361 0.3249890 0.3250416 0.3250938 0.3251457 [120] 0.3251972 0.3252483 0.3252991 0.3253495 0.3253995 0.3254492 0.3254985 [127] 0.3255474 0.3255960 0.3256442 0.3256921 0.3257395 0.3257866 0.3258334 [134] 0.3258797 0.3259257 0.3259714 0.3260166 0.3260615 0.3261061 0.3261502 [141] 0.3261940 0.3262375 0.3262805 0.3263232 0.3263655 0.3264075 0.3264490 [148] 0.3264902 0.3265311 0.3265716 0.3266116 0.3266514 0.3266907 0.3267297 [155] 0.3267683 0.3268066 0.3268444 0.3268819 0.3269191 0.3269558 0.3269922 [162] 0.3270282 0.3270639 0.3270991 0.3271340 0.3271685 0.3272027 0.3272365 [169] 0.3272699 0.3273029 0.3273356 0.3273678 0.3273998 0.3274313 0.3274624 [176] 0.3274932 0.3275236 0.3275537 0.3275834 0.3276126 0.3276416 0.3276701 [183] 0.3276983 0.3277261 0.3277535 0.3277805 0.3278072 0.3278335 0.3278594 [190] 0.3278849 0.3279101 0.3279349 0.3279593 0.3279833 0.3280070 0.3280303 [197] 0.3280532 0.3280757 0.3280979 0.3281196 0.3281410 0.3281621 0.3281827 [204] 0.3282030 0.3282229 0.3282424 0.3282615 0.3282803 0.3282987 0.3283167 [211] 0.3283343 0.3283516 0.3283685 0.3283850 0.3284011 0.3284168 0.3284322 [218] 0.3284472 0.3284618 0.3284760 0.3284899 0.3285034 0.3285165 0.3285292 [225] 0.3285415 0.3285535 0.3285651 0.3285763 0.3285871 0.3285976 0.3286076 [232] 0.3286173 0.3286266 0.3286356 0.3286441 0.3286523 0.3286601 0.3286675 [239] 0.3286746 0.3286812 0.3286875 0.3286934 0.3286990 0.3287041 0.3287089 [246] 0.3287133 0.3287173 0.3287209 0.3287242 0.3287271 0.3287296 0.3287317 [253] 0.3287334 0.3287348 0.3287358 0.3287364 0.3287366 0.3287364 0.3287359 [260] 0.3287350 0.3287337 0.3287320 0.3287300 0.3287276 0.3287248 0.3287216 [267] 0.3287180 0.3287141 0.3287098 0.3287051 0.3287000 0.3286945 0.3286887 [274] 0.3286825 0.3286759 0.3286689 0.3286616 0.3286538 0.3286457 0.3286372 [281] 0.3286284 0.3286191 0.3286095 0.3285995 0.3285892 0.3285784 0.3285673 [288] 0.3285558 0.3285439 0.3285316 0.3285190 0.3285059 0.3284926 0.3284788 [295] 0.3284646 0.3284501 0.3284352 0.3284199 0.3284042 0.3283882 0.3283718 [302] 0.3283550 0.3283378 0.3283203 0.3283023 0.3282840 0.3282654 0.3282463 [309] 0.3282269 0.3282071 0.3281869 0.3281663 0.3281454 0.3281241 0.3281024 [316] 0.3280803 0.3280579 0.3280350 0.3280118 0.3279883 0.3279643 0.3279400 [323] 0.3279153 0.3278902 0.3278648 0.3278390 0.3278128 0.3277862 0.3277593 [330] 0.3277320 0.3277043 0.3276762 0.3276477 0.3276189 0.3275897 0.3275602 [337] 0.3275302 0.3274999 0.3274692 0.3274382 0.3274067 0.3273749 0.3273428 [344] 0.3273102 0.3272773 0.3272440 0.3272103 0.3271763 0.3271419 0.3271071 [351] 0.3270719 0.3270364 0.3270005 0.3269642 0.3269276 0.3268906 0.3268532 [358] 0.3268154 0.3267773 0.3267388 0.3266999 0.3266607 0.3266211 0.3265811 [365] 0.3265408 0.3265001 0.3264590 0.3264175 0.3263757 0.3263335 0.3262909 [372] 0.3262480 0.3262047 0.3261610 0.3261170 0.3260726 0.3260278 0.3259827 [379] 0.3259372 0.3258913 0.3258451 0.3257985 0.3257515 0.3257041 0.3256564 [386] 0.3256084 0.3255599 0.3255111 0.3254619 0.3254124 0.3253625 0.3253122 [393] 0.3252616 0.3252106 0.3251593 0.3251075 0.3250555 0.3250030 0.3249502 [400] 0.3248970 0.3248435 > mx [1] 0.3287366 > mxli [1] 0.56 > 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/14uaz1257595554.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/2ko861257595554.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/3fq451257595554.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/4b5ta1257595554.tab") > > system("convert tmp/14uaz1257595554.ps tmp/14uaz1257595554.png") > system("convert tmp/2ko861257595554.ps tmp/2ko861257595554.png") > system("convert tmp/3fq451257595554.ps tmp/3fq451257595554.png") > > > proc.time() user system elapsed 0.771 0.473 1.071