R version 2.8.0 (2008-10-20) 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(527070,509846,514258,516922,507561,492622,490243,469357,477580,528379,533590,517945,506174) > x <- c(250643,243422,247105,248541,245039,237080,237085,225554,226839,247934,248333,246969,245098) > #'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.9473261 0.9473517 0.9473750 0.9473992 0.9474211 0.9474421 0.9474653 [8] 0.9474895 0.9475098 0.9475322 0.9475547 0.9475783 0.9476036 0.9476261 [15] 0.9476491 0.9476704 0.9476943 0.9477155 0.9477381 0.9477605 0.9477829 [22] 0.9478061 0.9478277 0.9478507 0.9478738 0.9478956 0.9479184 0.9479411 [29] 0.9479631 0.9479860 0.9480082 0.9480307 0.9480531 0.9480755 0.9480977 [36] 0.9481200 0.9481423 0.9481647 0.9481871 0.9482095 0.9482317 0.9482539 [43] 0.9482762 0.9482984 0.9483206 0.9483428 0.9483650 0.9483872 0.9484093 [50] 0.9484315 0.9484536 0.9484757 0.9484978 0.9485199 0.9485420 0.9485641 [57] 0.9485861 0.9486081 0.9486302 0.9486521 0.9486741 0.9486961 0.9487181 [64] 0.9487400 0.9487619 0.9487838 0.9488057 0.9488276 0.9488495 0.9488714 [71] 0.9488932 0.9489150 0.9489368 0.9489586 0.9489804 0.9490022 0.9490239 [78] 0.9490457 0.9490674 0.9490891 0.9491108 0.9491325 0.9491541 0.9491758 [85] 0.9491974 0.9492190 0.9492406 0.9492622 0.9492838 0.9493054 0.9493269 [92] 0.9493484 0.9493700 0.9493915 0.9494130 0.9494344 0.9494559 0.9494773 [99] 0.9494987 0.9495202 0.9495416 0.9495629 0.9495843 0.9496057 0.9496270 [106] 0.9496483 0.9496696 0.9496909 0.9497122 0.9497335 0.9497547 0.9497760 [113] 0.9497972 0.9498184 0.9498396 0.9498608 0.9498819 0.9499031 0.9499242 [120] 0.9499453 0.9499664 0.9499875 0.9500086 0.9500296 0.9500507 0.9500717 [127] 0.9500927 0.9501137 0.9501347 0.9501556 0.9501766 0.9501975 0.9502184 [134] 0.9502394 0.9502602 0.9502811 0.9503020 0.9503228 0.9503437 0.9503645 [141] 0.9503853 0.9504061 0.9504268 0.9504476 0.9504683 0.9504891 0.9505098 [148] 0.9505305 0.9505511 0.9505718 0.9505925 0.9506131 0.9506337 0.9506543 [155] 0.9506749 0.9506955 0.9507160 0.9507366 0.9507571 0.9507776 0.9507981 [162] 0.9508186 0.9508391 0.9508595 0.9508800 0.9509004 0.9509208 0.9509412 [169] 0.9509616 0.9509819 0.9510023 0.9510226 0.9510429 0.9510632 0.9510835 [176] 0.9511038 0.9511241 0.9511443 0.9511645 0.9511847 0.9512049 0.9512251 [183] 0.9512453 0.9512654 0.9512856 0.9513057 0.9513258 0.9513459 0.9513659 [190] 0.9513860 0.9514060 0.9514261 0.9514461 0.9514661 0.9514861 0.9515060 [197] 0.9515260 0.9515459 0.9515658 0.9515857 0.9516056 0.9516255 0.9516454 [204] 0.9516652 0.9516850 0.9517048 0.9517246 0.9517444 0.9517642 0.9517839 [211] 0.9518037 0.9518234 0.9518431 0.9518628 0.9518825 0.9519021 0.9519218 [218] 0.9519414 0.9519610 0.9519806 0.9520002 0.9520198 0.9520393 0.9520588 [225] 0.9520784 0.9520979 0.9521174 0.9521368 0.9521563 0.9521757 0.9521952 [232] 0.9522146 0.9522340 0.9522533 0.9522727 0.9522921 0.9523114 0.9523307 [239] 0.9523500 0.9523693 0.9523886 0.9524078 0.9524271 0.9524463 0.9524655 [246] 0.9524847 0.9525039 0.9525230 0.9525422 0.9525613 0.9525804 0.9525995 [253] 0.9526186 0.9526377 0.9526568 0.9526758 0.9526948 0.9527138 0.9527328 [260] 0.9527518 0.9527708 0.9527897 0.9528086 0.9528275 0.9528464 0.9528653 [267] 0.9528842 0.9529030 0.9529219 0.9529407 0.9529595 0.9529783 0.9529971 [274] 0.9530158 0.9530346 0.9530533 0.9530720 0.9530907 0.9531094 0.9531280 [281] 0.9531467 0.9531653 0.9531839 0.9532025 0.9532211 0.9532397 0.9532582 [288] 0.9532768 0.9532953 0.9533138 0.9533323 0.9533508 0.9533692 0.9533877 [295] 0.9534061 0.9534245 0.9534429 0.9534613 0.9534796 0.9534980 0.9535163 [302] 0.9535346 0.9535529 0.9535712 0.9535895 0.9536077 0.9536260 0.9536442 [309] 0.9536624 0.9536806 0.9536988 0.9537169 0.9537351 0.9537532 0.9537713 [316] 0.9537894 0.9538075 0.9538255 0.9538436 0.9538616 0.9538796 0.9538976 [323] 0.9539156 0.9539336 0.9539515 0.9539695 0.9539874 0.9540053 0.9540232 [330] 0.9540411 0.9540589 0.9540768 0.9540946 0.9541124 0.9541302 0.9541480 [337] 0.9541657 0.9541835 0.9542012 0.9542189 0.9542366 0.9542543 0.9542720 [344] 0.9542896 0.9543072 0.9543249 0.9543425 0.9543600 0.9543776 0.9543952 [351] 0.9544127 0.9544302 0.9544477 0.9544652 0.9544827 0.9545002 0.9545176 [358] 0.9545350 0.9545524 0.9545698 0.9545872 0.9546046 0.9546219 0.9546392 [365] 0.9546565 0.9546738 0.9546911 0.9547084 0.9547256 0.9547429 0.9547601 [372] 0.9547773 0.9547945 0.9548116 0.9548288 0.9548459 0.9548630 0.9548802 [379] 0.9548972 0.9549143 0.9549314 0.9549484 0.9549654 0.9549824 0.9549994 [386] 0.9550164 0.9550334 0.9550503 0.9550672 0.9550841 0.9551010 0.9551179 [393] 0.9551348 0.9551516 0.9551685 0.9551853 0.9552021 0.9552188 0.9552356 [400] 0.9552524 0.9552691 > mx [1] 0.955269 > mxli [1] 2 > 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/15e3d1226481848.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/2qogg1226481848.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/3uk6u1226481848.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/4176i1226481848.tab") > > system("convert tmp/15e3d1226481848.ps tmp/15e3d1226481848.png") > system("convert tmp/2qogg1226481848.ps tmp/2qogg1226481848.png") > system("convert tmp/3uk6u1226481848.ps tmp/3uk6u1226481848.png") > > > proc.time() user system elapsed 1.205 0.814 1.331