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(274412,272433,268361,268586,264768,269974,304744,309365,308347,298427,289231,291975,294912,293488,290555,284736,281818,287854,316263,325412,326011,328282,317480,317539,313737,312276,309391,302950,300316,304035,333476,337698,335932,323931,313927,314485,313218,309664,302963,298989,298423,301631,329765,335083,327616,309119,295916,291413,291542,284678,276475,272566,264981,263290,296806,303598,286994,276427,266424,267153,268381,262522,255542,253158,243803,250741,280445,285257,270976,261076,255603,260376,263903,264291,263276,262572,256167,264221,293860) > x <- c(244752,244576,241572,240541,236089,236997,264579,270349,269645,267037,258113,262813,267413,267366,264777,258863,254844,254868,277267,285351,286602,283042,276687,277915,277128,277103,275037,270150,267140,264993,287259,291186,292300,288186,281477,282656,280190,280408,276836,275216,274352,271311,289802,290726,292300,278506,269826,265861,269034,264176,255198,253353,246057,235372,258556,260993,254663,250643,243422,247105,248541,245039,237080,237085,225554,226839,247934,248333,246969,245098,246263,255765,264319,268347,273046,273963,267430,271993,292710) > #'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.8319205 0.8319834 0.8320442 0.8321042 0.8321667 0.8322294 0.8322909 [8] 0.8323519 0.8324130 0.8324735 0.8325358 0.8325965 0.8326570 0.8327179 [15] 0.8327789 0.8328384 0.8328995 0.8329594 0.8330197 0.8330796 0.8331398 [22] 0.8331999 0.8332596 0.8333192 0.8333788 0.8334385 0.8334981 0.8335576 [29] 0.8336167 0.8336759 0.8337349 0.8337938 0.8338528 0.8339116 0.8339703 [36] 0.8340289 0.8340874 0.8341457 0.8342041 0.8342624 0.8343205 0.8343785 [43] 0.8344364 0.8344942 0.8345520 0.8346096 0.8346672 0.8347246 0.8347820 [50] 0.8348393 0.8348964 0.8349535 0.8350105 0.8350674 0.8351242 0.8351809 [57] 0.8352375 0.8352940 0.8353504 0.8354067 0.8354629 0.8355190 0.8355750 [64] 0.8356310 0.8356868 0.8357425 0.8357982 0.8358537 0.8359092 0.8359645 [71] 0.8360198 0.8360750 0.8361300 0.8361850 0.8362399 0.8362947 0.8363494 [78] 0.8364039 0.8364584 0.8365128 0.8365671 0.8366214 0.8366755 0.8367295 [85] 0.8367834 0.8368372 0.8368910 0.8369446 0.8369981 0.8370516 0.8371049 [92] 0.8371582 0.8372113 0.8372644 0.8373173 0.8373702 0.8374230 0.8374756 [99] 0.8375282 0.8375807 0.8376331 0.8376854 0.8377376 0.8377897 0.8378417 [106] 0.8378936 0.8379454 0.8379971 0.8380487 0.8381002 0.8381517 0.8382030 [113] 0.8382542 0.8383054 0.8383564 0.8384073 0.8384582 0.8385089 0.8385596 [120] 0.8386102 0.8386606 0.8387110 0.8387613 0.8388114 0.8388615 0.8389115 [127] 0.8389614 0.8390112 0.8390609 0.8391105 0.8391600 0.8392094 0.8392587 [134] 0.8393079 0.8393570 0.8394060 0.8394550 0.8395038 0.8395525 0.8396012 [141] 0.8396497 0.8396981 0.8397465 0.8397947 0.8398429 0.8398909 0.8399389 [148] 0.8399868 0.8400345 0.8400822 0.8401298 0.8401773 0.8402247 0.8402719 [155] 0.8403191 0.8403662 0.8404132 0.8404601 0.8405069 0.8405536 0.8406003 [162] 0.8406468 0.8406932 0.8407395 0.8407857 0.8408319 0.8408779 0.8409238 [169] 0.8409697 0.8410154 0.8410611 0.8411066 0.8411521 0.8411974 0.8412427 [176] 0.8412879 0.8413329 0.8413779 0.8414228 0.8414676 0.8415123 0.8415568 [183] 0.8416013 0.8416457 0.8416900 0.8417342 0.8417783 0.8418223 0.8418662 [190] 0.8419101 0.8419538 0.8419974 0.8420409 0.8420844 0.8421277 0.8421709 [197] 0.8422141 0.8422571 0.8423001 0.8423429 0.8423857 0.8424283 0.8424709 [204] 0.8425133 0.8425557 0.8425980 0.8426402 0.8426822 0.8427242 0.8427661 [211] 0.8428079 0.8428496 0.8428912 0.8429327 0.8429741 0.8430154 0.8430566 [218] 0.8430977 0.8431387 0.8431796 0.8432205 0.8432612 0.8433018 0.8433424 [225] 0.8433828 0.8434231 0.8434634 0.8435035 0.8435436 0.8435835 0.8436234 [232] 0.8436632 0.8437028 0.8437424 0.8437819 0.8438212 0.8438605 0.8438997 [239] 0.8439388 0.8439778 0.8440167 0.8440555 0.8440942 0.8441328 0.8441713 [246] 0.8442097 0.8442480 0.8442862 0.8443244 0.8443624 0.8444003 0.8444381 [253] 0.8444759 0.8445135 0.8445511 0.8445885 0.8446259 0.8446631 0.8447003 [260] 0.8447373 0.8447743 0.8448112 0.8448479 0.8448846 0.8449212 0.8449577 [267] 0.8449941 0.8450304 0.8450666 0.8451027 0.8451387 0.8451746 0.8452104 [274] 0.8452461 0.8452817 0.8453172 0.8453526 0.8453880 0.8454232 0.8454583 [281] 0.8454934 0.8455283 0.8455632 0.8455979 0.8456326 0.8456671 0.8457016 [288] 0.8457359 0.8457702 0.8458044 0.8458385 0.8458724 0.8459063 0.8459401 [295] 0.8459738 0.8460074 0.8460409 0.8460743 0.8461076 0.8461408 0.8461739 [302] 0.8462069 0.8462399 0.8462727 0.8463054 0.8463381 0.8463706 0.8464030 [309] 0.8464354 0.8464676 0.8464998 0.8465318 0.8465638 0.8465957 0.8466274 [316] 0.8466591 0.8466907 0.8467222 0.8467535 0.8467848 0.8468160 0.8468471 [323] 0.8468781 0.8469090 0.8469398 0.8469705 0.8470012 0.8470317 0.8470621 [330] 0.8470924 0.8471227 0.8471528 0.8471829 0.8472128 0.8472426 0.8472724 [337] 0.8473021 0.8473316 0.8473611 0.8473905 0.8474197 0.8474489 0.8474780 [344] 0.8475070 0.8475359 0.8475647 0.8475934 0.8476220 0.8476505 0.8476789 [351] 0.8477072 0.8477354 0.8477636 0.8477916 0.8478195 0.8478474 0.8478751 [358] 0.8479028 0.8479303 0.8479578 0.8479851 0.8480124 0.8480396 0.8480667 [365] 0.8480936 0.8481205 0.8481473 0.8481740 0.8482006 0.8482271 0.8482535 [372] 0.8482798 0.8483060 0.8483322 0.8483582 0.8483841 0.8484100 0.8484357 [379] 0.8484613 0.8484869 0.8485123 0.8485377 0.8485630 0.8485881 0.8486132 [386] 0.8486382 0.8486631 0.8486879 0.8487126 0.8487371 0.8487617 0.8487861 [393] 0.8488104 0.8488346 0.8488587 0.8488827 0.8489067 0.8489305 0.8489542 [400] 0.8489779 0.8490014 > mx [1] 0.8490014 > 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/16jvf1257943304.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/2rd2a1257943304.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/3cty31257943304.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/45ygl1257943304.tab") > system("convert tmp/16jvf1257943304.ps tmp/16jvf1257943304.png") > system("convert tmp/2rd2a1257943304.ps tmp/2rd2a1257943304.png") > system("convert tmp/3cty31257943304.ps tmp/3cty31257943304.png") > > > proc.time() user system elapsed 0.785 0.492 0.914