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(128.7,136.9,156.9,109.1,122.3,123.9,90.9,77.9,120.3,118.9,125.5,98.9,102.9,105.9,117.6,113.6,115.9,118.9,77.6,81.2,123.1,136.6,112.1,95.1,96.3,105.7,115.8,105.7,105.7,111.1,82.4,60,107.3,99.3,113.5,108.9,100.2,103.9,138.7,120.2,100.2,143.2,70.9,85.2,133,136.6,117.9,106.3,122.3,125.5,148.4,126.3,99.6,140.4,80.3,92.6,138.5,110.9,119.6,105) > x <- c(98.8,100.5,110.4,96.4,101.9,106.2,81,94.7,101,109.4,102.3,90.7,96.2,96.1,106,103.1,102,104.7,86,92.1,106.9,112.6,101.7,92,97.4,97,105.4,102.7,98.1,104.5,87.4,89.9,109.8,111.7,98.6,96.9,95.1,97,112.7,102.9,97.4,111.4,87.4,96.8,114.1,110.3,103.9,101.6,94.6,95.9,104.7,102.8,98.1,113.9,80.9,95.7,113.2,105.9,108.8,102.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.7574094 0.7574953 0.7575808 0.7576661 0.7577510 0.7578356 0.7579200 [8] 0.7580040 0.7580878 0.7581712 0.7582544 0.7583372 0.7584198 0.7585020 [15] 0.7585840 0.7586656 0.7587470 0.7588280 0.7589088 0.7589892 0.7590693 [22] 0.7591492 0.7592287 0.7593080 0.7593869 0.7594656 0.7595440 0.7596220 [29] 0.7596998 0.7597772 0.7598544 0.7599312 0.7600078 0.7600840 0.7601600 [36] 0.7602356 0.7603110 0.7603860 0.7604608 0.7605352 0.7606094 0.7606833 [43] 0.7607568 0.7608301 0.7609030 0.7609757 0.7610480 0.7611201 0.7611919 [50] 0.7612633 0.7613345 0.7614054 0.7614759 0.7615462 0.7616161 0.7616858 [57] 0.7617552 0.7618242 0.7618930 0.7619615 0.7620297 0.7620975 0.7621651 [64] 0.7622324 0.7622994 0.7623660 0.7624324 0.7624985 0.7625643 0.7626297 [71] 0.7626949 0.7627598 0.7628244 0.7628887 0.7629527 0.7630164 0.7630798 [78] 0.7631429 0.7632057 0.7632682 0.7633304 0.7633923 0.7634539 0.7635152 [85] 0.7635762 0.7636369 0.7636973 0.7637575 0.7638173 0.7638768 0.7639360 [92] 0.7639950 0.7640536 0.7641119 0.7641700 0.7642277 0.7642852 0.7643423 [99] 0.7643992 0.7644557 0.7645120 0.7645680 0.7646236 0.7646790 0.7647341 [106] 0.7647889 0.7648434 0.7648976 0.7649515 0.7650051 0.7650584 0.7651114 [113] 0.7651641 0.7652165 0.7652686 0.7653205 0.7653720 0.7654232 0.7654742 [120] 0.7655248 0.7655752 0.7656253 0.7656750 0.7657245 0.7657737 0.7658226 [127] 0.7658712 0.7659195 0.7659675 0.7660152 0.7660626 0.7661098 0.7661566 [134] 0.7662032 0.7662494 0.7662954 0.7663410 0.7663864 0.7664315 0.7664763 [141] 0.7665208 0.7665650 0.7666089 0.7666526 0.7666959 0.7667389 0.7667817 [148] 0.7668242 0.7668663 0.7669082 0.7669498 0.7669911 0.7670321 0.7670728 [155] 0.7671133 0.7671534 0.7671933 0.7672328 0.7672721 0.7673111 0.7673498 [162] 0.7673882 0.7674263 0.7674642 0.7675017 0.7675390 0.7675759 0.7676126 [169] 0.7676490 0.7676851 0.7677209 0.7677565 0.7677917 0.7678267 0.7678613 [176] 0.7678957 0.7679298 0.7679636 0.7679972 0.7680304 0.7680634 0.7680960 [183] 0.7681284 0.7681605 0.7681923 0.7682239 0.7682551 0.7682861 0.7683168 [190] 0.7683472 0.7683773 0.7684071 0.7684367 0.7684659 0.7684949 0.7685236 [197] 0.7685520 0.7685801 0.7686080 0.7686356 0.7686629 0.7686899 0.7687166 [204] 0.7687430 0.7687692 0.7687951 0.7688207 0.7688460 0.7688710 0.7688958 [211] 0.7689203 0.7689445 0.7689684 0.7689920 0.7690154 0.7690385 0.7690613 [218] 0.7690838 0.7691061 0.7691281 0.7691498 0.7691712 0.7691923 0.7692132 [225] 0.7692338 0.7692541 0.7692741 0.7692939 0.7693134 0.7693326 0.7693515 [232] 0.7693701 0.7693885 0.7694066 0.7694245 0.7694420 0.7694593 0.7694763 [239] 0.7694931 0.7695095 0.7695257 0.7695416 0.7695573 0.7695726 0.7695877 [246] 0.7696026 0.7696171 0.7696314 0.7696454 0.7696592 0.7696726 0.7696858 [253] 0.7696988 0.7697114 0.7697238 0.7697359 0.7697478 0.7697594 0.7697707 [260] 0.7697817 0.7697925 0.7698030 0.7698132 0.7698232 0.7698329 0.7698423 [267] 0.7698515 0.7698604 0.7698691 0.7698774 0.7698855 0.7698934 0.7699009 [274] 0.7699083 0.7699153 0.7699221 0.7699286 0.7699348 0.7699408 0.7699465 [281] 0.7699520 0.7699572 0.7699621 0.7699668 0.7699712 0.7699754 0.7699792 [288] 0.7699829 0.7699862 0.7699893 0.7699922 0.7699948 0.7699971 0.7699991 [295] 0.7700009 0.7700025 0.7700038 0.7700048 0.7700055 0.7700060 0.7700063 [302] 0.7700063 0.7700060 0.7700055 0.7700047 0.7700037 0.7700024 0.7700008 [309] 0.7699990 0.7699970 0.7699946 0.7699921 0.7699892 0.7699862 0.7699828 [316] 0.7699792 0.7699754 0.7699713 0.7699669 0.7699623 0.7699575 0.7699524 [323] 0.7699470 0.7699414 0.7699355 0.7699294 0.7699231 0.7699164 0.7699096 [330] 0.7699025 0.7698951 0.7698875 0.7698796 0.7698715 0.7698632 0.7698545 [337] 0.7698457 0.7698366 0.7698272 0.7698176 0.7698078 0.7697977 0.7697874 [344] 0.7697768 0.7697660 0.7697549 0.7697436 0.7697320 0.7697202 0.7697081 [351] 0.7696959 0.7696833 0.7696705 0.7696575 0.7696442 0.7696307 0.7696170 [358] 0.7696030 0.7695888 0.7695743 0.7695596 0.7695446 0.7695294 0.7695140 [365] 0.7694983 0.7694824 0.7694662 0.7694499 0.7694332 0.7694164 0.7693993 [372] 0.7693819 0.7693643 0.7693465 0.7693285 0.7693102 0.7692917 0.7692729 [379] 0.7692539 0.7692347 0.7692152 0.7691955 0.7691756 0.7691554 0.7691350 [386] 0.7691144 0.7690935 0.7690724 0.7690511 0.7690296 0.7690078 0.7689858 [393] 0.7689635 0.7689410 0.7689183 0.7688954 0.7688722 0.7688488 0.7688252 [400] 0.7688013 0.7687772 > mx [1] 0.7700063 > mxli [1] 1 > 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/1y1i91257953189.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/2o4631257953189.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/3ll5p1257953189.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/4mw1t1257953189.tab") > system("convert tmp/1y1i91257953189.ps tmp/1y1i91257953189.png") > system("convert tmp/2o4631257953189.ps tmp/2o4631257953189.png") > system("convert tmp/3ll5p1257953189.ps tmp/3ll5p1257953189.png") > > > proc.time() user system elapsed 1.304 0.886 1.691