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(281,295,294,302,314,321,313,310,319,316,319,333,356,358,340,328,355,356,351,359,378,378,389.,407,413,404,406,402,383,392,398,400,405,420,439,441,424,423,434,429,421,430,424,437,456,469,476,510,549,554,557,610,675,596,633,632,596,585,627,629) > x <- c(0.88,0.87,0.88,0.89,0.92,0.96,0.99,0.98,0.98,0.98,1.00,1.02,1.06,1.08,1.08,1.08,1.16,1.17,1.14,1.11,1.12,1.17,1.17,1.23,1.26,1.26,1.23,1.20,1.20,1.21,1.23,1.22,1.22,1.25,1.30,1.34,1.31,1.30,1.32,1.29,1.27,1.22,1.20,1.23,1.23,1.20,1.18,1.19,1.21,1.19,1.20,1.23,1.28,1.27,1.27,1.28,1.27,1.26,1.29,1.32) > #'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.6787919 0.6789252 0.6790582 0.6791911 0.6793237 0.6794562 0.6795884 [8] 0.6797205 0.6798523 0.6799840 0.6801155 0.6802467 0.6803778 0.6805086 [15] 0.6806393 0.6807697 0.6809000 0.6810300 0.6811598 0.6812895 0.6814189 [22] 0.6815481 0.6816772 0.6818060 0.6819346 0.6820630 0.6821912 0.6823192 [29] 0.6824470 0.6825746 0.6827020 0.6828292 0.6829561 0.6830829 0.6832094 [36] 0.6833358 0.6834619 0.6835878 0.6837136 0.6838391 0.6839644 0.6840894 [43] 0.6842143 0.6843390 0.6844634 0.6845877 0.6847117 0.6848355 0.6849591 [50] 0.6850825 0.6852057 0.6853287 0.6854514 0.6855739 0.6856963 0.6858184 [57] 0.6859403 0.6860619 0.6861834 0.6863046 0.6864257 0.6865465 0.6866671 [64] 0.6867875 0.6869076 0.6870276 0.6871473 0.6872668 0.6873861 0.6875051 [71] 0.6876240 0.6877426 0.6878610 0.6879792 0.6880972 0.6882149 0.6883325 [78] 0.6884498 0.6885669 0.6886837 0.6888004 0.6889168 0.6890330 0.6891490 [85] 0.6892647 0.6893802 0.6894955 0.6896106 0.6897255 0.6898401 0.6899545 [92] 0.6900687 0.6901826 0.6902964 0.6904099 0.6905231 0.6906362 0.6907490 [99] 0.6908616 0.6909740 0.6910861 0.6911980 0.6913097 0.6914212 0.6915324 [106] 0.6916434 0.6917541 0.6918647 0.6919750 0.6920851 0.6921949 0.6923045 [113] 0.6924139 0.6925231 0.6926320 0.6927407 0.6928492 0.6929574 0.6930654 [120] 0.6931731 0.6932807 0.6933880 0.6934950 0.6936019 0.6937085 0.6938148 [127] 0.6939210 0.6940269 0.6941325 0.6942379 0.6943431 0.6944481 0.6945528 [134] 0.6946573 0.6947615 0.6948655 0.6949693 0.6950728 0.6951761 0.6952792 [141] 0.6953820 0.6954846 0.6955870 0.6956891 0.6957909 0.6958926 0.6959940 [148] 0.6960951 0.6961960 0.6962967 0.6963971 0.6964973 0.6965973 0.6966970 [155] 0.6967965 0.6968957 0.6969947 0.6970934 0.6971920 0.6972902 0.6973882 [162] 0.6974860 0.6975836 0.6976809 0.6977779 0.6978747 0.6979713 0.6980676 [169] 0.6981637 0.6982595 0.6983551 0.6984505 0.6985456 0.6986404 0.6987350 [176] 0.6988294 0.6989235 0.6990174 0.6991110 0.6992044 0.6992976 0.6993904 [183] 0.6994831 0.6995755 0.6996676 0.6997596 0.6998512 0.6999426 0.7000338 [190] 0.7001247 0.7002154 0.7003058 0.7003960 0.7004859 0.7005756 0.7006650 [197] 0.7007542 0.7008431 0.7009318 0.7010202 0.7011084 0.7011963 0.7012840 [204] 0.7013714 0.7014586 0.7015455 0.7016322 0.7017186 0.7018048 0.7018907 [211] 0.7019764 0.7020618 0.7021470 0.7022319 0.7023166 0.7024010 0.7024851 [218] 0.7025691 0.7026527 0.7027361 0.7028193 0.7029022 0.7029848 0.7030672 [225] 0.7031493 0.7032312 0.7033128 0.7033942 0.7034753 0.7035562 0.7036368 [232] 0.7037172 0.7037973 0.7038771 0.7039567 0.7040361 0.7041152 0.7041940 [239] 0.7042726 0.7043509 0.7044289 0.7045067 0.7045843 0.7046616 0.7047386 [246] 0.7048154 0.7048919 0.7049682 0.7050442 0.7051200 0.7051955 0.7052707 [253] 0.7053457 0.7054204 0.7054949 0.7055691 0.7056430 0.7057167 0.7057902 [260] 0.7058634 0.7059363 0.7060089 0.7060813 0.7061535 0.7062254 0.7062970 [267] 0.7063684 0.7064395 0.7065103 0.7065809 0.7066513 0.7067213 0.7067912 [274] 0.7068607 0.7069300 0.7069990 0.7070678 0.7071363 0.7072046 0.7072726 [281] 0.7073403 0.7074078 0.7074750 0.7075420 0.7076087 0.7076751 0.7077413 [288] 0.7078072 0.7078728 0.7079382 0.7080034 0.7080682 0.7081328 0.7081972 [295] 0.7082613 0.7083251 0.7083887 0.7084520 0.7085150 0.7085778 0.7086403 [302] 0.7087026 0.7087646 0.7088263 0.7088878 0.7089490 0.7090099 0.7090706 [309] 0.7091310 0.7091912 0.7092511 0.7093107 0.7093701 0.7094292 0.7094880 [316] 0.7095466 0.7096049 0.7096630 0.7097208 0.7097783 0.7098356 0.7098926 [323] 0.7099493 0.7100058 0.7100620 0.7101180 0.7101737 0.7102291 0.7102843 [330] 0.7103392 0.7103938 0.7104482 0.7105023 0.7105562 0.7106097 0.7106631 [337] 0.7107161 0.7107689 0.7108214 0.7108737 0.7109257 0.7109775 0.7110289 [344] 0.7110801 0.7111311 0.7111818 0.7112322 0.7112824 0.7113322 0.7113819 [351] 0.7114312 0.7114803 0.7115292 0.7115778 0.7116261 0.7116741 0.7117219 [358] 0.7117694 0.7118167 0.7118636 0.7119104 0.7119568 0.7120030 0.7120490 [365] 0.7120946 0.7121400 0.7121852 0.7122301 0.7122747 0.7123190 0.7123631 [372] 0.7124069 0.7124505 0.7124938 0.7125368 0.7125796 0.7126221 0.7126643 [379] 0.7127063 0.7127480 0.7127894 0.7128306 0.7128715 0.7129122 0.7129525 [386] 0.7129927 0.7130325 0.7130721 0.7131115 0.7131505 0.7131893 0.7132279 [393] 0.7132661 0.7133042 0.7133419 0.7133794 0.7134166 0.7134536 0.7134903 [400] 0.7135267 0.7135629 > mx [1] 0.7135629 > 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/1lq4o1200487979.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/2xyr81200487979.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/3ihbe1200487979.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/4dxu41200487979.tab") > > system("convert tmp/1lq4o1200487979.ps tmp/1lq4o1200487979.png") > system("convert tmp/2xyr81200487979.ps tmp/2xyr81200487979.png") > system("convert tmp/3ihbe1200487979.ps tmp/3ihbe1200487979.png") > > > proc.time() user system elapsed 1.194 0.604 8.307