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(71.7,77.5,89.8,80.3,78.7,93.8,57.6,60.6,91,85.3,77.4,77.3,68.3,69.9,81.7,75.1,69.9,84,54.3,60,89.9,77,85.3,77.6,69.2,75.5,85.7,72.2,79.9,85.3,52.2,61.2,82.4,85.4,78.2,70.2,70.2,69.3,77.5,66.1,69,79.2,56.2,63.3,77.8,92,78.1,65.1,71.1,70.9,72,81.9,70.6,72.5,65.1,54.9,80,77.4,59.6,57.4,50.8) > x <- c(100.6,104.3,120.4,107.5,102.9,125.6,107.5,108.8,128.4,121.1,119.5,128.7,108.7,105.5,119.8,111.3,110.6,120.1,97.5,107.7,127.3,117.2,119.8,116.2,111,112.4,130.6,109.1,118.8,123.9,101.6,112.8,128,129.6,125.8,119.5,115.7,113.6,129.7,112,116.8,127,112.1,114.2,121.1,131.6,125,120.4,117.7,117.5,120.6,127.5,112.3,124.5,115.2,104.7,130.9,129.2,113.5,125.6,107.6) > #'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.6372563 0.6373161 0.6373758 0.6374354 0.6374949 0.6375542 0.6376134 [8] 0.6376725 0.6377315 0.6377903 0.6378491 0.6379077 0.6379662 0.6380246 [15] 0.6380828 0.6381409 0.6381990 0.6382568 0.6383146 0.6383723 0.6384298 [22] 0.6384872 0.6385445 0.6386016 0.6386587 0.6387156 0.6387724 0.6388291 [29] 0.6388857 0.6389421 0.6389984 0.6390546 0.6391107 0.6391666 0.6392225 [36] 0.6392782 0.6393338 0.6393893 0.6394446 0.6394998 0.6395550 0.6396099 [43] 0.6396648 0.6397196 0.6397742 0.6398287 0.6398831 0.6399373 0.6399915 [50] 0.6400455 0.6400994 0.6401532 0.6402068 0.6402603 0.6403138 0.6403671 [57] 0.6404202 0.6404733 0.6405262 0.6405790 0.6406317 0.6406843 0.6407367 [64] 0.6407890 0.6408412 0.6408933 0.6409453 0.6409971 0.6410488 0.6411004 [71] 0.6411519 0.6412033 0.6412545 0.6413056 0.6413566 0.6414075 0.6414582 [78] 0.6415088 0.6415593 0.6416097 0.6416600 0.6417101 0.6417601 0.6418100 [85] 0.6418598 0.6419095 0.6419590 0.6420084 0.6420577 0.6421069 0.6421559 [92] 0.6422049 0.6422537 0.6423024 0.6423509 0.6423994 0.6424477 0.6424959 [99] 0.6425440 0.6425919 0.6426398 0.6426875 0.6427351 0.6427826 0.6428299 [106] 0.6428772 0.6429243 0.6429713 0.6430181 0.6430649 0.6431115 0.6431580 [113] 0.6432044 0.6432507 0.6432968 0.6433428 0.6433887 0.6434345 0.6434802 [120] 0.6435257 0.6435711 0.6436164 0.6436616 0.6437067 0.6437516 0.6437964 [127] 0.6438411 0.6438857 0.6439301 0.6439745 0.6440187 0.6440628 0.6441067 [134] 0.6441506 0.6441943 0.6442379 0.6442814 0.6443248 0.6443680 0.6444111 [141] 0.6444541 0.6444970 0.6445398 0.6445824 0.6446249 0.6446673 0.6447096 [148] 0.6447518 0.6447938 0.6448357 0.6448775 0.6449192 0.6449607 0.6450022 [155] 0.6450435 0.6450847 0.6451258 0.6451667 0.6452075 0.6452482 0.6452888 [162] 0.6453293 0.6453697 0.6454099 0.6454500 0.6454900 0.6455299 0.6455696 [169] 0.6456092 0.6456488 0.6456881 0.6457274 0.6457666 0.6458056 0.6458445 [176] 0.6458833 0.6459220 0.6459605 0.6459989 0.6460373 0.6460754 0.6461135 [183] 0.6461515 0.6461893 0.6462270 0.6462646 0.6463021 0.6463394 0.6463766 [190] 0.6464138 0.6464508 0.6464876 0.6465244 0.6465610 0.6465975 0.6466339 [197] 0.6466702 0.6467064 0.6467424 0.6467783 0.6468141 0.6468498 0.6468853 [204] 0.6469208 0.6469561 0.6469913 0.6470264 0.6470614 0.6470962 0.6471309 [211] 0.6471655 0.6472000 0.6472344 0.6472686 0.6473028 0.6473368 0.6473707 [218] 0.6474044 0.6474381 0.6474716 0.6475051 0.6475384 0.6475715 0.6476046 [225] 0.6476375 0.6476704 0.6477031 0.6477357 0.6477681 0.6478005 0.6478327 [232] 0.6478648 0.6478968 0.6479287 0.6479605 0.6479921 0.6480236 0.6480550 [239] 0.6480863 0.6481175 0.6481485 0.6481795 0.6482103 0.6482410 0.6482716 [246] 0.6483020 0.6483324 0.6483626 0.6483927 0.6484227 0.6484526 0.6484823 [253] 0.6485120 0.6485415 0.6485709 0.6486002 0.6486294 0.6486584 0.6486873 [260] 0.6487162 0.6487449 0.6487734 0.6488019 0.6488303 0.6488585 0.6488866 [267] 0.6489146 0.6489425 0.6489703 0.6489979 0.6490254 0.6490528 0.6490801 [274] 0.6491073 0.6491344 0.6491613 0.6491882 0.6492149 0.6492415 0.6492680 [281] 0.6492943 0.6493206 0.6493467 0.6493727 0.6493986 0.6494244 0.6494501 [288] 0.6494756 0.6495011 0.6495264 0.6495516 0.6495767 0.6496017 0.6496265 [295] 0.6496513 0.6496759 0.6497004 0.6497248 0.6497491 0.6497733 0.6497973 [302] 0.6498212 0.6498451 0.6498688 0.6498924 0.6499158 0.6499392 0.6499624 [309] 0.6499856 0.6500086 0.6500315 0.6500543 0.6500769 0.6500995 0.6501219 [316] 0.6501442 0.6501665 0.6501886 0.6502105 0.6502324 0.6502542 0.6502758 [323] 0.6502973 0.6503187 0.6503400 0.6503612 0.6503823 0.6504032 0.6504241 [330] 0.6504448 0.6504654 0.6504859 0.6505063 0.6505266 0.6505467 0.6505668 [337] 0.6505867 0.6506065 0.6506262 0.6506458 0.6506653 0.6506847 0.6507039 [344] 0.6507231 0.6507421 0.6507610 0.6507798 0.6507985 0.6508171 0.6508355 [351] 0.6508539 0.6508721 0.6508903 0.6509083 0.6509262 0.6509440 0.6509616 [358] 0.6509792 0.6509967 0.6510140 0.6510312 0.6510483 0.6510653 0.6510822 [365] 0.6510990 0.6511157 0.6511322 0.6511487 0.6511650 0.6511812 0.6511973 [372] 0.6512133 0.6512292 0.6512450 0.6512607 0.6512762 0.6512917 0.6513070 [379] 0.6513222 0.6513373 0.6513523 0.6513672 0.6513820 0.6513967 0.6514112 [386] 0.6514257 0.6514400 0.6514542 0.6514683 0.6514823 0.6514962 0.6515100 [393] 0.6515237 0.6515373 0.6515507 0.6515641 0.6515773 0.6515904 0.6516034 [400] 0.6516163 0.6516291 > mx [1] 0.6516291 > 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/rcomp/tmp/17d021258122991.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/2cg6p1258122991.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/378x51258122991.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/49rz31258122991.tab") > > system("convert tmp/17d021258122991.ps tmp/17d021258122991.png") > system("convert tmp/2cg6p1258122991.ps tmp/2cg6p1258122991.png") > system("convert tmp/378x51258122991.ps tmp/378x51258122991.png") > > > proc.time() user system elapsed 0.789 0.520 0.924