R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(3.2,3.7,3.5,3.4,3.3,3.1,3.4,3.9,3.8,3.4,3.3,3,2.9,3.1,2.9,2.8,2.7,2.5,2.7,3.1,3,2.5,2.3,2.1,2,2.3,2.1,2,1.9,1.8,1.9,2.3,2.2,1.9,1.7,1.6,1.5,1.7,1.6,1.6,1.5,1.4,1.6,1.9,1.8,1.6,1.6,1.6,1.7,2,1.9,2,2.1,2,2.2,2.6,2.6,2.2,2.1,2.1) > x <- c(3.9,4.4,4.1,4.1,3.8,3.4,3.4,3.6,3.6,3.4,3.3,3.1,3.2,3.4,3.1,3,2.8,2.5,2.5,2.6,2.5,2.3,2.2,2.1,2.1,2.3,2.2,2.1,1.9,1.7,1.7,1.9,1.8,1.7,1.6,1.6,1.6,1.9,1.8,1.8,1.6,1.5,1.5,1.7,1.7,1.7,1.8,2,2.3,3,3.2,3.4,3.5,3.2,3.2,3.4,3.3,3.1,3.1,3.1) > #'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.7644148 0.7646430 0.7648708 0.7650982 0.7653251 0.7655517 0.7657778 [8] 0.7660035 0.7662288 0.7664536 0.7666780 0.7669020 0.7671256 0.7673488 [15] 0.7675715 0.7677937 0.7680156 0.7682370 0.7684579 0.7686784 0.7688985 [22] 0.7691181 0.7693373 0.7695560 0.7697743 0.7699921 0.7702094 0.7704263 [29] 0.7706428 0.7708587 0.7710743 0.7712893 0.7715039 0.7717180 0.7719316 [36] 0.7721448 0.7723574 0.7725696 0.7727814 0.7729926 0.7732034 0.7734136 [43] 0.7736234 0.7738327 0.7740415 0.7742498 0.7744576 0.7746649 0.7748717 [50] 0.7750781 0.7752839 0.7754892 0.7756940 0.7758982 0.7761020 0.7763053 [57] 0.7765080 0.7767102 0.7769119 0.7771131 0.7773138 0.7775139 0.7777135 [64] 0.7779126 0.7781111 0.7783091 0.7785066 0.7787036 0.7788999 0.7790958 [71] 0.7792911 0.7794859 0.7796801 0.7798738 0.7800669 0.7802594 0.7804514 [78] 0.7806429 0.7808338 0.7810241 0.7812139 0.7814031 0.7815917 0.7817797 [85] 0.7819672 0.7821541 0.7823405 0.7825262 0.7827114 0.7828960 0.7830800 [92] 0.7832634 0.7834462 0.7836285 0.7838101 0.7839912 0.7841716 0.7843515 [99] 0.7845308 0.7847094 0.7848875 0.7850649 0.7852418 0.7854180 0.7855936 [106] 0.7857686 0.7859430 0.7861167 0.7862899 0.7864624 0.7866343 0.7868055 [113] 0.7869762 0.7871462 0.7873155 0.7874842 0.7876523 0.7878198 0.7879866 [120] 0.7881528 0.7883183 0.7884832 0.7886474 0.7888110 0.7889739 0.7891361 [127] 0.7892977 0.7894587 0.7896190 0.7897786 0.7899375 0.7900958 0.7902534 [134] 0.7904103 0.7905666 0.7907222 0.7908771 0.7910313 0.7911848 0.7913377 [141] 0.7914899 0.7916413 0.7917921 0.7919422 0.7920916 0.7922403 0.7923883 [148] 0.7925356 0.7926822 0.7928281 0.7929733 0.7931177 0.7932615 0.7934045 [155] 0.7935468 0.7936885 0.7938293 0.7939695 0.7941089 0.7942477 0.7943856 [162] 0.7945229 0.7946594 0.7947952 0.7949303 0.7950646 0.7951981 0.7953310 [169] 0.7954630 0.7955944 0.7957250 0.7958548 0.7959839 0.7961122 0.7962398 [176] 0.7963666 0.7964926 0.7966179 0.7967424 0.7968662 0.7969892 0.7971114 [183] 0.7972328 0.7973535 0.7974733 0.7975924 0.7977108 0.7978283 0.7979450 [190] 0.7980610 0.7981762 0.7982906 0.7984042 0.7985169 0.7986289 0.7987401 [197] 0.7988505 0.7989601 0.7990689 0.7991769 0.7992840 0.7993904 0.7994959 [204] 0.7996006 0.7997045 0.7998076 0.7999099 0.8000113 0.8001119 0.8002117 [211] 0.8003107 0.8004088 0.8005061 0.8006025 0.8006981 0.8007929 0.8008869 [218] 0.8009799 0.8010722 0.8011636 0.8012541 0.8013438 0.8014327 0.8015207 [225] 0.8016078 0.8016941 0.8017795 0.8018640 0.8019477 0.8020305 0.8021125 [232] 0.8021935 0.8022738 0.8023531 0.8024315 0.8025091 0.8025858 0.8026616 [239] 0.8027366 0.8028106 0.8028838 0.8029560 0.8030274 0.8030979 0.8031675 [246] 0.8032362 0.8033040 0.8033709 0.8034369 0.8035020 0.8035661 0.8036294 [253] 0.8036918 0.8037532 0.8038138 0.8038734 0.8039321 0.8039899 0.8040468 [260] 0.8041027 0.8041578 0.8042119 0.8042650 0.8043173 0.8043686 0.8044190 [267] 0.8044684 0.8045169 0.8045645 0.8046112 0.8046569 0.8047016 0.8047454 [274] 0.8047883 0.8048302 0.8048712 0.8049112 0.8049503 0.8049884 0.8050255 [281] 0.8050617 0.8050970 0.8051313 0.8051646 0.8051969 0.8052283 0.8052587 [288] 0.8052882 0.8053167 0.8053442 0.8053707 0.8053963 0.8054209 0.8054445 [295] 0.8054671 0.8054888 0.8055095 0.8055291 0.8055479 0.8055656 0.8055823 [302] 0.8055980 0.8056128 0.8056265 0.8056393 0.8056511 0.8056618 0.8056716 [309] 0.8056804 0.8056882 0.8056949 0.8057007 0.8057055 0.8057092 0.8057120 [316] 0.8057137 0.8057145 0.8057142 0.8057129 0.8057106 0.8057073 0.8057030 [323] 0.8056976 0.8056912 0.8056839 0.8056755 0.8056660 0.8056556 0.8056441 [330] 0.8056316 0.8056181 0.8056035 0.8055879 0.8055713 0.8055537 0.8055350 [337] 0.8055153 0.8054945 0.8054727 0.8054499 0.8054261 0.8054012 0.8053752 [344] 0.8053483 0.8053202 0.8052912 0.8052611 0.8052299 0.8051978 0.8051645 [351] 0.8051302 0.8050949 0.8050585 0.8050211 0.8049826 0.8049431 0.8049025 [358] 0.8048609 0.8048182 0.8047745 0.8047297 0.8046838 0.8046369 0.8045890 [365] 0.8045399 0.8044899 0.8044387 0.8043865 0.8043333 0.8042790 0.8042236 [372] 0.8041671 0.8041096 0.8040511 0.8039914 0.8039307 0.8038690 0.8038062 [379] 0.8037423 0.8036773 0.8036113 0.8035442 0.8034760 0.8034068 0.8033365 [386] 0.8032651 0.8031927 0.8031192 0.8030446 0.8029690 0.8028923 0.8028145 [393] 0.8027356 0.8026557 0.8025747 0.8024926 0.8024095 0.8023253 0.8022400 [400] 0.8021536 0.8020662 > mx [1] 0.8057145 > mxli [1] 1.16 > 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/1hqix1260276260.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/2k7vy1260276260.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/3mwgi1260276260.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > 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/4z84v1260276260.tab") > > system("convert tmp/1hqix1260276260.ps tmp/1hqix1260276260.png") > system("convert tmp/2k7vy1260276260.ps tmp/2k7vy1260276260.png") > system("convert tmp/3mwgi1260276260.ps tmp/3mwgi1260276260.png") > > > proc.time() user system elapsed 0.775 0.489 1.002