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(45,24,18,20,22,39,55,35,38,47,1,57,50,33,19,2,7,15,56,53,24,48,2,49,46,32,37,10,8,16,55,46,46,45,6,45,52,44,35,15,44,51,58,23,44,43,6,51,53,47,19,18,38,43,23,43,18,43,6,31,49) > x <- c(75,38,20,6,11,38,54,44,37,39,4,49,45,29,20,9,16,3,56,53,35,49,11,54,47,31,21,14,9,16,61,57,40,42,7,43,56,29,34,14,25,39,53,39,32,40,1,47,39,39,20,7,43,43,21,39,35,38,12,37,34) > #'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.2634589 0.2642826 0.2651200 0.2659712 0.2668365 0.2677162 0.2686103 [8] 0.2695193 0.2704432 0.2713825 0.2723372 0.2733077 0.2742942 0.2752969 [15] 0.2763162 0.2773523 0.2784053 0.2794757 0.2805637 0.2816695 0.2827934 [22] 0.2839358 0.2850968 0.2862767 0.2874760 0.2886947 0.2899333 0.2911920 [29] 0.2924711 0.2937710 0.2950918 0.2964340 0.2977978 0.2991836 0.3005915 [36] 0.3020220 0.3034754 0.3049520 0.3064520 0.3079758 0.3095238 0.3110962 [43] 0.3126933 0.3143155 0.3159631 0.3176364 0.3193357 0.3210614 0.3228137 [50] 0.3245930 0.3263996 0.3282338 0.3300959 0.3319862 0.3339051 0.3358527 [57] 0.3378295 0.3398357 0.3418716 0.3439376 0.3460338 0.3481606 0.3503182 [64] 0.3525069 0.3547270 0.3569787 0.3592623 0.3615779 0.3639259 0.3663065 [71] 0.3687198 0.3711660 0.3736455 0.3761582 0.3787045 0.3812844 0.3838980 [78] 0.3865457 0.3892273 0.3919431 0.3946931 0.3974774 0.4002960 0.4031490 [85] 0.4060364 0.4089582 0.4119143 0.4149047 0.4179294 0.4209883 0.4240812 [92] 0.4272080 0.4303686 0.4335628 0.4367904 0.4400511 0.4433447 0.4466710 [99] 0.4500296 0.4534201 0.4568423 0.4602957 0.4637799 0.4672944 0.4708389 [106] 0.4744127 0.4780153 0.4816462 0.4853048 0.4889904 0.4927023 0.4964400 [113] 0.5002026 0.5039894 0.5077996 0.5116324 0.5154870 0.5193624 0.5232579 [120] 0.5271724 0.5311050 0.5350547 0.5390205 0.5430014 0.5469962 0.5510040 [127] 0.5550236 0.5590538 0.5630936 0.5671416 0.5711969 0.5752580 0.5793239 [134] 0.5833932 0.5874648 0.5915373 0.5956094 0.5996800 0.6037477 0.6078112 [141] 0.6118692 0.6159204 0.6199636 0.6239973 0.6280204 0.6320316 0.6360295 [148] 0.6400129 0.6439806 0.6479312 0.6518636 0.6557766 0.6596689 0.6635394 [155] 0.6673869 0.6712102 0.6750083 0.6787801 0.6825245 0.6862405 0.6899270 [162] 0.6935831 0.6972079 0.7008004 0.7043598 0.7078852 0.7113758 0.7148307 [169] 0.7182494 0.7216310 0.7249749 0.7282805 0.7315471 0.7347741 0.7379612 [176] 0.7411077 0.7442132 0.7472772 0.7502995 0.7532797 0.7562173 0.7591122 [183] 0.7619642 0.7647729 0.7675382 0.7702600 0.7729382 0.7755725 0.7781631 [190] 0.7807099 0.7832128 0.7856719 0.7880873 0.7904590 0.7927871 0.7950717 [197] 0.7973130 0.7995112 0.8016665 0.8037789 0.8058489 0.8078766 0.8098623 [204] 0.8118062 0.8137086 0.8155700 0.8173904 0.8191704 0.8209103 0.8226103 [211] 0.8242708 0.8258923 0.8274750 0.8290195 0.8305260 0.8319949 0.8334268 [218] 0.8348219 0.8361806 0.8375035 0.8387909 0.8400432 0.8412608 0.8424442 [225] 0.8435938 0.8447100 0.8457932 0.8468439 0.8478624 0.8488493 0.8498048 [232] 0.8507294 0.8516236 0.8524877 0.8533221 0.8541273 0.8549037 0.8556516 [239] 0.8563714 0.8570635 0.8577284 0.8583664 0.8589778 0.8595631 0.8601226 [246] 0.8606566 0.8611656 0.8616499 0.8621098 0.8625458 0.8629580 0.8633469 [253] 0.8637128 0.8640560 0.8643768 0.8646756 0.8649527 0.8652084 0.8654429 [260] 0.8656565 0.8658497 0.8660226 0.8661755 0.8663087 0.8664225 0.8665172 [267] 0.8665930 0.8666501 0.8666889 0.8667096 0.8667124 0.8666976 0.8666653 [274] 0.8666160 0.8665497 0.8664667 0.8663672 0.8662515 0.8661197 0.8659721 [281] 0.8658089 0.8656302 0.8654364 0.8652275 0.8650038 0.8647654 0.8645127 [288] 0.8642456 0.8639645 0.8636694 0.8633606 0.8630383 0.8627026 0.8623536 [295] 0.8619916 0.8616167 0.8612291 0.8608289 0.8604162 0.8599913 0.8595542 [302] 0.8591052 0.8586443 0.8581717 0.8576876 0.8571920 0.8566852 0.8561672 [309] 0.8556381 0.8550982 0.8545476 0.8539863 0.8534145 0.8528322 0.8522398 [316] 0.8516371 0.8510245 0.8504019 0.8497695 0.8491274 0.8484758 0.8478147 [323] 0.8471442 0.8464644 0.8457755 0.8450776 0.8443707 0.8436550 0.8429305 [330] 0.8421974 0.8414557 0.8407056 0.8399471 0.8391804 0.8384055 0.8376225 [337] 0.8368316 0.8360328 0.8352261 0.8344118 0.8335898 0.8327602 0.8319233 [344] 0.8310789 0.8302273 0.8293684 0.8285024 0.8276294 0.8267495 0.8258626 [351] 0.8249690 0.8240686 0.8231616 0.8222480 0.8213279 0.8204014 0.8194685 [358] 0.8185294 0.8175840 0.8166326 0.8156751 0.8147116 0.8137422 0.8127670 [365] 0.8117860 0.8107993 0.8098069 0.8088090 0.8078056 0.8067968 0.8057826 [372] 0.8047631 0.8037383 0.8027084 0.8016734 0.8006333 0.7995883 0.7985383 [379] 0.7974835 0.7964239 0.7953596 0.7942906 0.7932169 0.7921388 0.7910561 [386] 0.7899690 0.7888776 0.7877818 0.7866817 0.7855775 0.7844691 0.7833566 [393] 0.7822401 0.7811197 0.7799953 0.7788670 0.7777350 0.7765991 0.7754596 [400] 0.7743164 0.7731697 > mx [1] 0.8667124 > mxli [1] 0.7 > 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/1tqwl1226567813.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/226uk1226567813.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/3r0zc1226567813.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/4zkyp1226567813.tab") > > system("convert tmp/1tqwl1226567813.ps tmp/1tqwl1226567813.png") > system("convert tmp/226uk1226567813.ps tmp/226uk1226567813.png") > system("convert tmp/3r0zc1226567813.ps tmp/3r0zc1226567813.png") > > > proc.time() user system elapsed 1.041 0.529 1.237