R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(101.3,106.3,94,102.8,102,105.1,92.4,81.4,105.8,120.3,100.7,88.8,94.3,99.9,103.4,103.3,98.8,104.2,91.2,74.7,108.5,114.5,96.9,89.6,97.1,100.3,122.6,115.4,109,129.1,102.8,96.2,127.7,128.9,126.5,119.8,113.2,114.1,134.1,130,121.8,132.1,105.3,103,117.1,126.3,138.1,119.5,138,135.5,178.6,162.2,176.9,204.9,132.2,142.5,164.3,174.9,175.4,143) > x <- c(89.3,90.3,91.1,90.1,86.7,85.1,83.4,82,80.4,81.9,93.8,94.8,92.3,87.5,83.2,82,80.3,81.8,85.1,84.2,84.4,84.5,93.3,93.2,100.3,111.4,114.9,109.5,109.9,105.8,110.8,108.8,116.1,109.8,113.8,113.8,117.4,119.5,122.6,120.7,119,126.1,133.9,138.1,140.4,148.2,148.2,155.9,171.1,171.9,188.8,214.9,228.5,220,225.4,220.7,219.7,232.1,223.5,218.9) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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.7835118 0.7839512 0.7843899 0.7848282 0.7852658 0.7857029 0.7861394 [8] 0.7865753 0.7870106 0.7874453 0.7878793 0.7883128 0.7887456 0.7891778 [15] 0.7896093 0.7900401 0.7904703 0.7908998 0.7913286 0.7917567 0.7921841 [22] 0.7926108 0.7930368 0.7934620 0.7938865 0.7943103 0.7947333 0.7951555 [29] 0.7955770 0.7959977 0.7964175 0.7968366 0.7972549 0.7976723 0.7980890 [36] 0.7985048 0.7989197 0.7993338 0.7997470 0.8001594 0.8005708 0.8009814 [43] 0.8013911 0.8017999 0.8022078 0.8026147 0.8030207 0.8034258 0.8038299 [50] 0.8042330 0.8046352 0.8050364 0.8054367 0.8058359 0.8062341 0.8066313 [57] 0.8070275 0.8074226 0.8078167 0.8082098 0.8086018 0.8089928 0.8093826 [64] 0.8097714 0.8101591 0.8105457 0.8109312 0.8113155 0.8116988 0.8120809 [71] 0.8124618 0.8128416 0.8132203 0.8135978 0.8139740 0.8143492 0.8147231 [78] 0.8150958 0.8154673 0.8158375 0.8162066 0.8165744 0.8169409 0.8173062 [85] 0.8176703 0.8180330 0.8183945 0.8187547 0.8191136 0.8194712 0.8198275 [92] 0.8201825 0.8205361 0.8208884 0.8212394 0.8215890 0.8219372 0.8222841 [99] 0.8226296 0.8229737 0.8233164 0.8236577 0.8239976 0.8243361 0.8246732 [106] 0.8250088 0.8253431 0.8256758 0.8260071 0.8263369 0.8266653 0.8269922 [113] 0.8273176 0.8276416 0.8279640 0.8282849 0.8286043 0.8289222 0.8292386 [120] 0.8295534 0.8298667 0.8301784 0.8304886 0.8307973 0.8311043 0.8314098 [127] 0.8317137 0.8320160 0.8323168 0.8326159 0.8329134 0.8332093 0.8335036 [134] 0.8337963 0.8340873 0.8343767 0.8346645 0.8349506 0.8352351 0.8355179 [141] 0.8357990 0.8360785 0.8363562 0.8366323 0.8369068 0.8371795 0.8374505 [148] 0.8377198 0.8379874 0.8382533 0.8385175 0.8387799 0.8390406 0.8392996 [155] 0.8395568 0.8398123 0.8400661 0.8403181 0.8405683 0.8408168 0.8410635 [162] 0.8413084 0.8415516 0.8417930 0.8420326 0.8422704 0.8425064 0.8427406 [169] 0.8429731 0.8432037 0.8434325 0.8436595 0.8438847 0.8441081 0.8443297 [176] 0.8445494 0.8447673 0.8449834 0.8451977 0.8454101 0.8456207 0.8458294 [183] 0.8460363 0.8462414 0.8464446 0.8466459 0.8468454 0.8470431 0.8472389 [190] 0.8474328 0.8476249 0.8478151 0.8480035 0.8481900 0.8483746 0.8485573 [197] 0.8487382 0.8489172 0.8490944 0.8492696 0.8494430 0.8496145 0.8497842 [204] 0.8499519 0.8501178 0.8502818 0.8504439 0.8506041 0.8507625 0.8509190 [211] 0.8510735 0.8512262 0.8513771 0.8515260 0.8516731 0.8518183 0.8519616 [218] 0.8521030 0.8522425 0.8523802 0.8525159 0.8526498 0.8527819 0.8529120 [225] 0.8530403 0.8531666 0.8532912 0.8534138 0.8535346 0.8536535 0.8537705 [232] 0.8538856 0.8539989 0.8541104 0.8542199 0.8543276 0.8544335 0.8545374 [239] 0.8546396 0.8547398 0.8548383 0.8549348 0.8550296 0.8551224 0.8552135 [246] 0.8553027 0.8553900 0.8554756 0.8555593 0.8556411 0.8557212 0.8557994 [253] 0.8558758 0.8559504 0.8560231 0.8560941 0.8561633 0.8562306 0.8562962 [260] 0.8563599 0.8564219 0.8564821 0.8565405 0.8565971 0.8566519 0.8567050 [267] 0.8567563 0.8568058 0.8568536 0.8568996 0.8569438 0.8569863 0.8570271 [274] 0.8570661 0.8571034 0.8571390 0.8571729 0.8572050 0.8572354 0.8572641 [281] 0.8572911 0.8573164 0.8573400 0.8573619 0.8573821 0.8574007 0.8574175 [288] 0.8574327 0.8574463 0.8574582 0.8574684 0.8574770 0.8574839 0.8574892 [295] 0.8574929 0.8574950 0.8574954 0.8574942 0.8574914 0.8574871 0.8574811 [302] 0.8574735 0.8574644 0.8574536 0.8574413 0.8574275 0.8574121 0.8573951 [309] 0.8573766 0.8573565 0.8573350 0.8573118 0.8572872 0.8572611 0.8572334 [316] 0.8572043 0.8571737 0.8571415 0.8571079 0.8570729 0.8570363 0.8569983 [323] 0.8569589 0.8569180 0.8568756 0.8568319 0.8567867 0.8567401 0.8566921 [330] 0.8566426 0.8565918 0.8565396 0.8564860 0.8564311 0.8563748 0.8563171 [337] 0.8562580 0.8561976 0.8561359 0.8560729 0.8560085 0.8559428 0.8558758 [344] 0.8558075 0.8557379 0.8556670 0.8555948 0.8555214 0.8554467 0.8553707 [351] 0.8552935 0.8552151 0.8551354 0.8550545 0.8549723 0.8548890 0.8548044 [358] 0.8547187 0.8546317 0.8545436 0.8544543 0.8543639 0.8542723 0.8541795 [365] 0.8540856 0.8539905 0.8538943 0.8537971 0.8536986 0.8535991 0.8534985 [372] 0.8533968 0.8532940 0.8531901 0.8530852 0.8529792 0.8528722 0.8527641 [379] 0.8526550 0.8525448 0.8524336 0.8523214 0.8522082 0.8520941 0.8519789 [386] 0.8518627 0.8517455 0.8516274 0.8515083 0.8513883 0.8512673 0.8511454 [393] 0.8510226 0.8508988 0.8507741 0.8506485 0.8505220 0.8503946 0.8502664 [400] 0.8501372 0.8500072 > mx [1] 0.8574954 > mxli [1] 0.96 > 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/1ejax1257852446.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/20dtl1257852446.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/3ob161257852446.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 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > 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/4tto91257852446.tab") > > system("convert tmp/1ejax1257852446.ps tmp/1ejax1257852446.png") > system("convert tmp/20dtl1257852446.ps tmp/20dtl1257852446.png") > system("convert tmp/3ob161257852446.ps tmp/3ob161257852446.png") > > > proc.time() user system elapsed 0.780 0.492 1.031