R version 2.8.1 (2008-12-22) Copyright (C) 2008 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(8.2,8.0,7.5,6.8,6.5,6.6,7.6,8.0,8.1,7.7,7.5,7.6,7.8,7.8,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.2,7.9,7.3,6.9,6.6,6.7,6.9,7.0,7.1,7.2,7.1,6.9,7.0,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,7.9,7.7) > x <- c(9.9,9.8,9.3,8.3,8.0,8.5,10.4,11.1,10.9,10.0,9.2,9.2,9.5,9.6,9.5,9.1,8.9,9.0,10.1,10.3,10.2,9.6,9.2,9.3,9.4,9.4,9.2,9.0,9.0,9.0,9.8,10.0,9.8,9.3,9.0,9.0,9.1,9.1,9.1,9.2,8.8,8.3,8.4,8.1,7.7,7.9,7.9,8.0,7.9,7.6,7.1,6.8,6.5,6.9,8.2,8.7,8.3,7.9,7.5,7.8,8.3,8.4,8.2,7.7) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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.7224427 0.7224688 0.7224945 0.7225197 0.7225444 0.7225686 0.7225924 [8] 0.7226156 0.7226384 0.7226607 0.7226825 0.7227038 0.7227246 0.7227449 [15] 0.7227647 0.7227841 0.7228029 0.7228213 0.7228392 0.7228566 0.7228735 [22] 0.7228899 0.7229059 0.7229213 0.7229363 0.7229507 0.7229647 0.7229782 [29] 0.7229912 0.7230037 0.7230157 0.7230273 0.7230383 0.7230489 0.7230589 [36] 0.7230685 0.7230776 0.7230862 0.7230943 0.7231019 0.7231091 0.7231157 [43] 0.7231219 0.7231275 0.7231327 0.7231374 0.7231416 0.7231453 0.7231485 [50] 0.7231512 0.7231535 0.7231552 0.7231565 0.7231573 0.7231576 0.7231573 [57] 0.7231567 0.7231555 0.7231538 0.7231516 0.7231490 0.7231458 0.7231422 [64] 0.7231381 0.7231335 0.7231284 0.7231228 0.7231167 0.7231102 0.7231031 [71] 0.7230956 0.7230876 0.7230791 0.7230701 0.7230606 0.7230506 0.7230401 [78] 0.7230292 0.7230177 0.7230058 0.7229934 0.7229805 0.7229671 0.7229532 [85] 0.7229388 0.7229239 0.7229086 0.7228928 0.7228765 0.7228596 0.7228424 [92] 0.7228246 0.7228063 0.7227876 0.7227683 0.7227486 0.7227284 0.7227077 [99] 0.7226865 0.7226648 0.7226427 0.7226200 0.7225969 0.7225733 0.7225492 [106] 0.7225246 0.7224996 0.7224740 0.7224480 0.7224215 0.7223945 0.7223670 [113] 0.7223390 0.7223106 0.7222816 0.7222522 0.7222223 0.7221919 0.7221610 [120] 0.7221297 0.7220978 0.7220655 0.7220327 0.7219994 0.7219657 0.7219314 [127] 0.7218967 0.7218615 0.7218258 0.7217896 0.7217530 0.7217159 0.7216783 [134] 0.7216402 0.7216016 0.7215625 0.7215230 0.7214830 0.7214425 0.7214016 [141] 0.7213601 0.7213182 0.7212758 0.7212329 0.7211896 0.7211457 0.7211014 [148] 0.7210566 0.7210114 0.7209656 0.7209194 0.7208727 0.7208256 0.7207779 [155] 0.7207298 0.7206812 0.7206321 0.7205826 0.7205326 0.7204821 0.7204311 [162] 0.7203797 0.7203278 0.7202754 0.7202226 0.7201692 0.7201154 0.7200612 [169] 0.7200064 0.7199512 0.7198955 0.7198394 0.7197828 0.7197257 0.7196681 [176] 0.7196101 0.7195516 0.7194926 0.7194332 0.7193733 0.7193129 0.7192521 [183] 0.7191908 0.7191290 0.7190667 0.7190040 0.7189409 0.7188772 0.7188131 [190] 0.7187486 0.7186835 0.7186180 0.7185521 0.7184857 0.7184188 0.7183514 [197] 0.7182836 0.7182153 0.7181466 0.7180774 0.7180078 0.7179376 0.7178671 [204] 0.7177960 0.7177245 0.7176526 0.7175801 0.7175073 0.7174339 0.7173602 [211] 0.7172859 0.7172112 0.7171360 0.7170604 0.7169843 0.7169078 0.7168308 [218] 0.7167534 0.7166755 0.7165971 0.7165183 0.7164391 0.7163594 0.7162792 [225] 0.7161986 0.7161175 0.7160360 0.7159540 0.7158716 0.7157888 0.7157054 [232] 0.7156217 0.7155375 0.7154528 0.7153677 0.7152821 0.7151961 0.7151097 [239] 0.7150228 0.7149354 0.7148476 0.7147594 0.7146707 0.7145816 0.7144920 [246] 0.7144020 0.7143115 0.7142206 0.7141293 0.7140375 0.7139453 0.7138526 [253] 0.7137595 0.7136659 0.7135719 0.7134775 0.7133827 0.7132873 0.7131916 [260] 0.7130954 0.7129988 0.7129018 0.7128043 0.7127063 0.7126080 0.7125092 [267] 0.7124100 0.7123103 0.7122102 0.7121097 0.7120087 0.7119073 0.7118055 [274] 0.7117033 0.7116006 0.7114975 0.7113939 0.7112899 0.7111855 0.7110807 [281] 0.7109754 0.7108698 0.7107637 0.7106571 0.7105502 0.7104428 0.7103350 [288] 0.7102267 0.7101181 0.7100090 0.7098995 0.7097895 0.7096792 0.7095684 [295] 0.7094572 0.7093456 0.7092336 0.7091211 0.7090083 0.7088950 0.7087813 [302] 0.7086672 0.7085526 0.7084377 0.7083223 0.7082065 0.7080903 0.7079737 [309] 0.7078567 0.7077392 0.7076214 0.7075031 0.7073844 0.7072653 0.7071458 [316] 0.7070259 0.7069056 0.7067849 0.7066638 0.7065422 0.7064203 0.7062979 [323] 0.7061752 0.7060520 0.7059284 0.7058044 0.7056801 0.7055553 0.7054301 [330] 0.7053045 0.7051785 0.7050521 0.7049253 0.7047981 0.7046705 0.7045425 [337] 0.7044142 0.7042854 0.7041562 0.7040266 0.7038966 0.7037663 0.7036355 [344] 0.7035043 0.7033728 0.7032408 0.7031085 0.7029757 0.7028426 0.7027091 [351] 0.7025752 0.7024409 0.7023062 0.7021711 0.7020357 0.7018998 0.7017636 [358] 0.7016269 0.7014899 0.7013525 0.7012147 0.7010766 0.7009380 0.7007991 [365] 0.7006598 0.7005201 0.7003800 0.7002395 0.7000987 0.6999575 0.6998159 [372] 0.6996739 0.6995315 0.6993888 0.6992457 0.6991022 0.6989584 0.6988141 [379] 0.6986695 0.6985245 0.6983792 0.6982334 0.6980873 0.6979409 0.6977940 [386] 0.6976468 0.6974992 0.6973513 0.6972030 0.6970543 0.6969052 0.6967558 [393] 0.6966060 0.6964559 0.6963053 0.6961545 0.6960032 0.6958516 0.6956996 [400] 0.6955473 0.6953946 > mx [1] 0.7231576 > mxli [1] -1.46 > 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/rcomp/tmp/1ymt41257883298.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/rcomp/tmp/2y0qr1257883298.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/rcomp/tmp/3ll2z1257883298.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 > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/4hkap1257883298.tab") > > system("convert tmp/1ymt41257883298.ps tmp/1ymt41257883298.png") > system("convert tmp/2y0qr1257883298.ps tmp/2y0qr1257883298.png") > system("convert tmp/3ll2z1257883298.ps tmp/3ll2z1257883298.png") > > > proc.time() user system elapsed 0.950 0.860 1.591