R version 2.7.2 (2008-08-25) 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(106.7,110.2,125.9,100.1,106.4,114.8,81.3,87,104.2,108,105,94.5,92,95.9,108.8,103.4,102.1,110.1,83.2,82.7,106.8,113.7,102.5,96.6,92.1,95.6,102.3,98.6,98.2,104.5,84,73.8,103.9,106,97.2,102.6,89,93.8,116.7,106.8,98.5,118.7,90,91.9,113.3,113.1,104.1,108.7,96.7,101,116.9,105.8,99,129.4,83,88.9,115.9,104.2,113.4,112.2,100.8,107.3,126.6,102.9,117.9,128.8,87.5,93.8,122.7,126.2,124.6,116.7,115.2,111.1,129.9,113.3,118.5,137.9,103.6,101.7,127.4,137.5,128.3,118.2) > x <- c(104.8,105.6,118.3,89.9,90.2,107,64.5,92.6,95.8,94.3,91.2,86.3,77.6,82.5,97.7,83.3,84.2,92.8,77.4,72.5,88.8,93.4,92.6,90.7,81.6,84.1,88.1,85.3,82.9,84.8,71.2,68.9,94.3,97.6,85.6,91.9,75.8,79.8,99,88.5,86.7,97.9,94.3,72.9,91.8,93.2,86.5,98.9,77.2,79.4,90.4,81.4,85.8,103.6,73.6,75.7,99.2,88.7,94.6,98.7,84.2,87.7,103.3,88.2,93.4,106.3,73.1,78.6,101.6,101.4,98.5,99,89.5,83.5,97.4,87.8,90.4,101.6,80,81.7,96.4,110.2,101.1,89.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.8137973 0.8139051 0.8140124 0.8141192 0.8142255 0.8143313 0.8144365 [8] 0.8145412 0.8146454 0.8147491 0.8148522 0.8149549 0.8150570 0.8151585 [15] 0.8152596 0.8153601 0.8154601 0.8155595 0.8156585 0.8157569 0.8158548 [22] 0.8159522 0.8160490 0.8161453 0.8162411 0.8163363 0.8164310 0.8165252 [29] 0.8166189 0.8167120 0.8168046 0.8168967 0.8169883 0.8170793 0.8171698 [36] 0.8172597 0.8173492 0.8174381 0.8175264 0.8176143 0.8177016 0.8177883 [43] 0.8178746 0.8179603 0.8180454 0.8181301 0.8182142 0.8182978 0.8183808 [50] 0.8184633 0.8185453 0.8186267 0.8187076 0.8187880 0.8188678 0.8189471 [57] 0.8190259 0.8191041 0.8191818 0.8192590 0.8193356 0.8194117 0.8194872 [64] 0.8195622 0.8196367 0.8197107 0.8197841 0.8198569 0.8199293 0.8200010 [71] 0.8200723 0.8201430 0.8202132 0.8202828 0.8203519 0.8204205 0.8204885 [78] 0.8205560 0.8206230 0.8206894 0.8207552 0.8208206 0.8208853 0.8209496 [85] 0.8210133 0.8210765 0.8211391 0.8212012 0.8212627 0.8213237 0.8213842 [92] 0.8214441 0.8215035 0.8215623 0.8216206 0.8216784 0.8217356 0.8217923 [99] 0.8218484 0.8219040 0.8219590 0.8220135 0.8220675 0.8221209 0.8221738 [106] 0.8222261 0.8222779 0.8223292 0.8223799 0.8224300 0.8224797 0.8225287 [113] 0.8225773 0.8226252 0.8226727 0.8227196 0.8227659 0.8228117 0.8228570 [120] 0.8229017 0.8229459 0.8229895 0.8230326 0.8230751 0.8231171 0.8231586 [127] 0.8231995 0.8232398 0.8232797 0.8233189 0.8233576 0.8233958 0.8234334 [134] 0.8234705 0.8235071 0.8235431 0.8235785 0.8236134 0.8236478 0.8236816 [141] 0.8237148 0.8237475 0.8237797 0.8238113 0.8238424 0.8238729 0.8239029 [148] 0.8239324 0.8239612 0.8239896 0.8240174 0.8240446 0.8240713 0.8240975 [155] 0.8241231 0.8241481 0.8241727 0.8241966 0.8242200 0.8242429 0.8242652 [162] 0.8242870 0.8243082 0.8243289 0.8243490 0.8243686 0.8243877 0.8244061 [169] 0.8244241 0.8244415 0.8244583 0.8244746 0.8244904 0.8245056 0.8245202 [176] 0.8245343 0.8245479 0.8245609 0.8245734 0.8245853 0.8245966 0.8246075 [183] 0.8246177 0.8246275 0.8246366 0.8246453 0.8246533 0.8246609 0.8246678 [190] 0.8246743 0.8246802 0.8246855 0.8246903 0.8246945 0.8246982 0.8247014 [197] 0.8247040 0.8247060 0.8247075 0.8247085 0.8247089 0.8247088 0.8247081 [204] 0.8247068 0.8247050 0.8247027 0.8246998 0.8246964 0.8246924 0.8246879 [211] 0.8246828 0.8246772 0.8246710 0.8246643 0.8246571 0.8246493 0.8246409 [218] 0.8246320 0.8246226 0.8246126 0.8246020 0.8245909 0.8245793 0.8245671 [225] 0.8245544 0.8245411 0.8245273 0.8245129 0.8244980 0.8244825 0.8244665 [232] 0.8244499 0.8244328 0.8244151 0.8243969 0.8243782 0.8243589 0.8243391 [239] 0.8243187 0.8242977 0.8242763 0.8242542 0.8242317 0.8242086 0.8241849 [246] 0.8241607 0.8241359 0.8241106 0.8240848 0.8240584 0.8240315 0.8240040 [253] 0.8239760 0.8239474 0.8239183 0.8238886 0.8238584 0.8238277 0.8237964 [260] 0.8237645 0.8237321 0.8236992 0.8236657 0.8236317 0.8235972 0.8235621 [267] 0.8235264 0.8234902 0.8234535 0.8234162 0.8233784 0.8233400 0.8233011 [274] 0.8232617 0.8232217 0.8231811 0.8231400 0.8230984 0.8230563 0.8230136 [281] 0.8229703 0.8229265 0.8228822 0.8228373 0.8227919 0.8227459 0.8226994 [288] 0.8226524 0.8226048 0.8225567 0.8225080 0.8224588 0.8224091 0.8223588 [295] 0.8223080 0.8222566 0.8222047 0.8221523 0.8220993 0.8220458 0.8219917 [302] 0.8219371 0.8218819 0.8218263 0.8217700 0.8217133 0.8216560 0.8215982 [309] 0.8215398 0.8214809 0.8214214 0.8213614 0.8213009 0.8212398 0.8211782 [316] 0.8211161 0.8210534 0.8209902 0.8209265 0.8208622 0.8207974 0.8207320 [323] 0.8206661 0.8205997 0.8205327 0.8204652 0.8203972 0.8203286 0.8202595 [330] 0.8201899 0.8201197 0.8200490 0.8199778 0.8199060 0.8198337 0.8197609 [337] 0.8196875 0.8196136 0.8195391 0.8194642 0.8193887 0.8193126 0.8192361 [344] 0.8191590 0.8190813 0.8190032 0.8189245 0.8188452 0.8187655 0.8186852 [351] 0.8186044 0.8185230 0.8184412 0.8183587 0.8182758 0.8181923 0.8181083 [358] 0.8180238 0.8179388 0.8178532 0.8177671 0.8176804 0.8175933 0.8175056 [365] 0.8174173 0.8173286 0.8172393 0.8171495 0.8170592 0.8169683 0.8168770 [372] 0.8167850 0.8166926 0.8165997 0.8165062 0.8164122 0.8163176 0.8162226 [379] 0.8161270 0.8160309 0.8159343 0.8158371 0.8157394 0.8156412 0.8155425 [386] 0.8154433 0.8153435 0.8152432 0.8151424 0.8150411 0.8149392 0.8148369 [393] 0.8147340 0.8146305 0.8145266 0.8144222 0.8143172 0.8142117 0.8141057 [400] 0.8139992 0.8138921 > mx [1] 0.8247089 > mxli [1] 0 > 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/1h72r1226477422.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/2bbjy1226477422.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/34h4u1226477422.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/4y6k31226477422.tab") > > system("convert tmp/1h72r1226477422.ps tmp/1h72r1226477422.png") > system("convert tmp/2bbjy1226477422.ps tmp/2bbjy1226477422.png") > system("convert tmp/34h4u1226477422.ps tmp/34h4u1226477422.png") > > > proc.time() user system elapsed 1.040 0.538 4.086