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(98.1,101.1,111.1,93.3,100,108,70.4,75.4,105.5,112.3,102.5,93.5,86.7,95.2,103.8,97,95.5,101,67.5,64,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,85.3,77.4,77.3,68.3,69.9,81.7,75.1,69.9,84,54.3,60,89.9,77,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,75.3,58.2,59.7) > x <- c(103.1,100.6,103.1,95.5,90.5,90.9,88.8,90.7,94.3,104.6,111.1,110.8,107.2,99,99,91,96.2,96.9,96.2,100.1,99,115.4,106.9,107.1,99.3,99.2,108.3,105.6,99.5,107.4,93.1,88.1,110.7,113.1,99.6,93.6,98.6,99.6,114.3,107.8,101.2,112.5,100.5,93.9,116.2,112,106.4,95.7,96,95.8,103,102.2,98.4,111.4,86.6,91.3,107.9,101.8,104.4,93.4,100.1,98.5,112.9,101.4,107.1,110.8,90.3,95.5,111.4,113,107.5,95.9,106.3,105.2,117.2,106.9,108.2,110,96.1,100.6) > #'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.3391712 0.3391571 0.3391430 0.3391289 0.3391147 0.3391005 0.3390862 [8] 0.3390719 0.3390576 0.3390433 0.3390289 0.3390144 0.3390000 0.3389855 [15] 0.3389710 0.3389564 0.3389418 0.3389272 0.3389125 0.3388979 0.3388831 [22] 0.3388684 0.3388536 0.3388387 0.3388239 0.3388090 0.3387941 0.3387791 [29] 0.3387641 0.3387491 0.3387340 0.3387189 0.3387038 0.3386886 0.3386734 [36] 0.3386582 0.3386429 0.3386276 0.3386123 0.3385969 0.3385815 0.3385660 [43] 0.3385506 0.3385351 0.3385195 0.3385040 0.3384883 0.3384727 0.3384570 [50] 0.3384413 0.3384256 0.3384098 0.3383940 0.3383782 0.3383623 0.3383464 [57] 0.3383304 0.3383144 0.3382984 0.3382824 0.3382663 0.3382502 0.3382340 [64] 0.3382179 0.3382016 0.3381854 0.3381691 0.3381528 0.3381364 0.3381201 [71] 0.3381036 0.3380872 0.3380707 0.3380542 0.3380376 0.3380210 0.3380044 [78] 0.3379878 0.3379711 0.3379544 0.3379376 0.3379208 0.3379040 0.3378871 [85] 0.3378703 0.3378533 0.3378364 0.3378194 0.3378024 0.3377853 0.3377682 [92] 0.3377511 0.3377339 0.3377167 0.3376995 0.3376822 0.3376649 0.3376476 [99] 0.3376302 0.3376128 0.3375954 0.3375780 0.3375605 0.3375429 0.3375254 [106] 0.3375078 0.3374901 0.3374725 0.3374548 0.3374370 0.3374193 0.3374015 [113] 0.3373836 0.3373658 0.3373479 0.3373299 0.3373120 0.3372940 0.3372759 [120] 0.3372579 0.3372398 0.3372216 0.3372035 0.3371853 0.3371670 0.3371488 [127] 0.3371305 0.3371121 0.3370937 0.3370753 0.3370569 0.3370384 0.3370199 [134] 0.3370014 0.3369828 0.3369642 0.3369456 0.3369269 0.3369082 0.3368895 [141] 0.3368707 0.3368519 0.3368330 0.3368142 0.3367953 0.3367763 0.3367574 [148] 0.3367383 0.3367193 0.3367002 0.3366811 0.3366620 0.3366428 0.3366236 [155] 0.3366044 0.3365851 0.3365658 0.3365464 0.3365271 0.3365077 0.3364882 [162] 0.3364688 0.3364492 0.3364297 0.3364101 0.3363905 0.3363709 0.3363512 [169] 0.3363315 0.3363118 0.3362920 0.3362722 0.3362524 0.3362325 0.3362126 [176] 0.3361926 0.3361727 0.3361527 0.3361326 0.3361126 0.3360924 0.3360723 [183] 0.3360521 0.3360319 0.3360117 0.3359914 0.3359711 0.3359508 0.3359304 [190] 0.3359100 0.3358896 0.3358691 0.3358486 0.3358281 0.3358075 0.3357869 [197] 0.3357663 0.3357456 0.3357249 0.3357042 0.3356834 0.3356626 0.3356418 [204] 0.3356209 0.3356000 0.3355791 0.3355581 0.3355371 0.3355161 0.3354950 [211] 0.3354739 0.3354528 0.3354316 0.3354104 0.3353892 0.3353680 0.3353467 [218] 0.3353253 0.3353040 0.3352826 0.3352612 0.3352397 0.3352182 0.3351967 [225] 0.3351751 0.3351536 0.3351319 0.3351103 0.3350886 0.3350669 0.3350451 [232] 0.3350233 0.3350015 0.3349797 0.3349578 0.3349359 0.3349139 0.3348919 [239] 0.3348699 0.3348479 0.3348258 0.3348037 0.3347816 0.3347594 0.3347372 [246] 0.3347149 0.3346927 0.3346704 0.3346480 0.3346256 0.3346032 0.3345808 [253] 0.3345583 0.3345358 0.3345133 0.3344907 0.3344681 0.3344455 0.3344229 [260] 0.3344002 0.3343774 0.3343547 0.3343319 0.3343091 0.3342862 0.3342633 [267] 0.3342404 0.3342174 0.3341945 0.3341714 0.3341484 0.3341253 0.3341022 [274] 0.3340790 0.3340559 0.3340326 0.3340094 0.3339861 0.3339628 0.3339395 [281] 0.3339161 0.3338927 0.3338693 0.3338458 0.3338223 0.3337988 0.3337752 [288] 0.3337516 0.3337280 0.3337043 0.3336806 0.3336569 0.3336331 0.3336094 [295] 0.3335855 0.3335617 0.3335378 0.3335139 0.3334899 0.3334660 0.3334419 [302] 0.3334179 0.3333938 0.3333697 0.3333456 0.3333214 0.3332972 0.3332730 [309] 0.3332487 0.3332244 0.3332001 0.3331757 0.3331513 0.3331269 0.3331024 [316] 0.3330780 0.3330534 0.3330289 0.3330043 0.3329797 0.3329550 0.3329304 [323] 0.3329057 0.3328809 0.3328561 0.3328313 0.3328065 0.3327816 0.3327567 [330] 0.3327318 0.3327068 0.3326818 0.3326568 0.3326318 0.3326067 0.3325816 [337] 0.3325564 0.3325312 0.3325060 0.3324808 0.3324555 0.3324302 0.3324049 [344] 0.3323795 0.3323541 0.3323287 0.3323032 0.3322777 0.3322522 0.3322266 [351] 0.3322010 0.3321754 0.3321498 0.3321241 0.3320984 0.3320726 0.3320469 [358] 0.3320211 0.3319952 0.3319694 0.3319435 0.3319175 0.3318916 0.3318656 [365] 0.3318396 0.3318135 0.3317874 0.3317613 0.3317352 0.3317090 0.3316828 [372] 0.3316565 0.3316303 0.3316040 0.3315776 0.3315513 0.3315249 0.3314985 [379] 0.3314720 0.3314455 0.3314190 0.3313925 0.3313659 0.3313393 0.3313126 [386] 0.3312860 0.3312593 0.3312326 0.3312058 0.3311790 0.3311522 0.3311253 [393] 0.3310984 0.3310715 0.3310446 0.3310176 0.3309906 0.3309636 0.3309365 [400] 0.3309094 0.3308823 > mx [1] 0.3391712 > 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/1tami1194695891.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/2v3341194695891.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/3qjik1194695891.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/4y3af1194695891.tab") > > system("convert tmp/1tami1194695891.ps tmp/1tami1194695891.png") > system("convert tmp/2v3341194695891.ps tmp/2v3341194695891.png") > system("convert tmp/3qjik1194695891.ps tmp/3qjik1194695891.png") > > > proc.time() user system elapsed 1.049 0.523 1.191