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(102.7,103.2,105.6,103.9,107.2,100.7,92.1,90.3,93.4,98.5,100.8,102.3,104.7,101.1,101.4,99.5,98.4,96.3,100.7,101.2,100.3,97.8,97.4,98.6,99.7,99,98.1,97,98.5,103.8,114.4,124.5,134.2,131.8,125.6,119.9,114.9,115.5,112.5,111.4,115.3,110.8,103.7,111.1,113,111.2,117.6,121.7,127.3,129.8,137.1,141.4,137.4,130.7,117.2,110.8,111.4,108.2,108.8,110.2,109.5,109.5,116,111.2,112.1,114,119.1,114.1,115.1,115.4,110.8,116,119.2,126.5,127.8,131.3,140.3,137.3,143,134.5,139.9,159.3,170.4,175,175.8,180.9,180.3,169.6,172.3,184.8,177.7,184.6,211.4) > x <- c(105.3,103,103.8,103.4,105.8,101.4,97,94.3,96.6,97.1,95.7,96.9,97.4,95.3,93.6,91.5,93.1,91.7,94.3,93.9,90.9,88.3,91.3,91.7,92.4,92,95.6,95.8,96.4,99,107,109.7,116.2,115.9,113.8,112.6,113.7,115.9,110.3,111.3,113.4,108.2,104.8,106,110.9,115,118.4,121.4,128.8,131.7,141.7,142.9,139.4,134.7,125,113.6,111.5,108.5,112.3,116.6,115.5,120.1,132.9,128.1,129.3,132.5,131,124.9,120.8,122,122.1,127.4,135.2,137.3,135,136,138.4,134.7,138.4,133.9,133.6,141.2,151.8,155.4,156.6,161.6,160.7,156,159.5,168.7,169.9,169.9,185.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.8404592 0.8408307 0.8412022 0.8415735 0.8419447 0.8423158 0.8426867 [8] 0.8430576 0.8434282 0.8437988 0.8441692 0.8445395 0.8449096 0.8452795 [15] 0.8456494 0.8460190 0.8463886 0.8467579 0.8471271 0.8474962 0.8478651 [22] 0.8482338 0.8486023 0.8489707 0.8493389 0.8497070 0.8500748 0.8504425 [29] 0.8508100 0.8511773 0.8515444 0.8519114 0.8522781 0.8526447 0.8530110 [36] 0.8533772 0.8537432 0.8541089 0.8544745 0.8548398 0.8552049 0.8555699 [43] 0.8559346 0.8562991 0.8566633 0.8570274 0.8573912 0.8577548 0.8581181 [50] 0.8584813 0.8588442 0.8592068 0.8595692 0.8599314 0.8602933 0.8606550 [57] 0.8610164 0.8613776 0.8617385 0.8620992 0.8624596 0.8628197 0.8631796 [64] 0.8635392 0.8638986 0.8642576 0.8646164 0.8649749 0.8653331 0.8656911 [71] 0.8660487 0.8664061 0.8667632 0.8671200 0.8674764 0.8678326 0.8681885 [78] 0.8685441 0.8688994 0.8692543 0.8696090 0.8699633 0.8703173 0.8706710 [85] 0.8710244 0.8713774 0.8717302 0.8720825 0.8724346 0.8727863 0.8731377 [92] 0.8734887 0.8738394 0.8741898 0.8745398 0.8748894 0.8752387 0.8755876 [99] 0.8759362 0.8762844 0.8766322 0.8769797 0.8773268 0.8776735 0.8780199 [106] 0.8783659 0.8787115 0.8790567 0.8794015 0.8797459 0.8800899 0.8804336 [113] 0.8807768 0.8811196 0.8814621 0.8818041 0.8821457 0.8824869 0.8828277 [120] 0.8831681 0.8835080 0.8838476 0.8841867 0.8845253 0.8848636 0.8852014 [127] 0.8855387 0.8858757 0.8862122 0.8865482 0.8868838 0.8872189 0.8875536 [134] 0.8878879 0.8882216 0.8885549 0.8888878 0.8892202 0.8895521 0.8898835 [141] 0.8902145 0.8905449 0.8908749 0.8912045 0.8915335 0.8918620 0.8921901 [148] 0.8925176 0.8928447 0.8931712 0.8934973 0.8938228 0.8941478 0.8944723 [155] 0.8947963 0.8951198 0.8954428 0.8957652 0.8960871 0.8964085 0.8967294 [162] 0.8970497 0.8973695 0.8976887 0.8980074 0.8983256 0.8986432 0.8989602 [169] 0.8992767 0.8995927 0.8999081 0.9002229 0.9005371 0.9008508 0.9011639 [176] 0.9014765 0.9017885 0.9020998 0.9024107 0.9027209 0.9030305 0.9033396 [183] 0.9036480 0.9039559 0.9042631 0.9045698 0.9048758 0.9051813 0.9054861 [190] 0.9057903 0.9060939 0.9063969 0.9066993 0.9070010 0.9073022 0.9076027 [197] 0.9079025 0.9082018 0.9085003 0.9087983 0.9090956 0.9093923 0.9096883 [204] 0.9099836 0.9102784 0.9105724 0.9108658 0.9111585 0.9114506 0.9117420 [211] 0.9120328 0.9123228 0.9126122 0.9129009 0.9131890 0.9134763 0.9137630 [218] 0.9140489 0.9143342 0.9146188 0.9149027 0.9151859 0.9154684 0.9157502 [225] 0.9160313 0.9163117 0.9165913 0.9168703 0.9171485 0.9174260 0.9177028 [232] 0.9179789 0.9182542 0.9185288 0.9188027 0.9190758 0.9193482 0.9196199 [239] 0.9198908 0.9201609 0.9204304 0.9206990 0.9209669 0.9212341 0.9215005 [246] 0.9217662 0.9220310 0.9222951 0.9225585 0.9228211 0.9230829 0.9233439 [253] 0.9236041 0.9238636 0.9241223 0.9243802 0.9246373 0.9248936 0.9251491 [260] 0.9254038 0.9256578 0.9259109 0.9261632 0.9264147 0.9266654 0.9269153 [267] 0.9271644 0.9274127 0.9276602 0.9279068 0.9281526 0.9283976 0.9286418 [274] 0.9288851 0.9291276 0.9293693 0.9296101 0.9298501 0.9300892 0.9303275 [281] 0.9305650 0.9308016 0.9310374 0.9312723 0.9315064 0.9317396 0.9319719 [288] 0.9322034 0.9324340 0.9326638 0.9328927 0.9331207 0.9333478 0.9335741 [295] 0.9337995 0.9340240 0.9342476 0.9344704 0.9346923 0.9349132 0.9351333 [302] 0.9353525 0.9355708 0.9357883 0.9360048 0.9362204 0.9364351 0.9366489 [309] 0.9368618 0.9370738 0.9372849 0.9374951 0.9377043 0.9379127 0.9381201 [316] 0.9383266 0.9385322 0.9387369 0.9389406 0.9391434 0.9393453 0.9395462 [323] 0.9397463 0.9399453 0.9401435 0.9403407 0.9405369 0.9407323 0.9409266 [330] 0.9411201 0.9413126 0.9415041 0.9416947 0.9418843 0.9420730 0.9422607 [337] 0.9424475 0.9426333 0.9428181 0.9430020 0.9431849 0.9433668 0.9435478 [344] 0.9437278 0.9439068 0.9440849 0.9442620 0.9444381 0.9446132 0.9447874 [351] 0.9449605 0.9451327 0.9453039 0.9454741 0.9456434 0.9458116 0.9459788 [358] 0.9461451 0.9463103 0.9464746 0.9466379 0.9468001 0.9469614 0.9471217 [365] 0.9472809 0.9474392 0.9475965 0.9477527 0.9479079 0.9480622 0.9482154 [372] 0.9483676 0.9485188 0.9486690 0.9488182 0.9489663 0.9491134 0.9492595 [379] 0.9494046 0.9495487 0.9496917 0.9498338 0.9499748 0.9501147 0.9502537 [386] 0.9503916 0.9505285 0.9506643 0.9507991 0.9509329 0.9510657 0.9511974 [393] 0.9513280 0.9514577 0.9515863 0.9517138 0.9518404 0.9519658 0.9520903 [400] 0.9522137 0.9523360 > mx [1] 0.952336 > 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/1ixti1194288931.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/2fyn21194288931.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/3ijuk1194288932.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/4e4pm1194288932.tab") > > system("convert tmp/1ixti1194288931.ps tmp/1ixti1194288931.png") > system("convert tmp/2fyn21194288931.ps tmp/2fyn21194288931.png") > system("convert tmp/3ijuk1194288932.ps tmp/3ijuk1194288932.png") > > > proc.time() user system elapsed 1.041 0.516 1.242