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(20,16,19.8,18.4,17.1,15.5,14.7,17.1,15.4,16.2,15,17.2,16,17,14.4) > x <- c(88.6,71.6,93.3,84.3,80.6,75.2,69.7,82,69.4,83.3,79.6,82.6,80.6,83.5,76.3) > #'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.7837912 0.7839833 0.7841753 0.7843672 0.7845590 0.7847507 0.7849423 [8] 0.7851338 0.7853252 0.7855165 0.7857077 0.7858988 0.7860898 0.7862807 [15] 0.7864715 0.7866622 0.7868528 0.7870433 0.7872337 0.7874239 0.7876141 [22] 0.7878042 0.7879941 0.7881840 0.7883737 0.7885634 0.7887529 0.7889423 [29] 0.7891316 0.7893208 0.7895099 0.7896989 0.7898878 0.7900765 0.7902652 [36] 0.7904537 0.7906422 0.7908305 0.7910187 0.7912068 0.7913947 0.7915826 [43] 0.7917703 0.7919580 0.7921455 0.7923329 0.7925202 0.7927073 0.7928944 [50] 0.7930813 0.7932681 0.7934548 0.7936414 0.7938278 0.7940142 0.7942004 [57] 0.7943865 0.7945724 0.7947583 0.7949440 0.7951296 0.7953151 0.7955005 [64] 0.7956857 0.7958708 0.7960558 0.7962407 0.7964254 0.7966100 0.7967945 [71] 0.7969789 0.7971631 0.7973472 0.7975312 0.7977150 0.7978988 0.7980823 [78] 0.7982658 0.7984491 0.7986323 0.7988154 0.7989983 0.7991811 0.7993638 [85] 0.7995464 0.7997288 0.7999110 0.8000932 0.8002752 0.8004571 0.8006388 [92] 0.8008204 0.8010018 0.8011832 0.8013644 0.8015454 0.8017263 0.8019071 [99] 0.8020877 0.8022682 0.8024486 0.8026288 0.8028089 0.8029888 0.8031686 [106] 0.8033483 0.8035278 0.8037072 0.8038864 0.8040655 0.8042444 0.8044232 [113] 0.8046019 0.8047804 0.8049587 0.8051369 0.8053150 0.8054929 0.8056707 [120] 0.8058483 0.8060258 0.8062031 0.8063803 0.8065573 0.8067342 0.8069109 [127] 0.8070875 0.8072639 0.8074402 0.8076163 0.8077923 0.8079681 0.8081438 [134] 0.8083193 0.8084946 0.8086698 0.8088449 0.8090198 0.8091945 0.8093691 [141] 0.8095435 0.8097178 0.8098919 0.8100658 0.8102396 0.8104133 0.8105867 [148] 0.8107601 0.8109332 0.8111062 0.8112790 0.8114517 0.8116242 0.8117966 [155] 0.8119687 0.8121408 0.8123126 0.8124843 0.8126558 0.8128272 0.8129984 [162] 0.8131694 0.8133403 0.8135110 0.8136815 0.8138519 0.8140221 0.8141921 [169] 0.8143620 0.8145317 0.8147012 0.8148706 0.8150398 0.8152088 0.8153776 [176] 0.8155463 0.8157148 0.8158831 0.8160513 0.8162192 0.8163871 0.8165547 [183] 0.8167221 0.8168894 0.8170565 0.8172235 0.8173902 0.8175568 0.8177232 [190] 0.8178894 0.8180555 0.8182214 0.8183870 0.8185526 0.8187179 0.8188830 [197] 0.8190480 0.8192128 0.8193774 0.8195419 0.8197061 0.8198702 0.8200341 [204] 0.8201978 0.8203613 0.8205246 0.8206877 0.8208507 0.8210135 0.8211761 [211] 0.8213385 0.8215007 0.8216627 0.8218246 0.8219863 0.8221477 0.8223090 [218] 0.8224701 0.8226310 0.8227917 0.8229522 0.8231126 0.8232727 0.8234327 [225] 0.8235924 0.8237520 0.8239114 0.8240706 0.8242296 0.8243884 0.8245470 [232] 0.8247054 0.8248636 0.8250216 0.8251794 0.8253371 0.8254945 0.8256517 [239] 0.8258088 0.8259656 0.8261222 0.8262787 0.8264349 0.8265910 0.8267468 [246] 0.8269025 0.8270579 0.8272131 0.8273682 0.8275230 0.8276777 0.8278321 [253] 0.8279863 0.8281404 0.8282942 0.8284478 0.8286013 0.8287545 0.8289075 [260] 0.8290603 0.8292129 0.8293653 0.8295175 0.8296694 0.8298212 0.8299728 [267] 0.8301241 0.8302753 0.8304262 0.8305770 0.8307275 0.8308778 0.8310279 [274] 0.8311778 0.8313275 0.8314769 0.8316262 0.8317752 0.8319241 0.8320727 [281] 0.8322211 0.8323693 0.8325172 0.8326650 0.8328126 0.8329599 0.8331070 [288] 0.8332539 0.8334006 0.8335471 0.8336933 0.8338393 0.8339852 0.8341307 [295] 0.8342761 0.8344213 0.8345662 0.8347109 0.8348554 0.8349997 0.8351438 [302] 0.8352876 0.8354312 0.8355746 0.8357178 0.8358608 0.8360035 0.8361460 [309] 0.8362883 0.8364303 0.8365722 0.8367138 0.8368552 0.8369963 0.8371372 [316] 0.8372780 0.8374184 0.8375587 0.8376987 0.8378385 0.8379781 0.8381174 [323] 0.8382565 0.8383954 0.8385341 0.8386725 0.8388107 0.8389487 0.8390864 [330] 0.8392239 0.8393612 0.8394982 0.8396350 0.8397716 0.8399080 0.8400441 [337] 0.8401800 0.8403156 0.8404510 0.8405862 0.8407211 0.8408558 0.8409903 [344] 0.8411246 0.8412586 0.8413923 0.8415258 0.8416591 0.8417922 0.8419250 [351] 0.8420576 0.8421899 0.8423220 0.8424539 0.8425855 0.8427169 0.8428480 [358] 0.8429790 0.8431096 0.8432400 0.8433702 0.8435002 0.8436299 0.8437593 [365] 0.8438885 0.8440175 0.8441462 0.8442747 0.8444030 0.8445310 0.8446587 [372] 0.8447862 0.8449135 0.8450405 0.8451673 0.8452938 0.8454201 0.8455461 [379] 0.8456719 0.8457975 0.8459228 0.8460478 0.8461726 0.8462972 0.8464215 [386] 0.8465455 0.8466693 0.8467929 0.8469162 0.8470392 0.8471620 0.8472846 [393] 0.8474069 0.8475290 0.8476508 0.8477723 0.8478936 0.8480147 0.8481354 [400] 0.8482560 0.8483763 > mx [1] 0.8483763 > 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/1cvdr1226431761.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/2a2jr1226431761.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/3shvg1226431761.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/402sx1226431761.tab") > > system("convert tmp/1cvdr1226431761.ps tmp/1cvdr1226431761.png") > system("convert tmp/2a2jr1226431761.ps tmp/2a2jr1226431761.png") > system("convert tmp/3shvg1226431761.ps tmp/3shvg1226431761.png") > > > proc.time() user system elapsed 1.228 0.818 1.351