R version 2.6.0 (2007-10-03) Copyright (C) 2007 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(98.1,101.1,111.1,93.3,100,108,70.4,75.4,105.5,112.3,102.5,93.5,86.7,95.2,103.8,97,95.5,101,67.5,64,106.7,100.6,101.2,93.1,84.2,85.8,91.8,92.4,80.3,79.7,62.5,57.1,100.8,100.7,86.2,83.2,71.7,77.5,89.8,80.3,78.7,93.8,57.6,60.6,91,85.3,77.4,77.3,68.3,69.9,81.7,75.1,69.9,84,54.3,60,89.9,77,85.3,77.6,69.2,75.5,85.7,72.2,79.9,85.3,52.2,61.2,82.4,85.4,78.2,70.2,70.2,69.3,77.5,66.1,69,75.3,58.2,59.7) > x <- c(98.6,98,106.8,96.6,100.1,107.7,91.5,97.8,107.4,117.5,105.6,97.4,99.5,98,104.3,100.6,101.1,103.9,96.9,95.5,108.4,117,103.8,100.8,110.6,104,112.6,107.3,98.9,109.8,104.9,102.2,123.9,124.9,112.7,121.9,100.6,104.3,120.4,107.5,102.9,125.6,107.5,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,126.3,112.9,115.9) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2007), Box-Cox Linearity Plot (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxlin.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description > 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.03302307 0.03304503 0.03306703 0.03308908 0.03311117 0.03313331 [7] 0.03315549 0.03317772 0.03319999 0.03322231 0.03324467 0.03326708 [13] 0.03328953 0.03331203 0.03333457 0.03335715 0.03337978 0.03340246 [19] 0.03342518 0.03344794 0.03347075 0.03349360 0.03351649 0.03353943 [25] 0.03356241 0.03358544 0.03360851 0.03363163 0.03365479 0.03367799 [31] 0.03370123 0.03372452 0.03374786 0.03377123 0.03379465 0.03381811 [37] 0.03384162 0.03386517 0.03388876 0.03391240 0.03393608 0.03395980 [43] 0.03398356 0.03400737 0.03403122 0.03405511 0.03407904 0.03410302 [49] 0.03412704 0.03415110 0.03417521 0.03419935 0.03422354 0.03424777 [55] 0.03427205 0.03429636 0.03432072 0.03434512 0.03436956 0.03439404 [61] 0.03441857 0.03444313 0.03446774 0.03449239 0.03451708 0.03454181 [67] 0.03456658 0.03459140 0.03461625 0.03464115 0.03466609 0.03469107 [73] 0.03471609 0.03474115 0.03476625 0.03479139 0.03481657 0.03484179 [79] 0.03486706 0.03489236 0.03491771 0.03494309 0.03496852 0.03499398 [85] 0.03501949 0.03504503 0.03507062 0.03509624 0.03512190 0.03514761 [91] 0.03517335 0.03519914 0.03522496 0.03525082 0.03527672 0.03530267 [97] 0.03532865 0.03535467 0.03538073 0.03540682 0.03543296 0.03545914 [103] 0.03548535 0.03551161 0.03553790 0.03556423 0.03559060 0.03561701 [109] 0.03564345 0.03566994 0.03569646 0.03572302 0.03574962 0.03577626 [115] 0.03580293 0.03582965 0.03585640 0.03588319 0.03591001 0.03593688 [121] 0.03596378 0.03599072 0.03601770 0.03604471 0.03607176 0.03609885 [127] 0.03612598 0.03615314 0.03618034 0.03620758 0.03623485 0.03626216 [133] 0.03628951 0.03631689 0.03634431 0.03637177 0.03639927 0.03642679 [139] 0.03645436 0.03648196 0.03650960 0.03653728 0.03656499 0.03659273 [145] 0.03662051 0.03664833 0.03667619 0.03670407 0.03673200 0.03675996 [151] 0.03678796 0.03681599 0.03684405 0.03687215 0.03690029 0.03692846 [157] 0.03695667 0.03698491 0.03701318 0.03704149 0.03706984 0.03709822 [163] 0.03712663 0.03715508 0.03718357 0.03721208 0.03724063 0.03726922 [169] 0.03729784 0.03732649 0.03735518 0.03738390 0.03741266 0.03744144 [175] 0.03747027 0.03749912 0.03752801 0.03755693 0.03758589 0.03761488 [181] 0.03764390 0.03767295 0.03770204 0.03773116 0.03776032 0.03778950 [187] 0.03781872 0.03784797 0.03787726 0.03790657 0.03793592 0.03796530 [193] 0.03799472 0.03802416 0.03805364 0.03808315 0.03811269 0.03814226 [199] 0.03817187 0.03820150 0.03823117 0.03826087 0.03829060 0.03832036 [205] 0.03835016 0.03837998 0.03840984 0.03843973 0.03846964 0.03849959 [211] 0.03852957 0.03855958 0.03858962 0.03861969 0.03864979 0.03867992 [217] 0.03871009 0.03874028 0.03877050 0.03880075 0.03883104 0.03886135 [223] 0.03889169 0.03892206 0.03895247 0.03898290 0.03901336 0.03904385 [229] 0.03907437 0.03910492 0.03913549 0.03916610 0.03919674 0.03922740 [235] 0.03925810 0.03928882 0.03931957 0.03935035 0.03938116 0.03941199 [241] 0.03944286 0.03947375 0.03950468 0.03953563 0.03956660 0.03959761 [247] 0.03962864 0.03965971 0.03969079 0.03972191 0.03975306 0.03978423 [253] 0.03981543 0.03984665 0.03987791 0.03990919 0.03994050 0.03997183 [259] 0.04000320 0.04003458 0.04006600 0.04009744 0.04012891 0.04016041 [265] 0.04019193 0.04022348 0.04025505 0.04028665 0.04031828 0.04034993 [271] 0.04038161 0.04041332 0.04044505 0.04047680 0.04050858 0.04054039 [277] 0.04057222 0.04060408 0.04063596 0.04066787 0.04069981 0.04073176 [283] 0.04076375 0.04079576 0.04082779 0.04085985 0.04089193 0.04092404 [289] 0.04095617 0.04098832 0.04102050 0.04105271 0.04108493 0.04111719 [295] 0.04114946 0.04118176 0.04121409 0.04124643 0.04127881 0.04131120 [301] 0.04134362 0.04137606 0.04140852 0.04144101 0.04147352 0.04150606 [307] 0.04153861 0.04157119 0.04160380 0.04163642 0.04166907 0.04170174 [313] 0.04173443 0.04176715 0.04179989 0.04183265 0.04186543 0.04189823 [319] 0.04193106 0.04196391 0.04199677 0.04202967 0.04206258 0.04209551 [325] 0.04212847 0.04216145 0.04219444 0.04222746 0.04226050 0.04229356 [331] 0.04232665 0.04235975 0.04239287 0.04242602 0.04245918 0.04249237 [337] 0.04252558 0.04255880 0.04259205 0.04262532 0.04265860 0.04269191 [343] 0.04272524 0.04275859 0.04279195 0.04282534 0.04285874 0.04289217 [349] 0.04292561 0.04295908 0.04299256 0.04302606 0.04305959 0.04309313 [355] 0.04312669 0.04316026 0.04319386 0.04322748 0.04326111 0.04329476 [361] 0.04332843 0.04336212 0.04339583 0.04342956 0.04346330 0.04349706 [367] 0.04353084 0.04356464 0.04359846 0.04363229 0.04366614 0.04370001 [373] 0.04373389 0.04376779 0.04380171 0.04383565 0.04386960 0.04390358 [379] 0.04393756 0.04397157 0.04400559 0.04403963 0.04407368 0.04410775 [385] 0.04414184 0.04417594 0.04421006 0.04424420 0.04427835 0.04431252 [391] 0.04434670 0.04438090 0.04441512 0.04444935 0.04448359 0.04451785 [397] 0.04455213 0.04458642 0.04462073 0.04465505 0.04468939 > mx [1] 0.04468939 > 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/181kz1194694995.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/2oruk1194694995.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/3pnnu1194694995.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 > 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/46e9q1194694995.tab") > > system("convert tmp/181kz1194694995.ps tmp/181kz1194694995.png") > system("convert tmp/2oruk1194694995.ps tmp/2oruk1194694995.png") > system("convert tmp/3pnnu1194694995.ps tmp/3pnnu1194694995.png") > > > proc.time() user system elapsed 1.077 0.545 1.273