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(2718,2646,2551,2712,2606,2365,3533,3509,2912,3599,2719,2869,4085,2686,2545,3071,3388,2652,3190,2884,3295,3818,3226,3953,3810,2877,3515,3708,3450,3360,4110,4384,3729,4263,3505,3674,3911,2951,3317,3417,3498,2768,2899,3179,3011,3481,3015,2606,3530,2827,3120,2557,3645,2865,2587,2887,3429,2956,3098,2934,3269) > x <- c(1515,1510,1225,1577,1417,1224,1693,1633,1639,1914,1586,1552,2081,1500,1437,1470,1849,1387,1592,1589,1798,1935,1887,2027,2080,1556,1682,1785,1869,1781,2082,2570,1862,1936,1504,1765,1607,1577,1493,1615,1700,1335,1523,1623,1540,1637,1524,1419,1821,1593,1357,1263,1750,1405,1393,1639,1679,1551,1744,1429,1784) > #'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.8208431 0.8210575 0.8212712 0.8214842 0.8216965 0.8219081 0.8221190 [8] 0.8223292 0.8225387 0.8227474 0.8229554 0.8231627 0.8233693 0.8235751 [15] 0.8237802 0.8239846 0.8241882 0.8243911 0.8245933 0.8247947 0.8249954 [22] 0.8251953 0.8253945 0.8255929 0.8257906 0.8259875 0.8261836 0.8263790 [29] 0.8265737 0.8267675 0.8269606 0.8271530 0.8273445 0.8275353 0.8277253 [36] 0.8279146 0.8281030 0.8282907 0.8284776 0.8286637 0.8288490 0.8290335 [43] 0.8292172 0.8294001 0.8295822 0.8297635 0.8299440 0.8301237 0.8303026 [50] 0.8304807 0.8306580 0.8308344 0.8310101 0.8311849 0.8313589 0.8315320 [57] 0.8317044 0.8318759 0.8320465 0.8322164 0.8323854 0.8325535 0.8327209 [64] 0.8328873 0.8330530 0.8332177 0.8333817 0.8335447 0.8337070 0.8338683 [71] 0.8340288 0.8341884 0.8343472 0.8345051 0.8346621 0.8348183 0.8349736 [78] 0.8351280 0.8352815 0.8354342 0.8355859 0.8357368 0.8358868 0.8360359 [85] 0.8361840 0.8363313 0.8364777 0.8366232 0.8367678 0.8369115 0.8370543 [92] 0.8371962 0.8373371 0.8374772 0.8376163 0.8377545 0.8378918 0.8380281 [99] 0.8381635 0.8382980 0.8384316 0.8385642 0.8386959 0.8388267 0.8389565 [106] 0.8390853 0.8392132 0.8393402 0.8394662 0.8395913 0.8397154 0.8398385 [113] 0.8399607 0.8400819 0.8402022 0.8403215 0.8404398 0.8405571 0.8406735 [120] 0.8407889 0.8409033 0.8410167 0.8411291 0.8412406 0.8413510 0.8414605 [127] 0.8415690 0.8416764 0.8417829 0.8418884 0.8419928 0.8420963 0.8421988 [134] 0.8423002 0.8424006 0.8425000 0.8425984 0.8426958 0.8427921 0.8428874 [141] 0.8429817 0.8430750 0.8431672 0.8432584 0.8433485 0.8434376 0.8435257 [148] 0.8436127 0.8436987 0.8437836 0.8438675 0.8439503 0.8440320 0.8441127 [155] 0.8441924 0.8442709 0.8443484 0.8444249 0.8445002 0.8445745 0.8446477 [162] 0.8447199 0.8447909 0.8448609 0.8449298 0.8449976 0.8450643 0.8451299 [169] 0.8451944 0.8452578 0.8453201 0.8453813 0.8454414 0.8455004 0.8455583 [176] 0.8456151 0.8456708 0.8457253 0.8457788 0.8458311 0.8458823 0.8459323 [183] 0.8459813 0.8460291 0.8460757 0.8461213 0.8461657 0.8462089 0.8462510 [190] 0.8462920 0.8463318 0.8463705 0.8464080 0.8464444 0.8464796 0.8465137 [197] 0.8465466 0.8465783 0.8466089 0.8466383 0.8466665 0.8466936 0.8467195 [204] 0.8467442 0.8467677 0.8467901 0.8468113 0.8468312 0.8468500 0.8468676 [211] 0.8468841 0.8468993 0.8469133 0.8469262 0.8469378 0.8469482 0.8469574 [218] 0.8469655 0.8469723 0.8469779 0.8469822 0.8469854 0.8469874 0.8469881 [225] 0.8469876 0.8469859 0.8469829 0.8469788 0.8469734 0.8469667 0.8469589 [232] 0.8469497 0.8469394 0.8469278 0.8469150 0.8469009 0.8468856 0.8468690 [239] 0.8468512 0.8468321 0.8468118 0.8467902 0.8467674 0.8467433 0.8467179 [246] 0.8466913 0.8466634 0.8466342 0.8466037 0.8465720 0.8465390 0.8465048 [253] 0.8464692 0.8464324 0.8463943 0.8463549 0.8463142 0.8462722 0.8462290 [260] 0.8461844 0.8461386 0.8460914 0.8460430 0.8459932 0.8459422 0.8458898 [267] 0.8458362 0.8457812 0.8457250 0.8456674 0.8456085 0.8455483 0.8454868 [274] 0.8454239 0.8453598 0.8452943 0.8452275 0.8451594 0.8450899 0.8450192 [281] 0.8449471 0.8448736 0.8447988 0.8447227 0.8446453 0.8445665 0.8444864 [288] 0.8444049 0.8443221 0.8442380 0.8441525 0.8440657 0.8439775 0.8438880 [295] 0.8437971 0.8437048 0.8436112 0.8435163 0.8434200 0.8433223 0.8432233 [302] 0.8431229 0.8430212 0.8429181 0.8428136 0.8427077 0.8426005 0.8424919 [309] 0.8423820 0.8422706 0.8421579 0.8420439 0.8419284 0.8418116 0.8416934 [316] 0.8415738 0.8414528 0.8413305 0.8412067 0.8410816 0.8409551 0.8408272 [323] 0.8406980 0.8405673 0.8404352 0.8403018 0.8401670 0.8400307 0.8398931 [330] 0.8397541 0.8396137 0.8394718 0.8393286 0.8391840 0.8390380 0.8388906 [337] 0.8387418 0.8385916 0.8384400 0.8382869 0.8381325 0.8379767 0.8378194 [344] 0.8376608 0.8375007 0.8373393 0.8371764 0.8370121 0.8368464 0.8366793 [351] 0.8365108 0.8363409 0.8361695 0.8359968 0.8358226 0.8356470 0.8354700 [358] 0.8352916 0.8351117 0.8349305 0.8347478 0.8345637 0.8343782 0.8341913 [365] 0.8340030 0.8338132 0.8336220 0.8334294 0.8332354 0.8330399 0.8328431 [372] 0.8326448 0.8324451 0.8322440 0.8320414 0.8318375 0.8316321 0.8314252 [379] 0.8312170 0.8310074 0.8307963 0.8305838 0.8303698 0.8301545 0.8299377 [386] 0.8297195 0.8294999 0.8292789 0.8290564 0.8288326 0.8286073 0.8283805 [393] 0.8281524 0.8279228 0.8276919 0.8274595 0.8272256 0.8269904 0.8267537 [400] 0.8265157 0.8262762 > mx [1] 0.846988 > mxli [1] 0.23 > 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/freestat/rcomp/tmp/158nv1226326053.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/freestat/rcomp/tmp/26dn01226326053.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/freestat/rcomp/tmp/3vgr81226326053.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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/4iwj01226326054.tab") > > system("convert tmp/158nv1226326053.ps tmp/158nv1226326053.png") > system("convert tmp/26dn01226326053.ps tmp/26dn01226326053.png") > system("convert tmp/3vgr81226326053.ps tmp/3vgr81226326053.png") > > > proc.time() user system elapsed 1.509 0.798 1.628