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(103.1,100.6,103.1,95.5,90.5,90.9,88.8,90.7,94.3,104.6,111.1,110.8,107.2,99,99,91,96.2,96.9,96.2,100.1,99,115.4,106.9,107.1,99.3,99.2,108.3,105.6,99.5,107.4,93.1,88.1,110.7,113.1,99.6,93.6,98.6,99.6,114.3,107.8,101.2,112.5,100.5,93.9,116.2,112,106.4,95.7,96,95.8,103,102.2,98.4,111.4,86.6,91.3,107.9,101.8,104.4,93.4,100.1,98.5,112.9,101.4,107.1,110.8,90.3,95.5,111.4,113,107.5,95.9,106.3,105.2,117.2,106.9,108.2,110,96.1,100.6) > #'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.5860185 0.5860896 0.5861606 0.5862316 0.5863025 0.5863734 0.5864442 [8] 0.5865149 0.5865856 0.5866563 0.5867269 0.5867974 0.5868679 0.5869383 [15] 0.5870087 0.5870790 0.5871493 0.5872195 0.5872896 0.5873597 0.5874297 [22] 0.5874997 0.5875696 0.5876395 0.5877093 0.5877791 0.5878488 0.5879184 [29] 0.5879880 0.5880575 0.5881270 0.5881964 0.5882657 0.5883350 0.5884043 [36] 0.5884735 0.5885426 0.5886117 0.5886807 0.5887496 0.5888185 0.5888874 [43] 0.5889562 0.5890249 0.5890936 0.5891622 0.5892307 0.5892992 0.5893677 [50] 0.5894361 0.5895044 0.5895727 0.5896409 0.5897090 0.5897771 0.5898452 [57] 0.5899131 0.5899811 0.5900489 0.5901167 0.5901845 0.5902522 0.5903198 [64] 0.5903874 0.5904549 0.5905224 0.5905898 0.5906571 0.5907244 0.5907916 [71] 0.5908588 0.5909259 0.5909929 0.5910599 0.5911268 0.5911937 0.5912605 [78] 0.5913273 0.5913940 0.5914606 0.5915272 0.5915937 0.5916602 0.5917266 [85] 0.5917929 0.5918592 0.5919254 0.5919916 0.5920577 0.5921237 0.5921897 [92] 0.5922556 0.5923215 0.5923873 0.5924530 0.5925187 0.5925843 0.5926499 [99] 0.5927154 0.5927809 0.5928462 0.5929116 0.5929768 0.5930420 0.5931072 [106] 0.5931723 0.5932373 0.5933023 0.5933672 0.5934320 0.5934968 0.5935615 [113] 0.5936262 0.5936908 0.5937553 0.5938198 0.5938842 0.5939486 0.5940129 [120] 0.5940771 0.5941413 0.5942054 0.5942695 0.5943335 0.5943974 0.5944613 [127] 0.5945251 0.5945888 0.5946525 0.5947161 0.5947797 0.5948432 0.5949067 [134] 0.5949700 0.5950334 0.5950966 0.5951598 0.5952230 0.5952860 0.5953491 [141] 0.5954120 0.5954749 0.5955377 0.5956005 0.5956632 0.5957258 0.5957884 [148] 0.5958509 0.5959134 0.5959758 0.5960381 0.5961004 0.5961626 0.5962248 [155] 0.5962868 0.5963489 0.5964108 0.5964727 0.5965346 0.5965963 0.5966580 [162] 0.5967197 0.5967813 0.5968428 0.5969043 0.5969656 0.5970270 0.5970883 [169] 0.5971495 0.5972106 0.5972717 0.5973327 0.5973937 0.5974546 0.5975154 [176] 0.5975762 0.5976369 0.5976975 0.5977581 0.5978186 0.5978791 0.5979395 [183] 0.5979998 0.5980600 0.5981202 0.5981804 0.5982405 0.5983005 0.5983604 [190] 0.5984203 0.5984801 0.5985399 0.5985996 0.5986592 0.5987187 0.5987782 [197] 0.5988377 0.5988971 0.5989564 0.5990156 0.5990748 0.5991339 0.5991930 [204] 0.5992519 0.5993109 0.5993697 0.5994285 0.5994873 0.5995459 0.5996045 [211] 0.5996631 0.5997215 0.5997800 0.5998383 0.5998966 0.5999548 0.6000130 [218] 0.6000710 0.6001291 0.6001870 0.6002449 0.6003028 0.6003605 0.6004182 [225] 0.6004759 0.6005334 0.6005909 0.6006484 0.6007057 0.6007631 0.6008203 [232] 0.6008775 0.6009346 0.6009917 0.6010486 0.6011056 0.6011624 0.6012192 [239] 0.6012759 0.6013326 0.6013892 0.6014457 0.6015022 0.6015586 0.6016149 [246] 0.6016712 0.6017274 0.6017835 0.6018396 0.6018956 0.6019515 0.6020074 [253] 0.6020632 0.6021190 0.6021747 0.6022303 0.6022858 0.6023413 0.6023967 [260] 0.6024521 0.6025073 0.6025626 0.6026177 0.6026728 0.6027278 0.6027828 [267] 0.6028377 0.6028925 0.6029472 0.6030019 0.6030565 0.6031111 0.6031656 [274] 0.6032200 0.6032744 0.6033287 0.6033829 0.6034370 0.6034911 0.6035452 [281] 0.6035991 0.6036530 0.6037068 0.6037606 0.6038143 0.6038679 0.6039215 [288] 0.6039750 0.6040284 0.6040818 0.6041351 0.6041883 0.6042415 0.6042945 [295] 0.6043476 0.6044005 0.6044534 0.6045063 0.6045590 0.6046117 0.6046643 [302] 0.6047169 0.6047694 0.6048218 0.6048742 0.6049264 0.6049787 0.6050308 [309] 0.6050829 0.6051349 0.6051869 0.6052388 0.6052906 0.6053424 0.6053940 [316] 0.6054457 0.6054972 0.6055487 0.6056001 0.6056515 0.6057027 0.6057539 [323] 0.6058051 0.6058562 0.6059072 0.6059581 0.6060090 0.6060598 0.6061105 [330] 0.6061612 0.6062118 0.6062624 0.6063128 0.6063632 0.6064136 0.6064638 [337] 0.6065140 0.6065642 0.6066142 0.6066642 0.6067141 0.6067640 0.6068138 [344] 0.6068635 0.6069132 0.6069628 0.6070123 0.6070617 0.6071111 0.6071604 [351] 0.6072097 0.6072589 0.6073080 0.6073570 0.6074060 0.6074549 0.6075037 [358] 0.6075525 0.6076012 0.6076498 0.6076984 0.6077469 0.6077953 0.6078437 [365] 0.6078920 0.6079402 0.6079883 0.6080364 0.6080844 0.6081324 0.6081803 [372] 0.6082281 0.6082758 0.6083235 0.6083711 0.6084186 0.6084661 0.6085135 [379] 0.6085608 0.6086081 0.6086553 0.6087024 0.6087495 0.6087965 0.6088434 [386] 0.6088902 0.6089370 0.6089837 0.6090304 0.6090770 0.6091235 0.6091699 [393] 0.6092163 0.6092626 0.6093088 0.6093550 0.6094011 0.6094471 0.6094930 [400] 0.6095389 0.6095847 > mx [1] 0.6095847 > 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/192f71194695815.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/2o79h1194695815.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/3352g1194695815.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/4352a1194695815.tab") > > system("convert tmp/192f71194695815.ps tmp/192f71194695815.png") > system("convert tmp/2o79h1194695815.ps tmp/2o79h1194695815.png") > system("convert tmp/3352g1194695815.ps tmp/3352g1194695815.png") > > > proc.time() user system elapsed 1.040 0.509 1.177