R version 2.8.1 (2008-12-22) Copyright (C) 2008 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(5,1.3,0,1.3,3,1.3,-1,-1.3,-2,-0.3,0.7,-6,-1,3,-2,-1.3,1.7,4,5.3,-3,1.3,8.7,7.3,7.3,7.7,4.7,4.7,3.7,8.3,8,8.3,12.7,11.7,9.7,9.3,9.3,7.7,8.3,7.7,7,4.3,-0.3,4.7,2,0.3,-1.7,1.3,-12.3,-14.3,-15.7,-16.7,-19,-27.3,-26.7,-26.3,-28.6,-22.9,-21.9,-17.6,-17.6,-20.8) > x <- c(785.8,819.3,849.4,880.4,900.1,937.2,948.9,952.6,947.3,974.2,1000.8,1032.8,1050.7,1057.3,1075.4,1118.4,1179.8,1227,1257.8,1251.5,1236.3,1170.6,1213.1,1265.5,1300.8,1348.4,1371.9,1403.3,1451.8,1474.2,1438.2,1513.6,1562.2,1546.2,1527.5,1418.7,1448.5,1492.1,1395.4,1403.7,1316.6,1274.5,1264.4,1323.9,1332.1,1250.2,1096.7,1080.8,1039.2,792,746.6,688.8,715.8,672.9,629.5,681.2,755.4,760.6,765.9,836.8,904.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.8577738 0.8577645 0.8577542 0.8577429 0.8577307 0.8577175 0.8577033 [8] 0.8576882 0.8576721 0.8576551 0.8576371 0.8576182 0.8575983 0.8575774 [15] 0.8575556 0.8575328 0.8575090 0.8574843 0.8574586 0.8574320 0.8574043 [22] 0.8573758 0.8573462 0.8573157 0.8572842 0.8572518 0.8572184 0.8571840 [29] 0.8571487 0.8571124 0.8570751 0.8570368 0.8569976 0.8569574 0.8569163 [36] 0.8568742 0.8568311 0.8567871 0.8567420 0.8566961 0.8566491 0.8566012 [43] 0.8565523 0.8565024 0.8564516 0.8563998 0.8563470 0.8562933 0.8562386 [50] 0.8561829 0.8561263 0.8560687 0.8560101 0.8559506 0.8558901 0.8558286 [57] 0.8557662 0.8557028 0.8556384 0.8555730 0.8555067 0.8554395 0.8553712 [64] 0.8553020 0.8552319 0.8551607 0.8550886 0.8550156 0.8549416 0.8548666 [71] 0.8547906 0.8547137 0.8546358 0.8545570 0.8544772 0.8543965 0.8543147 [78] 0.8542321 0.8541484 0.8540638 0.8539783 0.8538918 0.8538043 0.8537159 [85] 0.8536265 0.8535362 0.8534449 0.8533527 0.8532595 0.8531654 0.8530703 [92] 0.8529742 0.8528772 0.8527793 0.8526804 0.8525806 0.8524798 0.8523781 [99] 0.8522754 0.8521718 0.8520672 0.8519617 0.8518553 0.8517479 0.8516396 [106] 0.8515303 0.8514201 0.8513090 0.8511969 0.8510839 0.8509699 0.8508551 [113] 0.8507392 0.8506225 0.8505048 0.8503862 0.8502667 0.8501463 0.8500249 [120] 0.8499026 0.8497794 0.8496552 0.8495302 0.8494042 0.8492773 0.8491495 [127] 0.8490207 0.8488911 0.8487605 0.8486291 0.8484967 0.8483634 0.8482292 [134] 0.8480941 0.8479581 0.8478212 0.8476834 0.8475447 0.8474050 0.8472645 [141] 0.8471231 0.8469808 0.8468376 0.8466935 0.8465485 0.8464027 0.8462559 [148] 0.8461083 0.8459598 0.8458103 0.8456601 0.8455089 0.8453568 0.8452039 [155] 0.8450501 0.8448954 0.8447399 0.8445835 0.8444262 0.8442681 0.8441090 [162] 0.8439492 0.8437884 0.8436268 0.8434644 0.8433011 0.8431369 0.8429719 [169] 0.8428060 0.8426393 0.8424718 0.8423034 0.8421341 0.8419640 0.8417931 [176] 0.8416213 0.8414487 0.8412753 0.8411010 0.8409259 0.8407500 0.8405732 [183] 0.8403957 0.8402173 0.8400381 0.8398580 0.8396772 0.8394955 0.8393130 [190] 0.8391298 0.8389457 0.8387608 0.8385751 0.8383886 0.8382013 0.8380132 [197] 0.8378243 0.8376346 0.8374441 0.8372528 0.8370608 0.8368680 0.8366743 [204] 0.8364800 0.8362848 0.8360888 0.8358921 0.8356946 0.8354964 0.8352973 [211] 0.8350975 0.8348970 0.8346957 0.8344936 0.8342908 0.8340872 0.8338829 [218] 0.8336778 0.8334720 0.8332654 0.8330581 0.8328501 0.8326413 0.8324318 [225] 0.8322215 0.8320106 0.8317989 0.8315865 0.8313733 0.8311594 0.8309449 [232] 0.8307296 0.8305136 0.8302969 0.8300794 0.8298613 0.8296425 0.8294229 [239] 0.8292027 0.8289818 0.8287602 0.8285379 0.8283149 0.8280912 0.8278669 [246] 0.8276418 0.8274161 0.8271897 0.8269627 0.8267350 0.8265066 0.8262775 [253] 0.8260478 0.8258174 0.8255864 0.8253547 0.8251223 0.8248894 0.8246557 [260] 0.8244214 0.8241865 0.8239510 0.8237148 0.8234780 0.8232405 0.8230024 [267] 0.8227637 0.8225244 0.8222844 0.8220439 0.8218027 0.8215609 0.8213185 [274] 0.8210755 0.8208319 0.8205877 0.8203429 0.8200974 0.8198514 0.8196049 [281] 0.8193577 0.8191099 0.8188616 0.8186127 0.8183632 0.8181131 0.8178624 [288] 0.8176112 0.8173595 0.8171071 0.8168542 0.8166007 0.8163467 0.8160922 [295] 0.8158371 0.8155814 0.8153252 0.8150684 0.8148111 0.8145533 0.8142950 [302] 0.8140361 0.8137767 0.8135167 0.8132563 0.8129953 0.8127338 0.8124718 [309] 0.8122093 0.8119462 0.8116827 0.8114187 0.8111541 0.8108891 0.8106235 [316] 0.8103575 0.8100910 0.8098240 0.8095565 0.8092886 0.8090201 0.8087512 [323] 0.8084818 0.8082120 0.8079416 0.8076708 0.8073996 0.8071279 0.8068557 [330] 0.8065831 0.8063100 0.8060365 0.8057625 0.8054881 0.8052133 0.8049380 [337] 0.8046623 0.8043861 0.8041095 0.8038325 0.8035551 0.8032772 0.8029990 [344] 0.8027203 0.8024412 0.8021617 0.8018818 0.8016014 0.8013207 0.8010396 [351] 0.8007581 0.8004762 0.8001939 0.7999112 0.7996281 0.7993446 0.7990608 [358] 0.7987766 0.7984920 0.7982070 0.7979217 0.7976360 0.7973499 0.7970635 [365] 0.7967767 0.7964896 0.7962021 0.7959142 0.7956261 0.7953375 0.7950486 [372] 0.7947594 0.7944698 0.7941800 0.7938897 0.7935992 0.7933083 0.7930171 [379] 0.7927255 0.7924337 0.7921415 0.7918490 0.7915562 0.7912631 0.7909697 [386] 0.7906760 0.7903820 0.7900877 0.7897931 0.7894982 0.7892030 0.7889075 [393] 0.7886117 0.7883157 0.7880193 0.7877227 0.7874258 0.7871286 0.7868312 [400] 0.7865335 0.7862355 > mx [1] 0.8577738 > 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/rcomp/tmp/171a61257613054.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/rcomp/tmp/2o25x1257613054.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/rcomp/tmp/3qr7h1257613054.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/4lhf51257613054.tab") > > system("convert tmp/171a61257613054.ps tmp/171a61257613054.png") > system("convert tmp/2o25x1257613054.ps tmp/2o25x1257613054.png") > system("convert tmp/3qr7h1257613054.ps tmp/3qr7h1257613054.png") > > > proc.time() user system elapsed 0.880 0.790 1.319