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(476049,474605,470439,461251,454724,455626,516847,525192,522975,518585,509239,512238,519164,517009,509933,509127,500857,506971,569323,579714,577992,565464,547344,554788,562325,560854,555332,543599,536662,542722,593530,610763,612613,611324,594167,595454,590865,589379,584428,573100,567456,569028,620735,628884,628232,612117,595404,597141,593408,590072,579799,574205,572775,572942,619567,625809,619916,587625,565742,557274) > #'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.3319419 0.3320249 0.3321460 0.3322012 0.3323282 0.3324181 0.3324970 [8] 0.3326131 0.3326950 0.3327854 0.3328886 0.3329847 0.3330778 0.3331777 [15] 0.3332684 0.3333672 0.3334629 0.3335585 0.3336552 0.3337507 0.3338457 [22] 0.3339414 0.3340366 0.3341314 0.3342283 0.3343239 0.3344195 0.3345150 [29] 0.3346106 0.3347070 0.3348024 0.3348981 0.3349935 0.3350894 0.3351848 [36] 0.3352805 0.3353763 0.3354722 0.3355675 0.3356631 0.3357589 0.3358545 [43] 0.3359501 0.3360457 0.3361414 0.3362369 0.3363326 0.3364282 0.3365238 [50] 0.3366194 0.3367150 0.3368106 0.3369062 0.3370018 0.3370974 0.3371930 [57] 0.3372885 0.3373841 0.3374797 0.3375753 0.3376708 0.3377664 0.3378619 [64] 0.3379575 0.3380530 0.3381486 0.3382441 0.3383397 0.3384352 0.3385307 [71] 0.3386262 0.3387218 0.3388173 0.3389128 0.3390083 0.3391038 0.3391993 [78] 0.3392947 0.3393902 0.3394857 0.3395812 0.3396766 0.3397721 0.3398675 [85] 0.3399630 0.3400584 0.3401538 0.3402493 0.3403447 0.3404401 0.3405355 [92] 0.3406309 0.3407263 0.3408217 0.3409171 0.3410124 0.3411078 0.3412032 [99] 0.3412985 0.3413939 0.3414892 0.3415845 0.3416798 0.3417752 0.3418705 [106] 0.3419658 0.3420611 0.3421564 0.3422516 0.3423469 0.3424422 0.3425374 [113] 0.3426327 0.3427279 0.3428231 0.3429183 0.3430136 0.3431088 0.3432040 [120] 0.3432991 0.3433943 0.3434895 0.3435847 0.3436798 0.3437750 0.3438701 [127] 0.3439652 0.3440603 0.3441554 0.3442505 0.3443456 0.3444407 0.3445358 [134] 0.3446308 0.3447259 0.3448209 0.3449159 0.3450110 0.3451060 0.3452010 [141] 0.3452959 0.3453909 0.3454859 0.3455809 0.3456758 0.3457707 0.3458657 [148] 0.3459606 0.3460555 0.3461504 0.3462453 0.3463401 0.3464350 0.3465298 [155] 0.3466247 0.3467195 0.3468143 0.3469091 0.3470039 0.3470987 0.3471935 [162] 0.3472882 0.3473830 0.3474777 0.3475724 0.3476671 0.3477618 0.3478565 [169] 0.3479512 0.3480458 0.3481405 0.3482351 0.3483297 0.3484243 0.3485189 [176] 0.3486135 0.3487081 0.3488026 0.3488972 0.3489917 0.3490862 0.3491807 [183] 0.3492752 0.3493697 0.3494642 0.3495586 0.3496531 0.3497475 0.3498419 [190] 0.3499363 0.3500307 0.3501251 0.3502194 0.3503138 0.3504081 0.3505024 [197] 0.3505967 0.3506910 0.3507852 0.3508795 0.3509737 0.3510680 0.3511622 [204] 0.3512564 0.3513505 0.3514447 0.3515389 0.3516330 0.3517271 0.3518212 [211] 0.3519153 0.3520094 0.3521034 0.3521975 0.3522915 0.3523855 0.3524795 [218] 0.3525735 0.3526675 0.3527614 0.3528554 0.3529493 0.3530432 0.3531371 [225] 0.3532309 0.3533248 0.3534186 0.3535124 0.3536062 0.3537000 0.3537938 [232] 0.3538875 0.3539813 0.3540750 0.3541687 0.3542624 0.3543560 0.3544497 [239] 0.3545433 0.3546369 0.3547305 0.3548241 0.3549177 0.3550112 0.3551047 [246] 0.3551983 0.3552917 0.3553852 0.3554787 0.3555721 0.3556655 0.3557589 [253] 0.3558523 0.3559457 0.3560390 0.3561324 0.3562257 0.3563190 0.3564122 [260] 0.3565055 0.3565987 0.3566919 0.3567851 0.3568783 0.3569715 0.3570646 [267] 0.3571577 0.3572508 0.3573439 0.3574370 0.3575300 0.3576231 0.3577161 [274] 0.3578090 0.3579020 0.3579950 0.3580879 0.3581808 0.3582737 0.3583665 [281] 0.3584594 0.3585522 0.3586450 0.3587378 0.3588306 0.3589233 0.3590160 [288] 0.3591087 0.3592014 0.3592941 0.3593867 0.3594793 0.3595719 0.3596645 [295] 0.3597571 0.3598496 0.3599421 0.3600346 0.3601271 0.3602196 0.3603120 [302] 0.3604044 0.3604968 0.3605892 0.3606815 0.3607738 0.3608661 0.3609584 [309] 0.3610507 0.3611429 0.3612351 0.3613273 0.3614195 0.3615116 0.3616037 [316] 0.3616958 0.3617879 0.3618800 0.3619720 0.3620640 0.3621560 0.3622480 [323] 0.3623399 0.3624319 0.3625238 0.3626156 0.3627075 0.3627993 0.3628911 [330] 0.3629829 0.3630747 0.3631664 0.3632581 0.3633498 0.3634415 0.3635331 [337] 0.3636247 0.3637163 0.3638079 0.3638995 0.3639910 0.3640825 0.3641740 [344] 0.3642654 0.3643568 0.3644483 0.3645396 0.3646310 0.3647223 0.3648136 [351] 0.3649049 0.3649962 0.3650874 0.3651786 0.3652698 0.3653610 0.3654521 [358] 0.3655432 0.3656343 0.3657254 0.3658164 0.3659074 0.3659984 0.3660893 [365] 0.3661803 0.3662712 0.3663621 0.3664529 0.3665438 0.3666346 0.3667254 [372] 0.3668161 0.3669068 0.3669976 0.3670882 0.3671789 0.3672695 0.3673601 [379] 0.3674507 0.3675412 0.3676318 0.3677223 0.3678127 0.3679032 0.3679936 [386] 0.3680840 0.3681744 0.3682647 0.3683550 0.3684453 0.3685355 0.3686258 [393] 0.3687160 0.3688062 0.3688963 0.3689864 0.3690765 0.3691666 0.3692566 [400] 0.3693467 0.3694367 > mx [1] 0.3694367 > 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/1ap6g1258123387.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/2rdmy1258123387.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/3yfwu1258123387.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/4abyl1258123387.tab") > > system("convert tmp/1ap6g1258123387.ps tmp/1ap6g1258123387.png") > system("convert tmp/2rdmy1258123387.ps tmp/2rdmy1258123387.png") > system("convert tmp/3yfwu1258123387.ps tmp/3yfwu1258123387.png") > > > proc.time() user system elapsed 0.771 0.483 0.996