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(122.5,122.4,121.9,122.2,123.7,122.6,115.7,116.1,120.5,122.6,119.9,120.7,120.2,122.1,119.3,121.7,113.5,123.7,123.4,126.4,124.1,125.6,124.8,123,126.9,127.3,129,126.2,125.4,126.3,126.3,128.4,127.2,128.5,129,128.9,128.3,124.6,126.2,129.1,127.3,129.2,130.4,125.9,135.8,126.4,129.5,128.4,125.6,127.7,126.4,124.2,126.4,123.7,121.8,124,122.7,122.9,121,122.8,122.9) > x <- c(80.2,74.8,77.8,73,72,75.8,72.6,71.9,74.8,72.9,72.9,79.9,74,76,69.6,77.3,75.2,75.8,77.6,76.7,77,77.9,76.7,71.9,73.4,72.5,73.7,69.5,74.7,72.5,72.1,70.7,71.4,69.5,73.5,72.4,74.5,72.2,73,73.3,71.3,73.6,71.3,71.2,81.4,76.1,71.1,75.7,70,68.5,56.7,57.9,58.8,59.3,61.3,62.9,61.4,64.5,63.8,61.6,64.7) > #'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.05025613 0.05026867 0.05028119 0.05029368 0.05030615 0.05031859 [7] 0.05033101 0.05034340 0.05035576 0.05036810 0.05038042 0.05039271 [13] 0.05040497 0.05041721 0.05042943 0.05044162 0.05045378 0.05046592 [19] 0.05047803 0.05049012 0.05050219 0.05051423 0.05052624 0.05053823 [25] 0.05055020 0.05056214 0.05057405 0.05058595 0.05059781 0.05060966 [31] 0.05062147 0.05063327 0.05064504 0.05065678 0.05066850 0.05068020 [37] 0.05069187 0.05070352 0.05071514 0.05072674 0.05073832 0.05074987 [43] 0.05076140 0.05077290 0.05078439 0.05079584 0.05080727 0.05081868 [49] 0.05083007 0.05084143 0.05085277 0.05086408 0.05087537 0.05088664 [55] 0.05089789 0.05090911 0.05092030 0.05093148 0.05094263 0.05095376 [61] 0.05096486 0.05097594 0.05098700 0.05099803 0.05100905 0.05102004 [67] 0.05103100 0.05104195 0.05105287 0.05106376 0.05107464 0.05108549 [73] 0.05109632 0.05110713 0.05111792 0.05112868 0.05113942 0.05115014 [79] 0.05116083 0.05117150 0.05118216 0.05119278 0.05120339 0.05121397 [85] 0.05122454 0.05123508 0.05124560 0.05125609 0.05126657 0.05127702 [91] 0.05128745 0.05129786 0.05130825 0.05131862 0.05132896 0.05133928 [97] 0.05134958 0.05135986 0.05137012 0.05138036 0.05139058 0.05140077 [103] 0.05141095 0.05142110 0.05143123 0.05144134 0.05145143 0.05146150 [109] 0.05147155 0.05148158 0.05149158 0.05150157 0.05151153 0.05152148 [115] 0.05153140 0.05154130 0.05155119 0.05156105 0.05157089 0.05158071 [121] 0.05159051 0.05160030 0.05161006 0.05161980 0.05162952 0.05163922 [127] 0.05164890 0.05165856 0.05166820 0.05167783 0.05168743 0.05169701 [133] 0.05170657 0.05171612 0.05172564 0.05173514 0.05174463 0.05175409 [139] 0.05176354 0.05177297 0.05178237 0.05179176 0.05180113 0.05181048 [145] 0.05181981 0.05182912 0.05183842 0.05184769 0.05185695 0.05186619 [151] 0.05187540 0.05188460 0.05189379 0.05190295 0.05191209 0.05192122 [157] 0.05193033 0.05193942 0.05194849 0.05195754 0.05196658 0.05197559 [163] 0.05198459 0.05199357 0.05200254 0.05201148 0.05202041 0.05202932 [169] 0.05203821 0.05204708 0.05205594 0.05206478 0.05207360 0.05208241 [175] 0.05209120 0.05209997 0.05210872 0.05211746 0.05212617 0.05213488 [181] 0.05214356 0.05215223 0.05216088 0.05216951 0.05217813 0.05218673 [187] 0.05219532 0.05220388 0.05221244 0.05222097 0.05222949 0.05223799 [193] 0.05224648 0.05225495 0.05226340 0.05227184 0.05228026 0.05228866 [199] 0.05229705 0.05230543 0.05231378 0.05232213 0.05233045 0.05233876 [205] 0.05234706 0.05235534 0.05236360 0.05237185 0.05238008 0.05238830 [211] 0.05239651 0.05240469 0.05241287 0.05242102 0.05242917 0.05243730 [217] 0.05244541 0.05245351 0.05246159 0.05246966 0.05247771 0.05248575 [223] 0.05249378 0.05250179 0.05250979 0.05251777 0.05252574 0.05253369 [229] 0.05254163 0.05254956 0.05255747 0.05256537 0.05257325 0.05258112 [235] 0.05258898 0.05259682 0.05260465 0.05261247 0.05262027 0.05262806 [241] 0.05263583 0.05264360 0.05265134 0.05265908 0.05266680 0.05267451 [247] 0.05268221 0.05268989 0.05269756 0.05270522 0.05271287 0.05272050 [253] 0.05272812 0.05273573 0.05274332 0.05275091 0.05275848 0.05276604 [259] 0.05277358 0.05278112 0.05278864 0.05279615 0.05280365 0.05281113 [265] 0.05281861 0.05282607 0.05283352 0.05284096 0.05284838 0.05285580 [271] 0.05286320 0.05287060 0.05287798 0.05288535 0.05289271 0.05290006 [277] 0.05290739 0.05291472 0.05292204 0.05292934 0.05293663 0.05294392 [283] 0.05295119 0.05295845 0.05296570 0.05297294 0.05298017 0.05298739 [289] 0.05299460 0.05300180 0.05300899 0.05301617 0.05302334 0.05303050 [295] 0.05303765 0.05304479 0.05305192 0.05305904 0.05306615 0.05307325 [301] 0.05308034 0.05308742 0.05309449 0.05310156 0.05310861 0.05311566 [307] 0.05312269 0.05312972 0.05313674 0.05314375 0.05315075 0.05315774 [313] 0.05316472 0.05317170 0.05317866 0.05318562 0.05319257 0.05319951 [319] 0.05320644 0.05321337 0.05322028 0.05322719 0.05323409 0.05324098 [325] 0.05324787 0.05325474 0.05326161 0.05326847 0.05327532 0.05328217 [331] 0.05328901 0.05329584 0.05330266 0.05330948 0.05331629 0.05332309 [337] 0.05332989 0.05333667 0.05334346 0.05335023 0.05335700 0.05336376 [343] 0.05337051 0.05337726 0.05338400 0.05339073 0.05339746 0.05340418 [349] 0.05341090 0.05341761 0.05342431 0.05343101 0.05343770 0.05344439 [355] 0.05345107 0.05345774 0.05346441 0.05347107 0.05347773 0.05348438 [361] 0.05349103 0.05349767 0.05350430 0.05351093 0.05351756 0.05352418 [367] 0.05353080 0.05353741 0.05354401 0.05355061 0.05355721 0.05356380 [373] 0.05357039 0.05357697 0.05358355 0.05359012 0.05359669 0.05360325 [379] 0.05360981 0.05361637 0.05362292 0.05362947 0.05363602 0.05364256 [385] 0.05364910 0.05365563 0.05366216 0.05366869 0.05367521 0.05368173 [391] 0.05368824 0.05369476 0.05370127 0.05370777 0.05371428 0.05372078 [397] 0.05372728 0.05373377 0.05374026 0.05374675 0.05375324 > mx [1] 0.05375324 > 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/1ej7o1258120367.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/2x7gk1258120367.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/3ic4c1258120367.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/49shd1258120367.tab") > > system("convert tmp/1ej7o1258120367.ps tmp/1ej7o1258120367.png") > system("convert tmp/2x7gk1258120367.ps tmp/2x7gk1258120367.png") > system("convert tmp/3ic4c1258120367.ps tmp/3ic4c1258120367.png") > > > proc.time() user system elapsed 0.757 0.477 1.206