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(445,301,350,305,450,360,287,417,361,478,302,294,300,364,356,340,377,507,321,354,549,444,400,401,259,288,346,287,381,474,329,423,407,412,566,372,290,354,370,377,467,409,310,434,339,385,469,313,373,310,320,340,489,419,460,324,352,473,340,282) > x <- c(369,380,474,413,537,439,355,473,435,478,450,365,315,340,326,483,406,409,423,404,551,467,332,442,305,368,411,318,398,586,367,383,533,527,418,576,359,342,456,406,374,568,335,458,456,386,457,396,366,499,354,365,594,456,366,398,468,609,418,352) > #'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.5187376 0.5187954 0.5188530 0.5189103 0.5189674 0.5190242 0.5190807 [8] 0.5191369 0.5191929 0.5192486 0.5193040 0.5193592 0.5194140 0.5194686 [15] 0.5195230 0.5195770 0.5196308 0.5196843 0.5197375 0.5197905 0.5198432 [22] 0.5198956 0.5199477 0.5199995 0.5200511 0.5201024 0.5201534 0.5202041 [29] 0.5202545 0.5203047 0.5203545 0.5204041 0.5204534 0.5205024 0.5205512 [36] 0.5205996 0.5206478 0.5206957 0.5207432 0.5207905 0.5208375 0.5208843 [43] 0.5209307 0.5209768 0.5210227 0.5210682 0.5211135 0.5211585 0.5212032 [50] 0.5212475 0.5212916 0.5213354 0.5213789 0.5214222 0.5214651 0.5215077 [57] 0.5215500 0.5215920 0.5216338 0.5216752 0.5217163 0.5217571 0.5217977 [64] 0.5218379 0.5218778 0.5219174 0.5219568 0.5219958 0.5220345 0.5220729 [71] 0.5221111 0.5221489 0.5221864 0.5222236 0.5222605 0.5222971 0.5223333 [78] 0.5223693 0.5224050 0.5224403 0.5224754 0.5225101 0.5225446 0.5225787 [85] 0.5226125 0.5226460 0.5226792 0.5227121 0.5227447 0.5227769 0.5228089 [92] 0.5228405 0.5228718 0.5229028 0.5229335 0.5229639 0.5229940 0.5230237 [99] 0.5230532 0.5230823 0.5231111 0.5231396 0.5231677 0.5231956 0.5232231 [106] 0.5232503 0.5232772 0.5233038 0.5233301 0.5233560 0.5233816 0.5234069 [113] 0.5234319 0.5234565 0.5234809 0.5235049 0.5235286 0.5235519 0.5235750 [120] 0.5235977 0.5236201 0.5236422 0.5236639 0.5236853 0.5237064 0.5237272 [127] 0.5237477 0.5237678 0.5237876 0.5238070 0.5238262 0.5238450 0.5238635 [134] 0.5238816 0.5238995 0.5239170 0.5239342 0.5239510 0.5239675 0.5239837 [141] 0.5239996 0.5240151 0.5240303 0.5240452 0.5240597 0.5240739 0.5240878 [148] 0.5241013 0.5241145 0.5241274 0.5241400 0.5241522 0.5241641 0.5241756 [155] 0.5241868 0.5241977 0.5242083 0.5242185 0.5242284 0.5242379 0.5242471 [162] 0.5242560 0.5242646 0.5242728 0.5242807 0.5242882 0.5242954 0.5243023 [169] 0.5243088 0.5243150 0.5243209 0.5243264 0.5243316 0.5243365 0.5243410 [176] 0.5243452 0.5243490 0.5243525 0.5243557 0.5243585 0.5243610 0.5243632 [183] 0.5243650 0.5243665 0.5243676 0.5243684 0.5243689 0.5243690 0.5243688 [190] 0.5243683 0.5243674 0.5243662 0.5243646 0.5243627 0.5243605 0.5243579 [197] 0.5243550 0.5243517 0.5243481 0.5243442 0.5243399 0.5243353 0.5243304 [204] 0.5243251 0.5243194 0.5243135 0.5243072 0.5243005 0.5242935 0.5242862 [211] 0.5242785 0.5242705 0.5242622 0.5242535 0.5242445 0.5242351 0.5242254 [218] 0.5242154 0.5242050 0.5241943 0.5241832 0.5241718 0.5241601 0.5241480 [225] 0.5241356 0.5241228 0.5241097 0.5240963 0.5240825 0.5240684 0.5240540 [232] 0.5240392 0.5240241 0.5240086 0.5239928 0.5239766 0.5239602 0.5239433 [239] 0.5239262 0.5239087 0.5238909 0.5238727 0.5238542 0.5238353 0.5238162 [246] 0.5237966 0.5237768 0.5237566 0.5237360 0.5237152 0.5236940 0.5236724 [253] 0.5236506 0.5236283 0.5236058 0.5235829 0.5235597 0.5235361 0.5235122 [260] 0.5234880 0.5234634 0.5234385 0.5234133 0.5233877 0.5233618 0.5233356 [267] 0.5233090 0.5232821 0.5232549 0.5232273 0.5231994 0.5231712 0.5231426 [274] 0.5231137 0.5230845 0.5230549 0.5230250 0.5229948 0.5229643 0.5229334 [281] 0.5229021 0.5228706 0.5228387 0.5228065 0.5227740 0.5227411 0.5227079 [288] 0.5226744 0.5226405 0.5226064 0.5225719 0.5225370 0.5225019 0.5224664 [295] 0.5224306 0.5223944 0.5223580 0.5223212 0.5222840 0.5222466 0.5222088 [302] 0.5221708 0.5221323 0.5220936 0.5220545 0.5220152 0.5219755 0.5219354 [309] 0.5218951 0.5218544 0.5218134 0.5217721 0.5217305 0.5216885 0.5216463 [316] 0.5216037 0.5215608 0.5215175 0.5214740 0.5214301 0.5213860 0.5213415 [323] 0.5212967 0.5212515 0.5212061 0.5211603 0.5211143 0.5210679 0.5210212 [330] 0.5209742 0.5209269 0.5208792 0.5208313 0.5207830 0.5207345 0.5206856 [337] 0.5206364 0.5205869 0.5205371 0.5204870 0.5204365 0.5203858 0.5203348 [344] 0.5202834 0.5202318 0.5201798 0.5201276 0.5200750 0.5200221 0.5199690 [351] 0.5199155 0.5198617 0.5198076 0.5197533 0.5196986 0.5196436 0.5195883 [358] 0.5195327 0.5194768 0.5194207 0.5193642 0.5193074 0.5192503 0.5191930 [365] 0.5191353 0.5190774 0.5190191 0.5189606 0.5189017 0.5188426 0.5187832 [372] 0.5187235 0.5186635 0.5186032 0.5185426 0.5184817 0.5184205 0.5183591 [379] 0.5182974 0.5182353 0.5181730 0.5181104 0.5180475 0.5179844 0.5179209 [386] 0.5178572 0.5177932 0.5177289 0.5176643 0.5175994 0.5175343 0.5174689 [393] 0.5174032 0.5173372 0.5172709 0.5172044 0.5171376 0.5170705 0.5170032 [400] 0.5169355 0.5168676 > mx [1] 0.524369 > mxli [1] -0.13 > 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/1r7af1260114470.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/2d4lc1260114470.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/34d3w1260114470.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/4hjig1260114470.tab") > > system("convert tmp/1r7af1260114470.ps tmp/1r7af1260114470.png") > system("convert tmp/2d4lc1260114470.ps tmp/2d4lc1260114470.png") > system("convert tmp/34d3w1260114470.ps tmp/34d3w1260114470.png") > > > proc.time() user system elapsed 0.779 0.497 0.911