R version 2.7.2 (2008-08-25) 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(62,48,53,26,24,32,71,62,62,61,22,61,68,60,51,31,60,67,74,39,60,59,22,67,69,63,35,34,54,59,39,59,34,59,22,47,65) > x <- c(64,48,38,31,26,33,78,74,57,59,24,60,73,46,51,31,42,56,70,56,49,57,18,64,56,56,37,24,60,60,38,56,52,55,29,54,51) > #'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.7680003 0.7688103 0.7696180 0.7704234 0.7712265 0.7720273 0.7728258 [8] 0.7736218 0.7744155 0.7752068 0.7759956 0.7767820 0.7775660 0.7783474 [15] 0.7791263 0.7799027 0.7806765 0.7814477 0.7822164 0.7829824 0.7837458 [22] 0.7845066 0.7852647 0.7860200 0.7867727 0.7875226 0.7882698 0.7890142 [29] 0.7897559 0.7904947 0.7912307 0.7919638 0.7926941 0.7934214 0.7941459 [36] 0.7948675 0.7955861 0.7963018 0.7970145 0.7977242 0.7984309 0.7991345 [43] 0.7998351 0.8005327 0.8012271 0.8019185 0.8026068 0.8032919 0.8039739 [50] 0.8046527 0.8053284 0.8060008 0.8066700 0.8073360 0.8079988 0.8086583 [57] 0.8093145 0.8099675 0.8106171 0.8112634 0.8119064 0.8125460 0.8131823 [64] 0.8138152 0.8144447 0.8150708 0.8156934 0.8163127 0.8169285 0.8175408 [71] 0.8181496 0.8187550 0.8193569 0.8199552 0.8205500 0.8211413 0.8217290 [78] 0.8223132 0.8228938 0.8234708 0.8240442 0.8246139 0.8251801 0.8257426 [85] 0.8263015 0.8268567 0.8274083 0.8279562 0.8285003 0.8290408 0.8295776 [92] 0.8301107 0.8306400 0.8311656 0.8316874 0.8322055 0.8327198 0.8332304 [99] 0.8337371 0.8342401 0.8347393 0.8352346 0.8357262 0.8362139 0.8366977 [106] 0.8371778 0.8376539 0.8381262 0.8385947 0.8390593 0.8395200 0.8399768 [113] 0.8404297 0.8408787 0.8413238 0.8417651 0.8422023 0.8426357 0.8430651 [120] 0.8434906 0.8439122 0.8443298 0.8447434 0.8451532 0.8455589 0.8459607 [127] 0.8463585 0.8467523 0.8471422 0.8475280 0.8479099 0.8482878 0.8486617 [134] 0.8490316 0.8493975 0.8497594 0.8501173 0.8504712 0.8508211 0.8511669 [141] 0.8515088 0.8518466 0.8521804 0.8525102 0.8528360 0.8531577 0.8534754 [148] 0.8537891 0.8540987 0.8544043 0.8547059 0.8550034 0.8552969 0.8555864 [155] 0.8558719 0.8561533 0.8564306 0.8567040 0.8569733 0.8572385 0.8574998 [162] 0.8577569 0.8580101 0.8582592 0.8585043 0.8587454 0.8589824 0.8592154 [169] 0.8594444 0.8596694 0.8598903 0.8601072 0.8603201 0.8605290 0.8607338 [176] 0.8609347 0.8611315 0.8613243 0.8615132 0.8616980 0.8618788 0.8620556 [183] 0.8622284 0.8623973 0.8625621 0.8627230 0.8628798 0.8630327 0.8631817 [190] 0.8633266 0.8634676 0.8636047 0.8637377 0.8638669 0.8639920 0.8641133 [197] 0.8642306 0.8643439 0.8644533 0.8645588 0.8646604 0.8647581 0.8648518 [204] 0.8649417 0.8650277 0.8651097 0.8651879 0.8652622 0.8653326 0.8653991 [211] 0.8654618 0.8655206 0.8655756 0.8656267 0.8656740 0.8657175 0.8657571 [218] 0.8657929 0.8658249 0.8658531 0.8658775 0.8658981 0.8659149 0.8659279 [225] 0.8659372 0.8659427 0.8659444 0.8659424 0.8659366 0.8659271 0.8659139 [232] 0.8658970 0.8658763 0.8658520 0.8658239 0.8657922 0.8657568 0.8657177 [239] 0.8656750 0.8656286 0.8655785 0.8655248 0.8654675 0.8654066 0.8653420 [246] 0.8652739 0.8652021 0.8651268 0.8650479 0.8649654 0.8648794 0.8647898 [253] 0.8646967 0.8646000 0.8644998 0.8643961 0.8642890 0.8641783 0.8640641 [260] 0.8639464 0.8638253 0.8637008 0.8635728 0.8634413 0.8633064 0.8631682 [267] 0.8630265 0.8628814 0.8627329 0.8625810 0.8624258 0.8622672 0.8621053 [274] 0.8619401 0.8617715 0.8615996 0.8614244 0.8612459 0.8610642 0.8608791 [281] 0.8606908 0.8604993 0.8603045 0.8601065 0.8599052 0.8597008 0.8594931 [288] 0.8592823 0.8590683 0.8588512 0.8586309 0.8584074 0.8581808 0.8579511 [295] 0.8577183 0.8574824 0.8572434 0.8570014 0.8567563 0.8565081 0.8562569 [302] 0.8560026 0.8557454 0.8554851 0.8552219 0.8549557 0.8546865 0.8544143 [309] 0.8541392 0.8538612 0.8535802 0.8532964 0.8530096 0.8527200 0.8524275 [316] 0.8521321 0.8518338 0.8515328 0.8512289 0.8509222 0.8506127 0.8503004 [323] 0.8499853 0.8496675 0.8493469 0.8490235 0.8486975 0.8483687 0.8480372 [330] 0.8477030 0.8473662 0.8470267 0.8466845 0.8463397 0.8459922 0.8456422 [337] 0.8452895 0.8449343 0.8445764 0.8442160 0.8438531 0.8434876 0.8431196 [344] 0.8427490 0.8423760 0.8420004 0.8416224 0.8412419 0.8408590 0.8404736 [351] 0.8400858 0.8396956 0.8393030 0.8389080 0.8385106 0.8381109 0.8377088 [358] 0.8373044 0.8368976 0.8364885 0.8360772 0.8356635 0.8352476 0.8348294 [365] 0.8344090 0.8339863 0.8335614 0.8331343 0.8327050 0.8322735 0.8318399 [372] 0.8314041 0.8309661 0.8305260 0.8300838 0.8296395 0.8291931 0.8287446 [379] 0.8282941 0.8278415 0.8273868 0.8269302 0.8264715 0.8260108 0.8255481 [386] 0.8250835 0.8246169 0.8241483 0.8236778 0.8232054 0.8227310 0.8222548 [393] 0.8217767 0.8212967 0.8208149 0.8203312 0.8198456 0.8193583 0.8188691 [400] 0.8183782 0.8178854 > mx [1] 0.8659444 > mxli [1] 0.26 > 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/1mrpp1226501096.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/235q61226501096.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/3sijw1226501096.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/4jvq81226501096.tab") > > system("convert tmp/1mrpp1226501096.ps tmp/1mrpp1226501096.png") > system("convert tmp/235q61226501096.ps tmp/235q61226501096.png") > system("convert tmp/3sijw1226501096.ps tmp/3sijw1226501096.png") > > > proc.time() user system elapsed 1.004 0.515 1.154