R version 2.8.0 (2008-10-20) 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(9.3,8.3,8,8.5,10.4,11.1,10.9,10,9.2,9.2,9.5,9.6,9.5,9.1,8.9,9,10.1,10.3,10.2,9.6,9.2,9.3,9.4,9.4,9.2,9,9,9,9.8,10,9.8,9.3,9,9,9.1,9.1,9.1,9.2,8.8,8.3,8.4,8.1,7.7,7.9,7.9,8,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) > x <- c(7.5,6.8,6.5,6.6,7.6,8,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,7.1,7.2,7.1,6.9,7,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) > #'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.7480554 0.7480059 0.7479562 0.7479063 0.7478563 0.7478060 0.7477556 [8] 0.7477049 0.7476541 0.7476031 0.7475519 0.7475005 0.7474489 0.7473971 [15] 0.7473451 0.7472929 0.7472405 0.7471880 0.7471352 0.7470823 0.7470292 [22] 0.7469758 0.7469223 0.7468686 0.7468147 0.7467606 0.7467063 0.7466519 [29] 0.7465972 0.7465424 0.7464873 0.7464321 0.7463767 0.7463211 0.7462653 [36] 0.7462093 0.7461531 0.7460967 0.7460402 0.7459835 0.7459265 0.7458694 [43] 0.7458121 0.7457546 0.7456969 0.7456390 0.7455810 0.7455227 0.7454643 [50] 0.7454057 0.7453468 0.7452878 0.7452287 0.7451693 0.7451097 0.7450500 [57] 0.7449900 0.7449299 0.7448696 0.7448091 0.7447484 0.7446876 0.7446265 [64] 0.7445653 0.7445038 0.7444422 0.7443804 0.7443184 0.7442563 0.7441939 [71] 0.7441314 0.7440687 0.7440058 0.7439427 0.7438794 0.7438159 0.7437523 [78] 0.7436885 0.7436245 0.7435603 0.7434959 0.7434313 0.7433666 0.7433017 [85] 0.7432365 0.7431713 0.7431058 0.7430401 0.7429743 0.7429083 0.7428421 [92] 0.7427757 0.7427091 0.7426423 0.7425754 0.7425083 0.7424410 0.7423735 [99] 0.7423059 0.7422380 0.7421700 0.7421018 0.7420334 0.7419649 0.7418962 [106] 0.7418272 0.7417581 0.7416889 0.7416194 0.7415498 0.7414799 0.7414100 [113] 0.7413398 0.7412694 0.7411989 0.7411282 0.7410573 0.7409862 0.7409150 [120] 0.7408436 0.7407720 0.7407002 0.7406283 0.7405561 0.7404838 0.7404113 [127] 0.7403387 0.7402658 0.7401928 0.7401196 0.7400463 0.7399727 0.7398990 [134] 0.7398251 0.7397511 0.7396768 0.7396024 0.7395278 0.7394530 0.7393781 [141] 0.7393030 0.7392277 0.7391522 0.7390766 0.7390008 0.7389248 0.7388486 [148] 0.7387723 0.7386958 0.7386191 0.7385423 0.7384653 0.7383881 0.7383107 [155] 0.7382332 0.7381555 0.7380776 0.7379995 0.7379213 0.7378429 0.7377643 [162] 0.7376856 0.7376067 0.7375276 0.7374484 0.7373689 0.7372893 0.7372096 [169] 0.7371297 0.7370496 0.7369693 0.7368889 0.7368082 0.7367275 0.7366465 [176] 0.7365654 0.7364841 0.7364027 0.7363211 0.7362393 0.7361573 0.7360752 [183] 0.7359929 0.7359105 0.7358279 0.7357451 0.7356621 0.7355790 0.7354957 [190] 0.7354123 0.7353287 0.7352449 0.7351609 0.7350768 0.7349925 0.7349081 [197] 0.7348235 0.7347387 0.7346538 0.7345687 0.7344834 0.7343980 0.7343124 [204] 0.7342266 0.7341407 0.7340546 0.7339684 0.7338820 0.7337954 0.7337087 [211] 0.7336218 0.7335348 0.7334475 0.7333602 0.7332726 0.7331849 0.7330971 [218] 0.7330090 0.7329209 0.7328325 0.7327440 0.7326553 0.7325665 0.7324775 [225] 0.7323884 0.7322991 0.7322096 0.7321200 0.7320302 0.7319403 0.7318502 [232] 0.7317599 0.7316695 0.7315790 0.7314882 0.7313974 0.7313063 0.7312151 [239] 0.7311238 0.7310322 0.7309406 0.7308488 0.7307568 0.7306646 0.7305723 [246] 0.7304799 0.7303873 0.7302945 0.7302016 0.7301086 0.7300153 0.7299220 [253] 0.7298284 0.7297347 0.7296409 0.7295469 0.7294528 0.7293585 0.7292640 [260] 0.7291694 0.7290747 0.7289798 0.7288847 0.7287895 0.7286941 0.7285986 [267] 0.7285029 0.7284071 0.7283112 0.7282150 0.7281188 0.7280224 0.7279258 [274] 0.7278291 0.7277322 0.7276352 0.7275380 0.7274407 0.7273432 0.7272456 [281] 0.7271478 0.7270499 0.7269519 0.7268537 0.7267553 0.7266568 0.7265582 [288] 0.7264594 0.7263604 0.7262613 0.7261621 0.7260627 0.7259632 0.7258635 [295] 0.7257637 0.7256637 0.7255636 0.7254633 0.7253629 0.7252624 0.7251617 [302] 0.7250609 0.7249599 0.7248588 0.7247575 0.7246561 0.7245545 0.7244528 [309] 0.7243510 0.7242490 0.7241469 0.7240446 0.7239422 0.7238396 0.7237370 [316] 0.7236341 0.7235311 0.7234280 0.7233248 0.7232214 0.7231178 0.7230142 [323] 0.7229103 0.7228064 0.7227023 0.7225981 0.7224937 0.7223892 0.7222845 [330] 0.7221797 0.7220748 0.7219697 0.7218645 0.7217592 0.7216537 0.7215481 [337] 0.7214423 0.7213364 0.7212304 0.7211242 0.7210179 0.7209115 0.7208049 [344] 0.7206982 0.7205914 0.7204844 0.7203773 0.7202701 0.7201627 0.7200552 [351] 0.7199475 0.7198397 0.7197318 0.7196238 0.7195156 0.7194073 0.7192988 [358] 0.7191902 0.7190815 0.7189727 0.7188637 0.7187546 0.7186453 0.7185360 [365] 0.7184265 0.7183168 0.7182071 0.7180972 0.7179871 0.7178770 0.7177667 [372] 0.7176563 0.7175457 0.7174351 0.7173243 0.7172133 0.7171023 0.7169911 [379] 0.7168798 0.7167683 0.7166567 0.7165450 0.7164332 0.7163213 0.7162092 [386] 0.7160970 0.7159846 0.7158722 0.7157596 0.7156469 0.7155340 0.7154211 [393] 0.7153080 0.7151948 0.7150815 0.7149680 0.7148544 0.7147407 0.7146269 [400] 0.7145129 0.7143988 > mx [1] 0.7480554 > 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/freestat/rcomp/tmp/145te1257754453.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/freestat/rcomp/tmp/2qz9b1257754453.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/freestat/rcomp/tmp/38xy21257754453.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/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/4tqsn1257754453.tab") > > system("convert tmp/145te1257754453.ps tmp/145te1257754453.png") > system("convert tmp/2qz9b1257754453.ps tmp/2qz9b1257754453.png") > system("convert tmp/38xy21257754453.ps tmp/38xy21257754453.png") > > > proc.time() user system elapsed 1.216 0.811 1.409