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(2605,2682,2755,2760,2735,2659,2654,2670,2785,2845,2723,2746,2767,2940,2977,2993,2892,2824,2771,2686,2738,2723,2731,2632,2606,2605,2646,2627,2535,2456,2404,2319,2519,2504,2382,2394,2381,2501,2532,2515,2429,2389,2261,2272,2439,2373,2327,2364,2388,2553,2663,2694,2679,2611,2580,2627,2732,2707,2633,2683) > x <- c(6539,6699,6962,6981,7024,6940,6774,6671,6965,6969,6822,6878,6691,6837,7018,7167,7076,7171,7093,6971,7142,7047,6999,6650,6475,6437,6639,6422,6272,6232,6003,5673,6050,5977,5796,5752,5609,5839,6069,6006,5809,5797,5502,5568,5864,5764,5615,5615,5681,5915,6334,6494,6620,6578,6495,6538,6737,6651,6530,6563) > #'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.9297637 0.9297810 0.9297982 0.9298153 0.9298323 0.9298492 0.9298661 [8] 0.9298828 0.9298995 0.9299161 0.9299326 0.9299491 0.9299654 0.9299817 [15] 0.9299979 0.9300140 0.9300300 0.9300460 0.9300618 0.9300776 0.9300933 [22] 0.9301089 0.9301245 0.9301399 0.9301553 0.9301706 0.9301858 0.9302009 [29] 0.9302159 0.9302309 0.9302458 0.9302605 0.9302753 0.9302899 0.9303044 [36] 0.9303189 0.9303332 0.9303475 0.9303617 0.9303759 0.9303899 0.9304039 [43] 0.9304177 0.9304315 0.9304452 0.9304588 0.9304724 0.9304858 0.9304992 [50] 0.9305125 0.9305257 0.9305388 0.9305519 0.9305648 0.9305777 0.9305905 [57] 0.9306032 0.9306158 0.9306283 0.9306408 0.9306531 0.9306654 0.9306776 [64] 0.9306897 0.9307018 0.9307137 0.9307256 0.9307374 0.9307490 0.9307607 [71] 0.9307722 0.9307836 0.9307950 0.9308062 0.9308174 0.9308285 0.9308396 [78] 0.9308505 0.9308613 0.9308721 0.9308828 0.9308934 0.9309039 0.9309143 [85] 0.9309247 0.9309349 0.9309451 0.9309552 0.9309652 0.9309751 0.9309849 [92] 0.9309947 0.9310043 0.9310139 0.9310234 0.9310328 0.9310421 0.9310514 [99] 0.9310605 0.9310696 0.9310786 0.9310875 0.9310963 0.9311050 0.9311136 [106] 0.9311222 0.9311307 0.9311390 0.9311473 0.9311555 0.9311637 0.9311717 [113] 0.9311797 0.9311875 0.9311953 0.9312030 0.9312106 0.9312182 0.9312256 [120] 0.9312330 0.9312402 0.9312474 0.9312545 0.9312615 0.9312684 0.9312753 [127] 0.9312820 0.9312887 0.9312953 0.9313018 0.9313082 0.9313145 0.9313208 [134] 0.9313269 0.9313330 0.9313389 0.9313448 0.9313506 0.9313564 0.9313620 [141] 0.9313675 0.9313730 0.9313784 0.9313837 0.9313889 0.9313940 0.9313990 [148] 0.9314040 0.9314088 0.9314136 0.9314183 0.9314229 0.9314274 0.9314318 [155] 0.9314361 0.9314404 0.9314445 0.9314486 0.9314526 0.9314565 0.9314603 [162] 0.9314640 0.9314677 0.9314712 0.9314747 0.9314781 0.9314814 0.9314846 [169] 0.9314877 0.9314907 0.9314937 0.9314965 0.9314993 0.9315020 0.9315046 [176] 0.9315071 0.9315095 0.9315119 0.9315141 0.9315163 0.9315184 0.9315203 [183] 0.9315222 0.9315241 0.9315258 0.9315274 0.9315290 0.9315304 0.9315318 [190] 0.9315331 0.9315343 0.9315354 0.9315364 0.9315374 0.9315382 0.9315390 [197] 0.9315397 0.9315402 0.9315407 0.9315412 0.9315415 0.9315417 0.9315419 [204] 0.9315419 0.9315419 0.9315418 0.9315416 0.9315413 0.9315409 0.9315405 [211] 0.9315399 0.9315393 0.9315385 0.9315377 0.9315368 0.9315358 0.9315347 [218] 0.9315336 0.9315323 0.9315310 0.9315295 0.9315280 0.9315264 0.9315247 [225] 0.9315229 0.9315211 0.9315191 0.9315171 0.9315149 0.9315127 0.9315104 [232] 0.9315080 0.9315055 0.9315029 0.9315003 0.9314975 0.9314947 0.9314917 [239] 0.9314887 0.9314856 0.9314824 0.9314791 0.9314758 0.9314723 0.9314688 [246] 0.9314651 0.9314614 0.9314576 0.9314537 0.9314497 0.9314456 0.9314415 [253] 0.9314372 0.9314329 0.9314284 0.9314239 0.9314193 0.9314146 0.9314098 [260] 0.9314050 0.9314000 0.9313950 0.9313898 0.9313846 0.9313793 0.9313739 [267] 0.9313684 0.9313628 0.9313571 0.9313514 0.9313455 0.9313396 0.9313336 [274] 0.9313275 0.9313213 0.9313150 0.9313086 0.9313021 0.9312956 0.9312889 [281] 0.9312822 0.9312754 0.9312685 0.9312615 0.9312544 0.9312472 0.9312399 [288] 0.9312326 0.9312251 0.9312176 0.9312100 0.9312023 0.9311945 0.9311866 [295] 0.9311786 0.9311706 0.9311624 0.9311542 0.9311459 0.9311374 0.9311289 [302] 0.9311203 0.9311117 0.9311029 0.9310940 0.9310851 0.9310760 0.9310669 [309] 0.9310577 0.9310484 0.9310390 0.9310295 0.9310199 0.9310103 0.9310005 [316] 0.9309907 0.9309808 0.9309708 0.9309607 0.9309505 0.9309402 0.9309298 [323] 0.9309194 0.9309088 0.9308982 0.9308874 0.9308766 0.9308657 0.9308547 [330] 0.9308437 0.9308325 0.9308212 0.9308099 0.9307984 0.9307869 0.9307753 [337] 0.9307636 0.9307518 0.9307399 0.9307280 0.9307159 0.9307038 0.9306915 [344] 0.9306792 0.9306668 0.9306543 0.9306417 0.9306290 0.9306162 0.9306034 [351] 0.9305904 0.9305774 0.9305643 0.9305511 0.9305378 0.9305244 0.9305109 [358] 0.9304973 0.9304837 0.9304699 0.9304561 0.9304422 0.9304282 0.9304141 [365] 0.9303999 0.9303856 0.9303712 0.9303568 0.9303423 0.9303276 0.9303129 [372] 0.9302981 0.9302832 0.9302682 0.9302531 0.9302380 0.9302227 0.9302074 [379] 0.9301919 0.9301764 0.9301608 0.9301451 0.9301293 0.9301135 0.9300975 [386] 0.9300815 0.9300653 0.9300491 0.9300328 0.9300164 0.9299999 0.9299833 [393] 0.9299666 0.9299499 0.9299330 0.9299161 0.9298991 0.9298819 0.9298647 [400] 0.9298474 0.9298301 > mx [1] 0.931542 > mxli [1] 0.03 > 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/1g61x1257952014.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/276s71257952014.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/3g5wm1257952014.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/4xxfn1257952014.tab") > > system("convert tmp/1g61x1257952014.ps tmp/1g61x1257952014.png") > system("convert tmp/276s71257952014.ps tmp/276s71257952014.png") > system("convert tmp/3g5wm1257952014.ps tmp/3g5wm1257952014.png") > > > proc.time() user system elapsed 0.880 0.810 1.549