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(373,371,354,357,363,364,363,358,357,357,380,378,376,380,379,384,392,394,392,396,392,396,419,421,420,418,410,418,426,428,430,424,423,427,441,449,452,462,455,461,461,463,462,456,455,456,472,472,471,465,459,465,468,467,463,460,462,461,476,476,471,453,443,442,444,438,427,424,416,406,431,434,418) > x <- c(140,132,117,114,113,110,107,103,98,98,137,148,147,139,130,128,127,123,118,114,108,111,151,159,158,148,138,137,136,133,126,120,114,116,153,162,161,149,139,135,130,127,122,117,112,113,149,157,157,147,137,132,125,123,117,114,111,112,144,150,149,134,123,116,117,111,105,102,95,93,124,130,124) > #'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.3553348 0.3553132 0.3552915 0.3552696 0.3552475 0.3552253 0.3552028 [8] 0.3551801 0.3551572 0.3551341 0.3551108 0.3550874 0.3550637 0.3550398 [15] 0.3550158 0.3549915 0.3549671 0.3549424 0.3549176 0.3548925 0.3548673 [22] 0.3548419 0.3548163 0.3547905 0.3547645 0.3547383 0.3547119 0.3546854 [29] 0.3546586 0.3546317 0.3546045 0.3545772 0.3545497 0.3545219 0.3544940 [36] 0.3544660 0.3544377 0.3544092 0.3543806 0.3543517 0.3543227 0.3542935 [43] 0.3542641 0.3542345 0.3542047 0.3541747 0.3541446 0.3541142 0.3540837 [50] 0.3540530 0.3540221 0.3539911 0.3539598 0.3539284 0.3538967 0.3538649 [57] 0.3538329 0.3538008 0.3537684 0.3537359 0.3537032 0.3536703 0.3536372 [64] 0.3536039 0.3535705 0.3535369 0.3535031 0.3534691 0.3534350 0.3534006 [71] 0.3533661 0.3533315 0.3532966 0.3532616 0.3532263 0.3531909 0.3531554 [78] 0.3531196 0.3530837 0.3530476 0.3530114 0.3529749 0.3529383 0.3529015 [85] 0.3528645 0.3528274 0.3527901 0.3527526 0.3527150 0.3526772 0.3526392 [92] 0.3526010 0.3525627 0.3525242 0.3524855 0.3524467 0.3524076 0.3523685 [99] 0.3523291 0.3522896 0.3522499 0.3522101 0.3521701 0.3521299 0.3520895 [106] 0.3520490 0.3520083 0.3519675 0.3519265 0.3518853 0.3518440 0.3518025 [113] 0.3517608 0.3517190 0.3516770 0.3516349 0.3515926 0.3515501 0.3515075 [120] 0.3514647 0.3514217 0.3513786 0.3513354 0.3512919 0.3512483 0.3512046 [127] 0.3511607 0.3511166 0.3510724 0.3510281 0.3509835 0.3509388 0.3508940 [134] 0.3508490 0.3508039 0.3507586 0.3507131 0.3506675 0.3506217 0.3505758 [141] 0.3505298 0.3504835 0.3504372 0.3503906 0.3503440 0.3502972 0.3502502 [148] 0.3502031 0.3501558 0.3501084 0.3500608 0.3500131 0.3499652 0.3499172 [155] 0.3498691 0.3498208 0.3497723 0.3497237 0.3496750 0.3496261 0.3495771 [162] 0.3495279 0.3494786 0.3494291 0.3493795 0.3493298 0.3492799 0.3492299 [169] 0.3491797 0.3491294 0.3490790 0.3490284 0.3489777 0.3489268 0.3488758 [176] 0.3488246 0.3487734 0.3487219 0.3486704 0.3486187 0.3485669 0.3485149 [183] 0.3484628 0.3484106 0.3483582 0.3483057 0.3482531 0.3482003 0.3481474 [190] 0.3480944 0.3480412 0.3479879 0.3479345 0.3478809 0.3478272 0.3477734 [197] 0.3477195 0.3476654 0.3476112 0.3475568 0.3475024 0.3474478 0.3473931 [204] 0.3473382 0.3472833 0.3472282 0.3471729 0.3471176 0.3470621 0.3470065 [211] 0.3469508 0.3468950 0.3468390 0.3467829 0.3467267 0.3466704 0.3466139 [218] 0.3465573 0.3465006 0.3464438 0.3463869 0.3463298 0.3462727 0.3462154 [225] 0.3461579 0.3461004 0.3460428 0.3459850 0.3459271 0.3458691 0.3458110 [232] 0.3457528 0.3456945 0.3456360 0.3455774 0.3455188 0.3454600 0.3454011 [239] 0.3453420 0.3452829 0.3452237 0.3451643 0.3451049 0.3450453 0.3449856 [246] 0.3449258 0.3448659 0.3448059 0.3447458 0.3446856 0.3446252 0.3445648 [253] 0.3445042 0.3444436 0.3443828 0.3443220 0.3442610 0.3441999 0.3441387 [260] 0.3440775 0.3440161 0.3439546 0.3438930 0.3438313 0.3437695 0.3437076 [267] 0.3436456 0.3435836 0.3435214 0.3434591 0.3433967 0.3433342 0.3432716 [274] 0.3432089 0.3431461 0.3430832 0.3430203 0.3429572 0.3428940 0.3428308 [281] 0.3427674 0.3427040 0.3426404 0.3425768 0.3425130 0.3424492 0.3423853 [288] 0.3423213 0.3422572 0.3421930 0.3421287 0.3420643 0.3419998 0.3419353 [295] 0.3418706 0.3418059 0.3417411 0.3416762 0.3416112 0.3415461 0.3414809 [302] 0.3414157 0.3413503 0.3412849 0.3412194 0.3411538 0.3410881 0.3410223 [309] 0.3409565 0.3408905 0.3408245 0.3407584 0.3406922 0.3406260 0.3405596 [316] 0.3404932 0.3404267 0.3403601 0.3402934 0.3402267 0.3401599 0.3400930 [323] 0.3400260 0.3399589 0.3398918 0.3398246 0.3397573 0.3396899 0.3396225 [330] 0.3395550 0.3394874 0.3394197 0.3393520 0.3392842 0.3392163 0.3391483 [337] 0.3390803 0.3390122 0.3389440 0.3388757 0.3388074 0.3387390 0.3386706 [344] 0.3386020 0.3385334 0.3384648 0.3383960 0.3383272 0.3382583 0.3381894 [351] 0.3381204 0.3380513 0.3379822 0.3379130 0.3378437 0.3377744 0.3377049 [358] 0.3376355 0.3375659 0.3374963 0.3374267 0.3373570 0.3372872 0.3372173 [365] 0.3371474 0.3370774 0.3370074 0.3369373 0.3368671 0.3367969 0.3367266 [372] 0.3366563 0.3365859 0.3365155 0.3364450 0.3363744 0.3363038 0.3362331 [379] 0.3361623 0.3360915 0.3360207 0.3359498 0.3358788 0.3358078 0.3357367 [386] 0.3356656 0.3355944 0.3355231 0.3354519 0.3353805 0.3353091 0.3352377 [393] 0.3351662 0.3350946 0.3350230 0.3349513 0.3348796 0.3348079 0.3347361 [400] 0.3346642 0.3345923 > mx [1] 0.3553348 > 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/17fla1194180682.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/21pty1194180682.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/3pr551194180682.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/4vjsd1194180683.tab") > > system("convert tmp/17fla1194180682.ps tmp/17fla1194180682.png") > system("convert tmp/21pty1194180682.ps tmp/21pty1194180682.png") > system("convert tmp/3pr551194180682.ps tmp/3pr551194180682.png") > > > proc.time() user system elapsed 1.984 0.853 2.100