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(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,107,121.6,110.7,106.3,118.6,104.6,103.5) > x <- c(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,99,100.7,115.5,100.7,109.9,114.6,85.4,100.5,114.8,116.5,112.9,102,106,105.3,118.8,106.1,109.3,117.2,92.5,104.2,112.5,122.4,113.3,100,110.7,112.8,109.8,117.3,109.1,115.9,96,99.8,116.8,115.7,99.4,94.3,91,93.2,103.1,94.1,91.8,102.7,82.6,89.1) > #'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.8327240 0.8328348 0.8329453 0.8330555 0.8331654 0.8332750 0.8333844 [8] 0.8334934 0.8336022 0.8337107 0.8338190 0.8339269 0.8340346 0.8341420 [15] 0.8342491 0.8343559 0.8344625 0.8345687 0.8346747 0.8347804 0.8348858 [22] 0.8349910 0.8350958 0.8352004 0.8353047 0.8354087 0.8355125 0.8356159 [29] 0.8357191 0.8358220 0.8359246 0.8360269 0.8361290 0.8362308 0.8363323 [36] 0.8364335 0.8365344 0.8366351 0.8367354 0.8368355 0.8369354 0.8370349 [43] 0.8371341 0.8372331 0.8373318 0.8374302 0.8375284 0.8376262 0.8377238 [50] 0.8378211 0.8379181 0.8380148 0.8381113 0.8382075 0.8383034 0.8383990 [57] 0.8384943 0.8385894 0.8386842 0.8387787 0.8388729 0.8389669 0.8390605 [64] 0.8391539 0.8392470 0.8393399 0.8394324 0.8395247 0.8396167 0.8397084 [71] 0.8397999 0.8398910 0.8399819 0.8400725 0.8401629 0.8402529 0.8403427 [78] 0.8404322 0.8405214 0.8406104 0.8406990 0.8407874 0.8408755 0.8409634 [85] 0.8410509 0.8411382 0.8412252 0.8413120 0.8413984 0.8414846 0.8415705 [92] 0.8416561 0.8417415 0.8418265 0.8419113 0.8419959 0.8420801 0.8421641 [99] 0.8422478 0.8423312 0.8424144 0.8424972 0.8425798 0.8426622 0.8427442 [106] 0.8428260 0.8429075 0.8429887 0.8430697 0.8431503 0.8432307 0.8433109 [113] 0.8433907 0.8434703 0.8435496 0.8436287 0.8437074 0.8437859 0.8438641 [120] 0.8439421 0.8440198 0.8440972 0.8441743 0.8442512 0.8443278 0.8444041 [127] 0.8444801 0.8445559 0.8446314 0.8447066 0.8447816 0.8448563 0.8449307 [134] 0.8450048 0.8450787 0.8451523 0.8452257 0.8452987 0.8453715 0.8454441 [141] 0.8455163 0.8455883 0.8456600 0.8457315 0.8458027 0.8458736 0.8459442 [148] 0.8460146 0.8460847 0.8461546 0.8462241 0.8462934 0.8463625 0.8464313 [155] 0.8464998 0.8465680 0.8466360 0.8467037 0.8467711 0.8468383 0.8469052 [162] 0.8469718 0.8470382 0.8471043 0.8471702 0.8472358 0.8473011 0.8473661 [169] 0.8474309 0.8474954 0.8475597 0.8476237 0.8476874 0.8477509 0.8478141 [176] 0.8478770 0.8479397 0.8480021 0.8480643 0.8481262 0.8481878 0.8482492 [183] 0.8483103 0.8483711 0.8484317 0.8484920 0.8485521 0.8486119 0.8486714 [190] 0.8487307 0.8487897 0.8488484 0.8489069 0.8489652 0.8490232 0.8490809 [197] 0.8491383 0.8491955 0.8492525 0.8493092 0.8493656 0.8494218 0.8494777 [204] 0.8495333 0.8495887 0.8496439 0.8496987 0.8497534 0.8498077 0.8498618 [211] 0.8499157 0.8499693 0.8500226 0.8500757 0.8501286 0.8501811 0.8502335 [218] 0.8502855 0.8503373 0.8503889 0.8504402 0.8504913 0.8505421 0.8505926 [225] 0.8506429 0.8506930 0.8507427 0.8507923 0.8508416 0.8508906 0.8509394 [232] 0.8509879 0.8510362 0.8510842 0.8511320 0.8511795 0.8512268 0.8512738 [239] 0.8513206 0.8513671 0.8514134 0.8514594 0.8515052 0.8515508 0.8515960 [246] 0.8516411 0.8516859 0.8517304 0.8517747 0.8518188 0.8518626 0.8519061 [253] 0.8519494 0.8519925 0.8520353 0.8520779 0.8521202 0.8521623 0.8522041 [260] 0.8522457 0.8522870 0.8523281 0.8523690 0.8524096 0.8524500 0.8524901 [267] 0.8525300 0.8525696 0.8526090 0.8526482 0.8526871 0.8527258 0.8527642 [274] 0.8528024 0.8528404 0.8528781 0.8529156 0.8529528 0.8529898 0.8530265 [281] 0.8530630 0.8530993 0.8531353 0.8531711 0.8532067 0.8532420 0.8532771 [288] 0.8533119 0.8533465 0.8533809 0.8534151 0.8534489 0.8534826 0.8535160 [295] 0.8535492 0.8535822 0.8536149 0.8536474 0.8536796 0.8537116 0.8537434 [302] 0.8537750 0.8538063 0.8538374 0.8538682 0.8538988 0.8539292 0.8539593 [309] 0.8539893 0.8540189 0.8540484 0.8540776 0.8541066 0.8541354 0.8541639 [316] 0.8541922 0.8542203 0.8542481 0.8542757 0.8543031 0.8543303 0.8543572 [323] 0.8543839 0.8544104 0.8544366 0.8544626 0.8544884 0.8545140 0.8545393 [330] 0.8545644 0.8545893 0.8546139 0.8546384 0.8546626 0.8546865 0.8547103 [337] 0.8547338 0.8547571 0.8547802 0.8548031 0.8548257 0.8548481 0.8548703 [344] 0.8548923 0.8549140 0.8549356 0.8549569 0.8549779 0.8549988 0.8550194 [351] 0.8550399 0.8550601 0.8550800 0.8550998 0.8551193 0.8551387 0.8551578 [358] 0.8551766 0.8551953 0.8552137 0.8552320 0.8552500 0.8552678 0.8552854 [365] 0.8553027 0.8553199 0.8553368 0.8553535 0.8553700 0.8553863 0.8554023 [372] 0.8554182 0.8554338 0.8554493 0.8554645 0.8554795 0.8554943 0.8555088 [379] 0.8555232 0.8555373 0.8555513 0.8555650 0.8555785 0.8555918 0.8556049 [386] 0.8556178 0.8556304 0.8556429 0.8556551 0.8556672 0.8556790 0.8556906 [393] 0.8557020 0.8557132 0.8557242 0.8557350 0.8557456 0.8557559 0.8557661 [400] 0.8557761 0.8557858 > mx [1] 0.8557858 > 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/1vyq51258124415.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/23d2x1258124415.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/3bi7l1258124415.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/4we9p1258124415.tab") > > system("convert tmp/1vyq51258124415.ps tmp/1vyq51258124415.png") > system("convert tmp/23d2x1258124415.ps tmp/23d2x1258124415.png") > system("convert tmp/3bi7l1258124415.ps tmp/3bi7l1258124415.png") > > > proc.time() user system elapsed 0.781 0.527 0.925