R version 2.5.1 (2007-06-27) 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(20.2,56,12.5,21.2,15.5,39,21,38.2,55.6,81.9,39.5,56.4,40.5,14.3,81.5,13.7,81.5,20.5,56,80.7,20,56.5,12.1,19.6,15.5,38.8,19.5,38,55,80,38.5,55.8,38.8,12.5,80.4,12.7,80.9,20.5,55,19,55.5,12.3,18.4,11.5,38,18.5,38,55.3,38.7,54.5,38,12,81.7,11.5,80,18.3,55.3,80.2,80.7,55.8,15,81,12,81.4,12.5,38.2,54.2,79.3,18.2,55.5,11.4,19.5,15.5,37.5,19.5,37.5,55.5,80,37.5,15.5,23.7,9.8,40.8,17.5,4.3,36.5,26.3,30.4,50.2,30.1,25.5,13.8,58.9,40,6,72.5,38.8,19.4,81.5,77.4,54.6,6.8,32.6,19.8,58.8,12.9,49) > x <- c(18,38,15,20,18,36,20,43,45,65,43,38,33,10,50,10,50,15,53,60,18,38,15,20,18,36,20,43,45,65,43,38,33,10,50,10,50,15,53,15,37,15,18,11,35,20,40,50,36,50,38,10,75,10,85,13,50,58,58,48,12,63,10,63,13,28,35,63,13,45,9,20,18,35,20,38,50,70,40,21,19,10,33,16,5,32,23,30,45,33,25,12,53,36,5,63,43,25,73,45,52,9,30,22,56,15,45) > #'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.5243095 0.5264034 0.5285044 0.5306124 0.5327272 0.5348488 0.5369771 [8] 0.5391120 0.5412533 0.5434009 0.5455548 0.5477148 0.5498809 0.5520528 [15] 0.5542305 0.5564138 0.5586027 0.5607970 0.5629965 0.5652012 0.5674109 [22] 0.5696255 0.5718448 0.5740688 0.5762972 0.5785300 0.5807670 0.5830080 [29] 0.5852529 0.5875015 0.5897538 0.5920096 0.5942686 0.5965308 0.5987960 [36] 0.6010641 0.6033348 0.6056081 0.6078837 0.6101616 0.6124415 0.6147233 [43] 0.6170068 0.6192919 0.6215784 0.6238661 0.6261548 0.6284445 0.6307348 [50] 0.6330257 0.6353170 0.6376085 0.6399000 0.6421914 0.6444825 0.6467731 [57] 0.6490630 0.6513521 0.6536402 0.6559271 0.6582126 0.6604966 0.6627789 [64] 0.6650593 0.6673377 0.6696139 0.6718876 0.6741588 0.6764272 0.6786926 [71] 0.6809550 0.6832142 0.6854698 0.6877219 0.6899702 0.6922145 0.6944548 [78] 0.6966907 0.6989222 0.7011491 0.7033711 0.7055883 0.7078003 0.7100071 [85] 0.7122084 0.7144042 0.7165942 0.7187783 0.7209563 0.7231282 0.7252937 [92] 0.7274526 0.7296050 0.7317505 0.7338890 0.7360205 0.7381447 0.7402616 [99] 0.7423709 0.7444726 0.7465665 0.7486525 0.7507305 0.7528003 0.7548617 [106] 0.7569148 0.7589593 0.7609951 0.7630222 0.7650403 0.7670494 0.7690494 [113] 0.7710402 0.7730216 0.7749935 0.7769559 0.7789087 0.7808517 0.7827848 [120] 0.7847079 0.7866211 0.7885241 0.7904169 0.7922993 0.7941714 0.7960330 [127] 0.7978841 0.7997245 0.8015542 0.8033731 0.8051812 0.8069784 0.8087646 [134] 0.8105397 0.8123038 0.8140566 0.8157982 0.8175286 0.8192476 0.8209552 [141] 0.8226513 0.8243360 0.8260091 0.8276706 0.8293205 0.8309588 0.8325853 [148] 0.8342001 0.8358031 0.8373943 0.8389736 0.8405411 0.8420967 0.8436403 [155] 0.8451720 0.8466917 0.8481995 0.8496951 0.8511788 0.8526504 0.8541099 [162] 0.8555574 0.8569927 0.8584159 0.8598270 0.8612260 0.8626129 0.8639876 [169] 0.8653501 0.8667005 0.8680388 0.8693649 0.8706788 0.8719806 0.8732702 [176] 0.8745477 0.8758130 0.8770662 0.8783073 0.8795362 0.8807530 0.8819577 [183] 0.8831504 0.8843309 0.8854993 0.8866557 0.8878000 0.8889323 0.8900526 [190] 0.8911608 0.8922571 0.8933414 0.8944137 0.8954741 0.8965226 0.8975591 [197] 0.8985838 0.8995966 0.9005976 0.9015868 0.9025641 0.9035297 0.9044835 [204] 0.9054256 0.9063560 0.9072747 0.9081818 0.9090772 0.9099610 0.9108332 [211] 0.9116938 0.9125429 0.9133805 0.9142067 0.9150214 0.9158246 0.9166165 [218] 0.9173970 0.9181661 0.9189239 0.9196705 0.9204058 0.9211298 0.9218427 [225] 0.9225443 0.9232349 0.9239143 0.9245827 0.9252400 0.9258862 0.9265215 [232] 0.9271458 0.9277592 0.9283617 0.9289533 0.9295341 0.9301041 0.9306633 [239] 0.9312117 0.9317495 0.9322765 0.9327929 0.9332987 0.9337939 0.9342785 [246] 0.9347526 0.9352162 0.9356693 0.9361121 0.9365444 0.9369663 0.9373779 [253] 0.9377793 0.9381703 0.9385511 0.9389217 0.9392822 0.9396324 0.9399726 [260] 0.9403028 0.9406228 0.9409329 0.9412330 0.9415232 0.9418034 0.9420738 [267] 0.9423343 0.9425851 0.9428260 0.9430572 0.9432788 0.9434906 0.9436928 [274] 0.9438854 0.9440684 0.9442419 0.9444059 0.9445604 0.9447055 0.9448412 [281] 0.9449675 0.9450845 0.9451922 0.9452907 0.9453799 0.9454599 0.9455308 [288] 0.9455926 0.9456452 0.9456889 0.9457235 0.9457491 0.9457658 0.9457736 [295] 0.9457725 0.9457626 0.9457439 0.9457165 0.9456803 0.9456354 0.9455819 [302] 0.9455198 0.9454490 0.9453698 0.9452820 0.9451858 0.9450812 0.9449681 [309] 0.9448467 0.9447170 0.9445790 0.9444328 0.9442784 0.9441158 0.9439451 [316] 0.9437663 0.9435794 0.9433846 0.9431818 0.9429710 0.9427523 0.9425258 [323] 0.9422915 0.9420494 0.9417996 0.9415420 0.9412769 0.9410040 0.9407237 [330] 0.9404357 0.9401403 0.9398374 0.9395271 0.9392095 0.9388844 0.9385521 [337] 0.9382126 0.9378658 0.9375118 0.9371507 0.9367825 0.9364073 0.9360250 [344] 0.9356358 0.9352397 0.9348366 0.9344267 0.9340100 0.9335866 0.9331564 [351] 0.9327195 0.9322760 0.9318259 0.9313693 0.9309061 0.9304365 0.9299604 [358] 0.9294779 0.9289891 0.9284940 0.9279926 0.9274850 0.9269713 0.9264514 [365] 0.9259254 0.9253933 0.9248552 0.9243112 0.9237613 0.9232054 0.9226438 [372] 0.9220763 0.9215031 0.9209241 0.9203395 0.9197493 0.9191534 0.9185521 [379] 0.9179452 0.9173329 0.9167151 0.9160920 0.9154636 0.9148298 0.9141908 [386] 0.9135467 0.9128973 0.9122428 0.9115833 0.9109187 0.9102491 0.9095746 [393] 0.9088951 0.9082108 0.9075217 0.9068277 0.9061291 0.9054257 0.9047177 [400] 0.9040050 0.9032878 > mx [1] 0.9457736 > mxli [1] 0.93 > 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/1nerl1192454645.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/21wrj1192454645.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/3rq9j1192454645.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/4dn2h1192454645.tab") > > system("convert tmp/1nerl1192454645.ps tmp/1nerl1192454645.png") > system("convert tmp/21wrj1192454645.ps tmp/21wrj1192454645.png") > system("convert tmp/3rq9j1192454645.ps tmp/3rq9j1192454645.png") > > > proc.time() user system elapsed 1.086 0.526 1.200