R version 2.6.1 (2007-11-26) Copyright (C) 2007 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(10236,10893,10756,10940,10997,10827,10166,10186,10457,10368,10244,10511,10812,10738,10171,9721,9897,9828,9924,10371,10846,10413,10709,10662,10570,10297,10635,10872,10296,10383,10431,10574,10653,10805,10872,10625,10407,10463,10556,10646,10702,11353,11346,11451,11964,12574,13031,13812,14544,14931,14886,16005,17064,15168,16050,15839,15137,14954,15648,15305) > x <- c(0.8833,0.87,0.8758,0.8858,0.917,0.9554,0.9922,0.9778,0.9808,0.9811,1.0014,1.0183,1.0622,1.0773,1.0807,1.0848,1.1582,1.1663,1.1372,1.1139,1.1222,1.1692,1.1702,1.2286,1.2613,1.2646,1.2262,1.1985,1.2007,1.2138,1.2266,1.2176,1.2218,1.249,1.2991,1.3408,1.3119,1.3014,1.3201,1.2938,1.2694,1.2165,1.2037,1.2292,1.2256,1.2015,1.1786,1.1856,1.2103,1.1938,1.202,1.2271,1.277,1.265,1.2684,1.2811,1.2727,1.2611,1.2881,1.3213) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2007), Box-Cox Linearity Plot (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxlin.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description > 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.3553526 0.3554763 0.3555999 0.3557234 0.3558467 0.3559700 0.3560931 [8] 0.3562160 0.3563389 0.3564616 0.3565843 0.3567068 0.3568291 0.3569514 [15] 0.3570735 0.3571955 0.3573174 0.3574392 0.3575608 0.3576823 0.3578037 [22] 0.3579250 0.3580461 0.3581671 0.3582880 0.3584087 0.3585294 0.3586499 [29] 0.3587702 0.3588905 0.3590106 0.3591306 0.3592505 0.3593702 0.3594898 [36] 0.3596093 0.3597286 0.3598478 0.3599669 0.3600859 0.3602047 0.3603234 [43] 0.3604419 0.3605604 0.3606786 0.3607968 0.3609148 0.3610327 0.3611505 [50] 0.3612681 0.3613856 0.3615030 0.3616202 0.3617373 0.3618542 0.3619710 [57] 0.3620877 0.3622042 0.3623206 0.3624369 0.3625530 0.3626690 0.3627849 [64] 0.3629006 0.3630162 0.3631316 0.3632469 0.3633621 0.3634771 0.3635919 [71] 0.3637067 0.3638213 0.3639357 0.3640500 0.3641642 0.3642782 0.3643921 [78] 0.3645059 0.3646195 0.3647329 0.3648462 0.3649594 0.3650724 0.3651853 [85] 0.3652980 0.3654106 0.3655231 0.3656354 0.3657475 0.3658595 0.3659714 [92] 0.3660831 0.3661947 0.3663061 0.3664174 0.3665285 0.3666394 0.3667503 [99] 0.3668609 0.3669715 0.3670819 0.3671921 0.3673022 0.3674121 0.3675219 [106] 0.3676315 0.3677410 0.3678503 0.3679595 0.3680685 0.3681773 0.3682860 [113] 0.3683946 0.3685030 0.3686113 0.3687194 0.3688273 0.3689351 0.3690427 [120] 0.3691502 0.3692576 0.3693647 0.3694717 0.3695786 0.3696853 0.3697919 [127] 0.3698982 0.3700045 0.3701106 0.3702165 0.3703222 0.3704278 0.3705333 [134] 0.3706386 0.3707437 0.3708487 0.3709535 0.3710581 0.3711626 0.3712669 [141] 0.3713711 0.3714751 0.3715789 0.3716826 0.3717861 0.3718895 0.3719927 [148] 0.3720957 0.3721986 0.3723013 0.3724039 0.3725063 0.3726085 0.3727105 [155] 0.3728124 0.3729142 0.3730157 0.3731171 0.3732183 0.3733194 0.3734203 [162] 0.3735211 0.3736216 0.3737220 0.3738223 0.3739223 0.3740222 0.3741220 [169] 0.3742215 0.3743209 0.3744202 0.3745192 0.3746181 0.3747169 0.3748154 [176] 0.3749138 0.3750120 0.3751101 0.3752080 0.3753057 0.3754032 0.3755006 [183] 0.3755978 0.3756948 0.3757916 0.3758883 0.3759848 0.3760812 0.3761773 [190] 0.3762733 0.3763692 0.3764648 0.3765603 0.3766556 0.3767507 0.3768457 [197] 0.3769404 0.3770350 0.3771295 0.3772237 0.3773178 0.3774117 0.3775054 [204] 0.3775990 0.3776924 0.3777856 0.3778786 0.3779715 0.3780641 0.3781566 [211] 0.3782489 0.3783411 0.3784330 0.3785248 0.3786164 0.3787079 0.3787991 [218] 0.3788902 0.3789811 0.3790718 0.3791623 0.3792527 0.3793429 0.3794329 [225] 0.3795227 0.3796123 0.3797018 0.3797910 0.3798801 0.3799691 0.3800578 [232] 0.3801463 0.3802347 0.3803229 0.3804109 0.3804987 0.3805864 0.3806738 [239] 0.3807611 0.3808482 0.3809351 0.3810218 0.3811084 0.3811947 0.3812809 [246] 0.3813669 0.3814527 0.3815383 0.3816237 0.3817090 0.3817941 0.3818789 [253] 0.3819636 0.3820481 0.3821325 0.3822166 0.3823006 0.3823843 0.3824679 [260] 0.3825513 0.3826345 0.3827175 0.3828004 0.3828830 0.3829655 0.3830477 [267] 0.3831298 0.3832117 0.3832934 0.3833749 0.3834563 0.3835374 0.3836184 [274] 0.3836991 0.3837797 0.3838601 0.3839403 0.3840203 0.3841001 0.3841797 [281] 0.3842591 0.3843384 0.3844174 0.3844963 0.3845750 0.3846535 0.3847318 [288] 0.3848099 0.3848878 0.3849655 0.3850430 0.3851203 0.3851975 0.3852744 [295] 0.3853512 0.3854278 0.3855041 0.3855803 0.3856563 0.3857321 0.3858077 [302] 0.3858831 0.3859583 0.3860333 0.3861082 0.3861828 0.3862572 0.3863315 [309] 0.3864055 0.3864794 0.3865531 0.3866265 0.3866998 0.3867729 0.3868458 [316] 0.3869185 0.3869910 0.3870632 0.3871354 0.3872073 0.3872790 0.3873505 [323] 0.3874218 0.3874929 0.3875639 0.3876346 0.3877051 0.3877755 0.3878456 [330] 0.3879156 0.3879853 0.3880549 0.3881242 0.3881934 0.3882623 0.3883311 [337] 0.3883997 0.3884680 0.3885362 0.3886042 0.3886719 0.3887395 0.3888069 [344] 0.3888741 0.3889410 0.3890078 0.3890744 0.3891408 0.3892070 0.3892730 [351] 0.3893388 0.3894043 0.3894697 0.3895349 0.3895999 0.3896647 0.3897293 [358] 0.3897937 0.3898579 0.3899219 0.3899857 0.3900493 0.3901127 0.3901758 [365] 0.3902388 0.3903016 0.3903642 0.3904266 0.3904888 0.3905508 0.3906126 [372] 0.3906742 0.3907355 0.3907967 0.3908577 0.3909185 0.3909791 0.3910395 [379] 0.3910996 0.3911596 0.3912194 0.3912790 0.3913383 0.3913975 0.3914565 [386] 0.3915152 0.3915738 0.3916322 0.3916903 0.3917483 0.3918060 0.3918636 [393] 0.3919209 0.3919781 0.3920350 0.3920918 0.3921483 0.3922047 0.3922608 [400] 0.3923167 0.3923724 > mx [1] 0.3923724 > 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/1ut5t1200348052.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/269qb1200348052.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/38e9r1200348052.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 > 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/4sppi1200348052.tab") > > system("convert tmp/1ut5t1200348052.ps tmp/1ut5t1200348052.png") > system("convert tmp/269qb1200348052.ps tmp/269qb1200348052.png") > system("convert tmp/38e9r1200348052.ps tmp/38e9r1200348052.png") > > > proc.time() user system elapsed 1.811 0.798 1.931