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.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) > x <- 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) > #'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.13314167 0.13286934 0.13259661 0.13232349 0.13204998 0.13177608 [7] 0.13150179 0.13122711 0.13095205 0.13067661 0.13040078 0.13012457 [13] 0.12984798 0.12957101 0.12929367 0.12901595 0.12873785 0.12845938 [19] 0.12818054 0.12790133 0.12762176 0.12734181 0.12706150 0.12678082 [25] 0.12649978 0.12621838 0.12593662 0.12565450 0.12537203 0.12508919 [31] 0.12480601 0.12452247 0.12423858 0.12395434 0.12366975 0.12338482 [37] 0.12309954 0.12281392 0.12252795 0.12224165 0.12195501 0.12166802 [43] 0.12138071 0.12109306 0.12080507 0.12051676 0.12022812 0.11993914 [49] 0.11964985 0.11936022 0.11907028 0.11878001 0.11848943 0.11819852 [55] 0.11790730 0.11761576 0.11732392 0.11703175 0.11673928 0.11644651 [61] 0.11615342 0.11586003 0.11556634 0.11527234 0.11497805 0.11468346 [67] 0.11438857 0.11409338 0.11379791 0.11350214 0.11320608 0.11290973 [73] 0.11261310 0.11231619 0.11201899 0.11172151 0.11142375 0.11112571 [79] 0.11082740 0.11052882 0.11022996 0.10993083 0.10963143 0.10933177 [85] 0.10903184 0.10873165 0.10843120 0.10813048 0.10782951 0.10752829 [91] 0.10722681 0.10692508 0.10662309 0.10632086 0.10601838 0.10571566 [97] 0.10541269 0.10510948 0.10480604 0.10450235 0.10419843 0.10389428 [103] 0.10358989 0.10328527 0.10298043 0.10267536 0.10237006 0.10206454 [109] 0.10175880 0.10145285 0.10114667 0.10084028 0.10053368 0.10022686 [115] 0.09991984 0.09961261 0.09930517 0.09899753 0.09868969 0.09838165 [121] 0.09807341 0.09776497 0.09745634 0.09714752 0.09683851 0.09652931 [127] 0.09621992 0.09591035 0.09560060 0.09529067 0.09498056 0.09467027 [133] 0.09435981 0.09404917 0.09373837 0.09342740 0.09311626 0.09280495 [139] 0.09249348 0.09218186 0.09187007 0.09155813 0.09124603 0.09093378 [145] 0.09062138 0.09030883 0.08999613 0.08968329 0.08937031 0.08905718 [151] 0.08874392 0.08843052 0.08811699 0.08780332 0.08748952 0.08717559 [157] 0.08686154 0.08654736 0.08623306 0.08591864 0.08560410 0.08528944 [163] 0.08497467 0.08465979 0.08434480 0.08402969 0.08371449 0.08339917 [169] 0.08308376 0.08276824 0.08245263 0.08213692 0.08182111 0.08150522 [175] 0.08118923 0.08087315 0.08055699 0.08024075 0.07992442 0.07960801 [181] 0.07929153 0.07897497 0.07865833 0.07834162 0.07802485 0.07770800 [187] 0.07739109 0.07707412 0.07675708 0.07643999 0.07612283 0.07580562 [193] 0.07548836 0.07517105 0.07485369 0.07453628 0.07421882 0.07390132 [199] 0.07358378 0.07326620 0.07294859 0.07263093 0.07231325 0.07199553 [205] 0.07167779 0.07136002 0.07104222 0.07072440 0.07040656 0.07008870 [211] 0.06977082 0.06945293 0.06913503 0.06881712 0.06849919 0.06818126 [217] 0.06786333 0.06754539 0.06722745 0.06690952 0.06659158 0.06627366 [223] 0.06595574 0.06563783 0.06531993 0.06500204 0.06468417 0.06436632 [229] 0.06404849 0.06373068 0.06341289 0.06309513 0.06277739 0.06245969 [235] 0.06214201 0.06182437 0.06150677 0.06118920 0.06087168 0.06055419 [241] 0.06023675 0.05991935 0.05960200 0.05928471 0.05896746 0.05865026 [247] 0.05833313 0.05801604 0.05769902 0.05738206 0.05706516 0.05674833 [253] 0.05643157 0.05611487 0.05579825 0.05548169 0.05516522 0.05484882 [259] 0.05453250 0.05421626 0.05390010 0.05358403 0.05326805 0.05295215 [265] 0.05263634 0.05232063 0.05200501 0.05168949 0.05137406 0.05105874 [271] 0.05074351 0.05042840 0.05011338 0.04979848 0.04948368 0.04916900 [277] 0.04885443 0.04853997 0.04822564 0.04791142 0.04759732 0.04728334 [283] 0.04696949 0.04665577 0.04634217 0.04602871 0.04571538 0.04540218 [289] 0.04508911 0.04477619 0.04446340 0.04415076 0.04383826 0.04352590 [295] 0.04321369 0.04290163 0.04258972 0.04227796 0.04196636 0.04165491 [301] 0.04134362 0.04103249 0.04072152 0.04041071 0.04010007 0.03978959 [307] 0.03947929 0.03916915 0.03885918 0.03854939 0.03823978 0.03793034 [313] 0.03762108 0.03731200 0.03700310 0.03669439 0.03638586 0.03607752 [319] 0.03576937 0.03546142 0.03515365 0.03484608 0.03453870 0.03423152 [325] 0.03392455 0.03361777 0.03331120 0.03300483 0.03269866 0.03239271 [331] 0.03208696 0.03178143 0.03147611 0.03117100 0.03086611 0.03056143 [337] 0.03025698 0.02995275 0.02964874 0.02934495 0.02904139 0.02873806 [343] 0.02843496 0.02813209 0.02782945 0.02752704 0.02722487 0.02692294 [349] 0.02662124 0.02631979 0.02601857 0.02571761 0.02541688 0.02511640 [355] 0.02481617 0.02451619 0.02421646 0.02391699 0.02361776 0.02331879 [361] 0.02302008 0.02272163 0.02242344 0.02212551 0.02182784 0.02153044 [367] 0.02123331 0.02093644 0.02063984 0.02034351 0.02004745 0.01975166 [373] 0.01945615 0.01916092 0.01886596 0.01857129 0.01827689 0.01798278 [379] 0.01768894 0.01739540 0.01710214 0.01680916 0.01651648 0.01622409 [385] 0.01593198 0.01564017 0.01534866 0.01505744 0.01476651 0.01447589 [391] 0.01418557 0.01389554 0.01360582 0.01331640 0.01302729 0.01273848 [397] 0.01244998 0.01216179 0.01187391 0.01158635 0.01129909 > mx [1] 0.1331417 > 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/118gz1194694631.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/2hcok1194694631.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/3pv3e1194694631.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/43pol1194694631.tab") > > system("convert tmp/118gz1194694631.ps tmp/118gz1194694631.png") > system("convert tmp/2hcok1194694631.ps tmp/2hcok1194694631.png") > system("convert tmp/3pv3e1194694631.ps tmp/3pv3e1194694631.png") > > > proc.time() user system elapsed 1.037 0.508 1.205