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(101,100.88,100.55,100.83,101.51,102.16,102.39,102.54,102.85,103.47,103.57,103.69,103.5,103.47,103.45,103.48,103.93,103.89,104.4,104.79,104.77,105.13,105.26,104.96,104.75,105.01,105.15,105.2,105.77,105.78,106.26,106.13,106.12,106.57,106.44,106.54,107.1,108.1,108.4,108.84,109.62,110.42,110.67,111.66,112.28,112.87,112.18,112.36,112.16,111.49,111.25,111.36,111.74,111.1,111.33,111.25,111.04,110.97,111.31,111.02) > x <- c(100.64,100.63,100.43,100.8,101.33,101.88,101.85,102.04,102.22,102.63,102.65,102.54,102.37,102.68,102.76,102.82,103.31,103.23,103.6,103.95,103.93,104.25,104.38,104.36,104.32,104.58,104.68,104.92,105.46,105.23,105.58,105.34,105.28,105.7,105.67,105.71,106.19,106.93,107.44,107.85,108.71,109.32,109.49,110.2,110.62,111.22,110.88,111.15,111.29,111.09,111.24,111.45,111.75,111.07,111.17,110.96,110.5,110.48,110.66,110.46) > #'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.9951530 0.9951530 0.9951530 0.9951530 0.9951529 0.9951528 0.9951527 [8] 0.9951526 0.9951525 0.9951524 0.9951522 0.9951520 0.9951518 0.9951516 [15] 0.9951514 0.9951511 0.9951508 0.9951505 0.9951502 0.9951499 0.9951496 [22] 0.9951492 0.9951488 0.9951484 0.9951480 0.9951476 0.9951471 0.9951466 [29] 0.9951462 0.9951457 0.9951451 0.9951446 0.9951440 0.9951435 0.9951429 [36] 0.9951422 0.9951416 0.9951410 0.9951403 0.9951396 0.9951389 0.9951382 [43] 0.9951375 0.9951367 0.9951359 0.9951351 0.9951343 0.9951335 0.9951327 [50] 0.9951318 0.9951309 0.9951300 0.9951291 0.9951282 0.9951272 0.9951263 [57] 0.9951253 0.9951243 0.9951233 0.9951222 0.9951212 0.9951201 0.9951190 [64] 0.9951179 0.9951168 0.9951156 0.9951145 0.9951133 0.9951121 0.9951109 [71] 0.9951096 0.9951084 0.9951071 0.9951058 0.9951045 0.9951032 0.9951019 [78] 0.9951005 0.9950991 0.9950978 0.9950963 0.9950949 0.9950935 0.9950920 [85] 0.9950905 0.9950890 0.9950875 0.9950860 0.9950844 0.9950829 0.9950813 [92] 0.9950797 0.9950781 0.9950764 0.9950748 0.9950731 0.9950714 0.9950697 [99] 0.9950680 0.9950662 0.9950645 0.9950627 0.9950609 0.9950591 0.9950573 [106] 0.9950554 0.9950536 0.9950517 0.9950498 0.9950479 0.9950459 0.9950440 [113] 0.9950420 0.9950400 0.9950380 0.9950360 0.9950340 0.9950319 0.9950298 [120] 0.9950278 0.9950256 0.9950235 0.9950214 0.9950192 0.9950170 0.9950148 [127] 0.9950126 0.9950104 0.9950082 0.9950059 0.9950036 0.9950013 0.9949990 [134] 0.9949967 0.9949943 0.9949919 0.9949896 0.9949872 0.9949847 0.9949823 [141] 0.9949799 0.9949774 0.9949749 0.9949724 0.9949699 0.9949673 0.9949648 [148] 0.9949622 0.9949596 0.9949570 0.9949544 0.9949517 0.9949491 0.9949464 [155] 0.9949437 0.9949410 0.9949382 0.9949355 0.9949327 0.9949300 0.9949272 [162] 0.9949243 0.9949215 0.9949187 0.9949158 0.9949129 0.9949100 0.9949071 [169] 0.9949042 0.9949012 0.9948982 0.9948952 0.9948922 0.9948892 0.9948862 [176] 0.9948831 0.9948801 0.9948770 0.9948739 0.9948707 0.9948676 0.9948644 [183] 0.9948613 0.9948581 0.9948549 0.9948516 0.9948484 0.9948451 0.9948419 [190] 0.9948386 0.9948353 0.9948319 0.9948286 0.9948252 0.9948219 0.9948185 [197] 0.9948151 0.9948116 0.9948082 0.9948047 0.9948012 0.9947977 0.9947942 [204] 0.9947907 0.9947871 0.9947836 0.9947800 0.9947764 0.9947728 0.9947692 [211] 0.9947655 0.9947618 0.9947582 0.9947545 0.9947507 0.9947470 0.9947433 [218] 0.9947395 0.9947357 0.9947319 0.9947281 0.9947243 0.9947204 0.9947166 [225] 0.9947127 0.9947088 0.9947049 0.9947009 0.9946970 0.9946930 0.9946890 [232] 0.9946850 0.9946810 0.9946770 0.9946729 0.9946688 0.9946648 0.9946607 [239] 0.9946565 0.9946524 0.9946483 0.9946441 0.9946399 0.9946357 0.9946315 [246] 0.9946272 0.9946230 0.9946187 0.9946144 0.9946101 0.9946058 0.9946015 [253] 0.9945971 0.9945928 0.9945884 0.9945840 0.9945796 0.9945751 0.9945707 [260] 0.9945662 0.9945617 0.9945572 0.9945527 0.9945482 0.9945436 0.9945391 [267] 0.9945345 0.9945299 0.9945253 0.9945206 0.9945160 0.9945113 0.9945066 [274] 0.9945019 0.9944972 0.9944925 0.9944877 0.9944830 0.9944782 0.9944734 [281] 0.9944686 0.9944637 0.9944589 0.9944540 0.9944492 0.9944443 0.9944393 [288] 0.9944344 0.9944295 0.9944245 0.9944195 0.9944145 0.9944095 0.9944045 [295] 0.9943995 0.9943944 0.9943893 0.9943842 0.9943791 0.9943740 0.9943689 [302] 0.9943637 0.9943585 0.9943533 0.9943481 0.9943429 0.9943377 0.9943324 [309] 0.9943271 0.9943218 0.9943165 0.9943112 0.9943059 0.9943005 0.9942952 [316] 0.9942898 0.9942844 0.9942790 0.9942735 0.9942681 0.9942626 0.9942571 [323] 0.9942516 0.9942461 0.9942406 0.9942350 0.9942295 0.9942239 0.9942183 [330] 0.9942127 0.9942070 0.9942014 0.9941957 0.9941901 0.9941844 0.9941787 [337] 0.9941729 0.9941672 0.9941614 0.9941557 0.9941499 0.9941441 0.9941382 [344] 0.9941324 0.9941266 0.9941207 0.9941148 0.9941089 0.9941030 0.9940970 [351] 0.9940911 0.9940851 0.9940791 0.9940731 0.9940671 0.9940611 0.9940551 [358] 0.9940490 0.9940429 0.9940368 0.9940307 0.9940246 0.9940184 0.9940123 [365] 0.9940061 0.9939999 0.9939937 0.9939875 0.9939813 0.9939750 0.9939687 [372] 0.9939625 0.9939562 0.9939498 0.9939435 0.9939372 0.9939308 0.9939244 [379] 0.9939180 0.9939116 0.9939052 0.9938987 0.9938923 0.9938858 0.9938793 [386] 0.9938728 0.9938663 0.9938597 0.9938532 0.9938466 0.9938400 0.9938334 [393] 0.9938268 0.9938202 0.9938135 0.9938069 0.9938002 0.9937935 0.9937868 [400] 0.9937801 0.9937733 > mx [1] 0.995153 > 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/1az4c1262104492.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/20fmz1262104492.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/3dlhi1262104492.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/484ah1262104492.tab") > > try(system("convert tmp/1az4c1262104492.ps tmp/1az4c1262104492.png",intern=TRUE)) character(0) > try(system("convert tmp/20fmz1262104492.ps tmp/20fmz1262104492.png",intern=TRUE)) character(0) > try(system("convert tmp/3dlhi1262104492.ps tmp/3dlhi1262104492.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.809 0.516 1.334