R version 2.6.0 (2007-10-03) 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(106.7,100.6,101.2,93.1,84.2,85.8,91.8,92.4,80.3,79.7,62.5,57.1,100.8,100.7,86.2,83.2,71.7,77.5,89.8,80.3,78.7,93.8,57.6,60.6,91.0,85.3,77.4,77.3,68.3,69.9,81.7,75.1,69.9,84.0,54.3,60.0,89.9,77.0,85.3,77.6,69.2,75.5,85.7,72.2,79.9,85.3,52.2,61.2,82.4,85.4,78.2,70.2,70.2,69.3,77.5,66.1,69.0,75.3,58.2,59.7) > x <- c(108.4,117.0,103.8,100.8,110.6,104.0,112.6,107.3,98.9,109.8,104.9,102.2,123.9,124.9,112.7,121.9,100.6,104.3,120.4,107.5,102.9,125.6,107.5,108.8,128.4,121.1,119.5,128.7,108.7,105.5,119.8,111.3,110.6,120.1,97.5,107.7,127.3,117.2,119.8,116.2,111.0,112.4,130.6,109.1,118.8,123.9,101.6,112.8,128.0,129.6,125.8,119.5,115.7,113.6,129.7,112.0,116.8,126.3,112.9,115.9) > #'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.3586072 0.3586438 0.3586804 0.3587168 0.3587533 0.3587897 0.3588260 [8] 0.3588623 0.3588985 0.3589346 0.3589708 0.3590068 0.3590428 0.3590788 [15] 0.3591147 0.3591506 0.3591864 0.3592221 0.3592578 0.3592935 0.3593291 [22] 0.3593646 0.3594001 0.3594355 0.3594709 0.3595062 0.3595415 0.3595767 [29] 0.3596119 0.3596470 0.3596821 0.3597171 0.3597520 0.3597869 0.3598218 [36] 0.3598566 0.3598913 0.3599260 0.3599606 0.3599952 0.3600297 0.3600642 [43] 0.3600986 0.3601330 0.3601673 0.3602015 0.3602357 0.3602699 0.3603040 [50] 0.3603380 0.3603720 0.3604059 0.3604398 0.3604736 0.3605074 0.3605411 [57] 0.3605748 0.3606084 0.3606419 0.3606754 0.3607089 0.3607422 0.3607756 [64] 0.3608088 0.3608421 0.3608752 0.3609083 0.3609414 0.3609744 0.3610073 [71] 0.3610402 0.3610730 0.3611058 0.3611385 0.3611712 0.3612038 0.3612364 [78] 0.3612689 0.3613013 0.3613337 0.3613660 0.3613983 0.3614305 0.3614627 [85] 0.3614948 0.3615269 0.3615588 0.3615908 0.3616227 0.3616545 0.3616863 [92] 0.3617180 0.3617496 0.3617812 0.3618128 0.3618443 0.3618757 0.3619071 [99] 0.3619384 0.3619697 0.3620009 0.3620320 0.3620631 0.3620942 0.3621251 [106] 0.3621561 0.3621869 0.3622177 0.3622485 0.3622792 0.3623098 0.3623404 [113] 0.3623709 0.3624014 0.3624318 0.3624622 0.3624924 0.3625227 0.3625529 [120] 0.3625830 0.3626131 0.3626431 0.3626730 0.3627029 0.3627327 0.3627625 [127] 0.3627922 0.3628219 0.3628515 0.3628810 0.3629105 0.3629400 0.3629693 [134] 0.3629986 0.3630279 0.3630571 0.3630862 0.3631153 0.3631443 0.3631733 [141] 0.3632022 0.3632310 0.3632598 0.3632886 0.3633172 0.3633458 0.3633744 [148] 0.3634029 0.3634313 0.3634597 0.3634880 0.3635163 0.3635445 0.3635726 [155] 0.3636007 0.3636288 0.3636567 0.3636846 0.3637125 0.3637403 0.3637680 [162] 0.3637957 0.3638233 0.3638508 0.3638783 0.3639058 0.3639331 0.3639605 [169] 0.3639877 0.3640149 0.3640420 0.3640691 0.3640961 0.3641231 0.3641500 [176] 0.3641768 0.3642036 0.3642303 0.3642570 0.3642836 0.3643102 0.3643366 [183] 0.3643631 0.3643894 0.3644157 0.3644420 0.3644681 0.3644943 0.3645203 [190] 0.3645463 0.3645723 0.3645982 0.3646240 0.3646497 0.3646754 0.3647011 [197] 0.3647267 0.3647522 0.3647776 0.3648030 0.3648284 0.3648537 0.3648789 [204] 0.3649040 0.3649291 0.3649542 0.3649792 0.3650041 0.3650289 0.3650537 [211] 0.3650785 0.3651031 0.3651277 0.3651523 0.3651768 0.3652012 0.3652256 [218] 0.3652499 0.3652741 0.3652983 0.3653224 0.3653465 0.3653705 0.3653944 [225] 0.3654183 0.3654421 0.3654659 0.3654896 0.3655132 0.3655368 0.3655603 [232] 0.3655838 0.3656072 0.3656305 0.3656538 0.3656770 0.3657001 0.3657232 [239] 0.3657462 0.3657692 0.3657921 0.3658149 0.3658377 0.3658604 0.3658830 [246] 0.3659056 0.3659282 0.3659506 0.3659730 0.3659954 0.3660177 0.3660399 [253] 0.3660620 0.3660841 0.3661062 0.3661281 0.3661500 0.3661719 0.3661937 [260] 0.3662154 0.3662371 0.3662587 0.3662802 0.3663017 0.3663231 0.3663444 [267] 0.3663657 0.3663869 0.3664081 0.3664292 0.3664502 0.3664712 0.3664921 [274] 0.3665130 0.3665338 0.3665545 0.3665752 0.3665958 0.3666163 0.3666368 [281] 0.3666572 0.3666776 0.3666978 0.3667181 0.3667382 0.3667583 0.3667784 [288] 0.3667984 0.3668183 0.3668381 0.3668579 0.3668776 0.3668973 0.3669169 [295] 0.3669364 0.3669559 0.3669753 0.3669947 0.3670140 0.3670332 0.3670523 [302] 0.3670714 0.3670905 0.3671094 0.3671284 0.3671472 0.3671660 0.3671847 [309] 0.3672034 0.3672219 0.3672405 0.3672589 0.3672774 0.3672957 0.3673140 [316] 0.3673322 0.3673503 0.3673684 0.3673864 0.3674044 0.3674223 0.3674401 [323] 0.3674579 0.3674756 0.3674933 0.3675109 0.3675284 0.3675458 0.3675632 [330] 0.3675805 0.3675978 0.3676150 0.3676322 0.3676492 0.3676662 0.3676832 [337] 0.3677001 0.3677169 0.3677336 0.3677503 0.3677670 0.3677835 0.3678000 [344] 0.3678165 0.3678329 0.3678492 0.3678654 0.3678816 0.3678977 0.3679138 [351] 0.3679298 0.3679457 0.3679616 0.3679774 0.3679931 0.3680088 0.3680244 [358] 0.3680400 0.3680554 0.3680709 0.3680862 0.3681015 0.3681167 0.3681319 [365] 0.3681470 0.3681621 0.3681770 0.3681919 0.3682068 0.3682216 0.3682363 [372] 0.3682509 0.3682655 0.3682801 0.3682945 0.3683089 0.3683233 0.3683375 [379] 0.3683517 0.3683659 0.3683800 0.3683940 0.3684079 0.3684218 0.3684356 [386] 0.3684494 0.3684631 0.3684767 0.3684903 0.3685038 0.3685172 0.3685306 [393] 0.3685439 0.3685572 0.3685704 0.3685835 0.3685965 0.3686095 0.3686225 [400] 0.3686353 0.3686481 > mx [1] 0.3686481 > 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/1vdla1194255829.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/21vf01194255829.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/3xpfv1194255829.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/44fup1194255829.tab") > > system("convert tmp/1vdla1194255829.ps tmp/1vdla1194255829.png") > system("convert tmp/21vf01194255829.ps tmp/21vf01194255829.png") > system("convert tmp/3xpfv1194255829.ps tmp/3xpfv1194255829.png") > > > proc.time() user system elapsed 1.042 0.505 1.210