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(97.9,96.6,96.2,95.8,96,96.2,96.5,95.4,96.2,96.8,97,97.1,96.6,95.8,96.2,96,95.9,95.8,96,96.2,96.8,96.9,97.2,98.9,98.9,98.8,99,99.6,99.9,100.1,99.9,100.5,100.7,101.3,101.3,101.7,103,104.7,104.5,104.6,104.2,104.5,104.8,104.7,104.6,104.5,104.7,104.8,106.2,105.6,104.5,104.2,104.1,103.3,103.8,103.3,103.7,103.5,103.7,103.4,102.8) > x <- c(103.5,103.2,103.1,102.9,102.9,102.9,103.2,103,103.7,104.2,104.7,104.8,104.9,104.8,104.6,104.6,105.2,105.2,105.4,106.1,107.6,107.9,107.9,108.8,109.6,109.5,109.4,109.9,110.7,110,110.4,110.7,110.9,111.2,111.9,112.7,114.1,114.3,114.6,115,115.6,115.6,116.2,116,116.2,116.3,116.1,116.6,116.5,115.7,114.8,114.3,115.2,115.2,114.7,113.8,114.2,114.2,114.1,113.8,113.9) > #'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.9656288 0.9656569 0.9656851 0.9657132 0.9657413 0.9657693 0.9657974 [8] 0.9658254 0.9658534 0.9658814 0.9659094 0.9659373 0.9659652 0.9659931 [15] 0.9660210 0.9660488 0.9660766 0.9661044 0.9661322 0.9661599 0.9661877 [22] 0.9662154 0.9662431 0.9662707 0.9662984 0.9663260 0.9663536 0.9663811 [29] 0.9664087 0.9664362 0.9664637 0.9664912 0.9665186 0.9665460 0.9665734 [36] 0.9666008 0.9666282 0.9666555 0.9666828 0.9667101 0.9667374 0.9667646 [43] 0.9667919 0.9668191 0.9668462 0.9668734 0.9669005 0.9669276 0.9669547 [50] 0.9669818 0.9670088 0.9670358 0.9670628 0.9670898 0.9671167 0.9671436 [57] 0.9671705 0.9671974 0.9672242 0.9672511 0.9672779 0.9673047 0.9673314 [64] 0.9673581 0.9673849 0.9674115 0.9674382 0.9674648 0.9674915 0.9675181 [71] 0.9675446 0.9675712 0.9675977 0.9676242 0.9676507 0.9676771 0.9677036 [78] 0.9677300 0.9677564 0.9677827 0.9678091 0.9678354 0.9678617 0.9678879 [85] 0.9679142 0.9679404 0.9679666 0.9679928 0.9680189 0.9680450 0.9680712 [92] 0.9680972 0.9681233 0.9681493 0.9681753 0.9682013 0.9682273 0.9682532 [99] 0.9682791 0.9683050 0.9683309 0.9683568 0.9683826 0.9684084 0.9684342 [106] 0.9684599 0.9684856 0.9685113 0.9685370 0.9685627 0.9685883 0.9686139 [113] 0.9686395 0.9686651 0.9686906 0.9687161 0.9687416 0.9687671 0.9687925 [120] 0.9688180 0.9688434 0.9688687 0.9688941 0.9689194 0.9689447 0.9689700 [127] 0.9689953 0.9690205 0.9690457 0.9690709 0.9690961 0.9691212 0.9691463 [134] 0.9691714 0.9691965 0.9692215 0.9692466 0.9692716 0.9692965 0.9693215 [141] 0.9693464 0.9693713 0.9693962 0.9694211 0.9694459 0.9694707 0.9694955 [148] 0.9695202 0.9695450 0.9695697 0.9695944 0.9696191 0.9696437 0.9696683 [155] 0.9696929 0.9697175 0.9697420 0.9697666 0.9697911 0.9698155 0.9698400 [162] 0.9698644 0.9698888 0.9699132 0.9699376 0.9699619 0.9699862 0.9700105 [169] 0.9700348 0.9700590 0.9700832 0.9701074 0.9701316 0.9701557 0.9701798 [176] 0.9702039 0.9702280 0.9702520 0.9702761 0.9703001 0.9703240 0.9703480 [183] 0.9703719 0.9703958 0.9704197 0.9704436 0.9704674 0.9704912 0.9705150 [190] 0.9705388 0.9705625 0.9705862 0.9706099 0.9706336 0.9706572 0.9706808 [197] 0.9707044 0.9707280 0.9707515 0.9707751 0.9707986 0.9708220 0.9708455 [204] 0.9708689 0.9708923 0.9709157 0.9709390 0.9709624 0.9709857 0.9710090 [211] 0.9710322 0.9710555 0.9710787 0.9711019 0.9711250 0.9711482 0.9711713 [218] 0.9711944 0.9712174 0.9712405 0.9712635 0.9712865 0.9713095 0.9713324 [225] 0.9713553 0.9713782 0.9714011 0.9714239 0.9714468 0.9714696 0.9714924 [232] 0.9715151 0.9715378 0.9715605 0.9715832 0.9716059 0.9716285 0.9716511 [239] 0.9716737 0.9716963 0.9717188 0.9717413 0.9717638 0.9717863 0.9718087 [246] 0.9718311 0.9718535 0.9718759 0.9718982 0.9719206 0.9719428 0.9719651 [253] 0.9719874 0.9720096 0.9720318 0.9720540 0.9720761 0.9720982 0.9721203 [260] 0.9721424 0.9721645 0.9721865 0.9722085 0.9722305 0.9722524 0.9722744 [267] 0.9722963 0.9723182 0.9723400 0.9723619 0.9723837 0.9724055 0.9724272 [274] 0.9724490 0.9724707 0.9724924 0.9725140 0.9725357 0.9725573 0.9725789 [281] 0.9726004 0.9726220 0.9726435 0.9726650 0.9726865 0.9727079 0.9727293 [288] 0.9727507 0.9727721 0.9727935 0.9728148 0.9728361 0.9728574 0.9728786 [295] 0.9728998 0.9729211 0.9729422 0.9729634 0.9729845 0.9730056 0.9730267 [302] 0.9730478 0.9730688 0.9730898 0.9731108 0.9731317 0.9731527 0.9731736 [309] 0.9731945 0.9732153 0.9732362 0.9732570 0.9732778 0.9732986 0.9733193 [316] 0.9733400 0.9733607 0.9733814 0.9734020 0.9734226 0.9734432 0.9734638 [323] 0.9734843 0.9735049 0.9735254 0.9735458 0.9735663 0.9735867 0.9736071 [330] 0.9736275 0.9736478 0.9736681 0.9736884 0.9737087 0.9737290 0.9737492 [337] 0.9737694 0.9737896 0.9738097 0.9738299 0.9738500 0.9738701 0.9738901 [344] 0.9739101 0.9739301 0.9739501 0.9739701 0.9739900 0.9740099 0.9740298 [351] 0.9740497 0.9740695 0.9740893 0.9741091 0.9741289 0.9741486 0.9741683 [358] 0.9741880 0.9742077 0.9742273 0.9742469 0.9742665 0.9742861 0.9743056 [365] 0.9743251 0.9743446 0.9743641 0.9743835 0.9744030 0.9744224 0.9744417 [372] 0.9744611 0.9744804 0.9744997 0.9745190 0.9745382 0.9745574 0.9745766 [379] 0.9745958 0.9746149 0.9746341 0.9746532 0.9746722 0.9746913 0.9747103 [386] 0.9747293 0.9747483 0.9747672 0.9747862 0.9748051 0.9748239 0.9748428 [393] 0.9748616 0.9748804 0.9748992 0.9749180 0.9749367 0.9749554 0.9749741 [400] 0.9749927 0.9750114 > mx [1] 0.9750114 > 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/freestat/rcomp/tmp/1rsg71257941465.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/2s6hs1257941465.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/3eq0v1257941465.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/4sqco1257941465.tab") > > system("convert tmp/1rsg71257941465.ps tmp/1rsg71257941465.png") > system("convert tmp/2s6hs1257941465.ps tmp/2s6hs1257941465.png") > system("convert tmp/3eq0v1257941465.ps tmp/3eq0v1257941465.png") > > > proc.time() user system elapsed 1.223 0.813 1.305