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(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) > x <- c(24,23,24,24,27,28,25,19,19,19,20,16,22,21,25,29,28,25,26,24,28,28,28,28,32,31,22,29,31,29,32,32,31,29,28,28,29,22,26,24,27,27,23,21,19,17,19,21,13,8,5,10,6,6,8,11,12,13,19,19) > #'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.2899771 0.2904837 0.2909917 0.2915010 0.2920116 0.2925236 0.2930369 [8] 0.2935515 0.2940674 0.2945846 0.2951030 0.2956227 0.2961436 0.2966657 [15] 0.2971890 0.2977135 0.2982392 0.2987661 0.2992940 0.2998231 0.3003533 [22] 0.3008846 0.3014170 0.3019505 0.3024849 0.3030204 0.3035569 0.3040944 [29] 0.3046329 0.3051723 0.3057126 0.3062539 0.3067961 0.3073391 0.3078830 [36] 0.3084277 0.3089732 0.3095196 0.3100667 0.3106145 0.3111631 0.3117124 [43] 0.3122624 0.3128131 0.3133644 0.3139163 0.3144689 0.3150220 0.3155756 [50] 0.3161298 0.3166845 0.3172397 0.3177954 0.3183515 0.3189080 0.3194649 [57] 0.3200222 0.3205798 0.3211377 0.3216959 0.3222544 0.3228131 0.3233720 [64] 0.3239311 0.3244904 0.3250498 0.3256093 0.3261689 0.3267286 0.3272883 [71] 0.3278479 0.3284076 0.3289672 0.3295267 0.3300861 0.3306453 0.3312044 [78] 0.3317633 0.3323220 0.3328804 0.3334386 0.3339964 0.3345539 0.3351110 [85] 0.3356677 0.3362240 0.3367799 0.3373352 0.3378901 0.3384443 0.3389981 [92] 0.3395512 0.3401036 0.3406554 0.3412065 0.3417569 0.3423066 0.3428554 [99] 0.3434034 0.3439506 0.3444969 0.3450423 0.3455867 0.3461302 0.3466726 [106] 0.3472141 0.3477545 0.3482937 0.3488319 0.3493689 0.3499047 0.3504393 [113] 0.3509727 0.3515048 0.3520355 0.3525650 0.3530930 0.3536197 0.3541449 [120] 0.3546687 0.3551910 0.3557118 0.3562310 0.3567486 0.3572646 0.3577790 [127] 0.3582917 0.3588027 0.3593120 0.3598195 0.3603253 0.3608292 0.3613312 [134] 0.3618314 0.3623297 0.3628261 0.3633205 0.3638129 0.3643033 0.3647916 [141] 0.3652779 0.3657621 0.3662441 0.3667240 0.3672017 0.3676772 0.3681504 [148] 0.3686214 0.3690902 0.3695565 0.3700206 0.3704823 0.3709416 0.3713985 [155] 0.3718529 0.3723049 0.3727543 0.3732013 0.3736457 0.3740876 0.3745269 [162] 0.3749636 0.3753976 0.3758290 0.3762577 0.3766838 0.3771071 0.3775277 [169] 0.3779455 0.3783605 0.3787727 0.3791821 0.3795887 0.3799924 0.3803932 [176] 0.3807912 0.3811862 0.3815783 0.3819674 0.3823536 0.3827367 0.3831169 [183] 0.3834941 0.3838682 0.3842393 0.3846073 0.3849722 0.3853340 0.3856927 [190] 0.3860483 0.3864008 0.3867501 0.3870962 0.3874392 0.3877790 0.3881155 [197] 0.3884489 0.3887790 0.3891060 0.3894296 0.3897500 0.3900672 0.3903811 [204] 0.3906917 0.3909990 0.3913030 0.3916037 0.3919011 0.3921952 0.3924859 [211] 0.3927733 0.3930574 0.3933381 0.3936155 0.3938895 0.3941602 0.3944275 [218] 0.3946914 0.3949520 0.3952092 0.3954630 0.3957134 0.3959605 0.3962042 [225] 0.3964445 0.3966814 0.3969149 0.3971450 0.3973718 0.3975951 0.3978151 [232] 0.3980317 0.3982449 0.3984547 0.3986612 0.3988642 0.3990639 0.3992603 [239] 0.3994532 0.3996428 0.3998291 0.4000119 0.4001915 0.4003676 0.4005405 [246] 0.4007100 0.4008761 0.4010390 0.4011985 0.4013547 0.4015076 0.4016572 [253] 0.4018035 0.4019465 0.4020863 0.4022227 0.4023560 0.4024859 0.4026127 [260] 0.4027361 0.4028564 0.4029735 0.4030873 0.4031980 0.4033054 0.4034097 [267] 0.4035108 0.4036088 0.4037036 0.4037953 0.4038839 0.4039694 0.4040518 [274] 0.4041311 0.4042073 0.4042804 0.4043506 0.4044176 0.4044817 0.4045428 [281] 0.4046008 0.4046559 0.4047080 0.4047572 0.4048034 0.4048467 0.4048871 [288] 0.4049246 0.4049592 0.4049909 0.4050198 0.4050458 0.4050691 0.4050895 [295] 0.4051071 0.4051220 0.4051340 0.4051434 0.4051500 0.4051539 0.4051551 [302] 0.4051536 0.4051495 0.4051427 0.4051332 0.4051212 0.4051065 0.4050893 [309] 0.4050695 0.4050471 0.4050222 0.4049948 0.4049649 0.4049325 0.4048976 [316] 0.4048603 0.4048205 0.4047784 0.4047338 0.4046868 0.4046375 0.4045858 [323] 0.4045318 0.4044755 0.4044169 0.4043560 0.4042928 0.4042274 0.4041598 [330] 0.4040899 0.4040179 0.4039437 0.4038673 0.4037888 0.4037081 0.4036254 [337] 0.4035405 0.4034536 0.4033646 0.4032736 0.4031806 0.4030856 0.4029885 [344] 0.4028895 0.4027886 0.4026857 0.4025809 0.4024742 0.4023656 0.4022551 [351] 0.4021428 0.4020287 0.4019127 0.4017949 0.4016754 0.4015540 0.4014310 [358] 0.4013062 0.4011797 0.4010514 0.4009215 0.4007900 0.4006567 0.4005219 [365] 0.4003854 0.4002473 0.4001076 0.3999664 0.3998236 0.3996793 0.3995334 [372] 0.3993861 0.3992372 0.3990869 0.3989351 0.3987819 0.3986272 0.3984711 [379] 0.3983137 0.3981548 0.3979946 0.3978330 0.3976701 0.3975059 0.3973404 [386] 0.3971735 0.3970054 0.3968360 0.3966654 0.3964936 0.3963205 0.3961462 [393] 0.3959708 0.3957941 0.3956163 0.3954374 0.3952573 0.3950761 0.3948938 [400] 0.3947104 0.3945259 > mx [1] 0.4051551 > mxli [1] 1 > 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/186ga1258053579.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/2n41w1258053579.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/3l5a31258053579.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/4cymv1258053580.tab") > > system("convert tmp/186ga1258053579.ps tmp/186ga1258053579.png") > system("convert tmp/2n41w1258053579.ps tmp/2n41w1258053579.png") > system("convert tmp/3l5a31258053579.ps tmp/3l5a31258053579.png") > > > proc.time() user system elapsed 0.790 0.516 0.939