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(95.40,99.31,101.80,100.53,102.28,101.89,98.08,98.98,100.02,100.58,100.67,100.46,98.47,102.01,103.28,103.70,104.64,106.31,107.16,108.10,104.90,105.27,107.37,110.01,114.11,116.22,118.06,119.35,120.48,117.02,121.66,127.88,128.58,130.42,126.28,129.31,132.59,125.91,127.88,119.59,118.46,116.31,120.72,122.21,115.00,107.99,109.98,106.01,87.58,82.17,81.99,80.08,73.35,69.01,76.23,80.10,81.96,82.79,89.42,91.90) > x <- c(90.21,93.24,95.60,97.58,100.81,101.65,102.08,100.18,101.36,103.46,106.59,107.24,107.84,110.08,114.34,120.00,124.78,128.21,127.48,124.39,116.83,121.13,126.39,129.92,135.43,137.43,140.42,145.42,147.35,142.58,150.25,153.71,151.23,149.32,137.53,140.60,145.14,134.34,134.72,125.81,121.77,120.24,126.24,124.39,114.68,99.24,99.71,96.94,71.92,65.92,60.96,62.35,59.26,54.65,61.01,67.15,66.42,67.77,75.05,79.95) > #'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.8942088 0.8945288 0.8948483 0.8951671 0.8954854 0.8958030 0.8961200 [8] 0.8964364 0.8967522 0.8970673 0.8973818 0.8976957 0.8980089 0.8983214 [15] 0.8986333 0.8989445 0.8992551 0.8995649 0.8998741 0.9001826 0.9004904 [22] 0.9007975 0.9011039 0.9014096 0.9017146 0.9020188 0.9023223 0.9026251 [29] 0.9029272 0.9032285 0.9035290 0.9038288 0.9041279 0.9044261 0.9047236 [36] 0.9050203 0.9053163 0.9056114 0.9059058 0.9061993 0.9064920 0.9067840 [43] 0.9070751 0.9073653 0.9076548 0.9079434 0.9082312 0.9085181 0.9088042 [50] 0.9090894 0.9093738 0.9096573 0.9099399 0.9102216 0.9105024 0.9107824 [57] 0.9110614 0.9113396 0.9116168 0.9118931 0.9121685 0.9124430 0.9127165 [64] 0.9129891 0.9132608 0.9135315 0.9138012 0.9140700 0.9143378 0.9146047 [71] 0.9148705 0.9151354 0.9153993 0.9156622 0.9159241 0.9161850 0.9164448 [78] 0.9167037 0.9169615 0.9172183 0.9174741 0.9177288 0.9179825 0.9182351 [85] 0.9184867 0.9187372 0.9189866 0.9192350 0.9194822 0.9197284 0.9199735 [92] 0.9202175 0.9204604 0.9207022 0.9209429 0.9211825 0.9214209 0.9216582 [99] 0.9218944 0.9221294 0.9223633 0.9225960 0.9228276 0.9230580 0.9232872 [106] 0.9235153 0.9237422 0.9239679 0.9241924 0.9244158 0.9246379 0.9248588 [113] 0.9250786 0.9252971 0.9255143 0.9257304 0.9259452 0.9261588 0.9263712 [120] 0.9265823 0.9267921 0.9270007 0.9272081 0.9274142 0.9276190 0.9278225 [127] 0.9280248 0.9282257 0.9284254 0.9286238 0.9288209 0.9290167 0.9292112 [134] 0.9294043 0.9295962 0.9297867 0.9299759 0.9301638 0.9303503 0.9305355 [141] 0.9307193 0.9309018 0.9310830 0.9312628 0.9314412 0.9316183 0.9317940 [148] 0.9319683 0.9321412 0.9323128 0.9324829 0.9326517 0.9328191 0.9329851 [155] 0.9331497 0.9333128 0.9334746 0.9336349 0.9337939 0.9339514 0.9341075 [162] 0.9342621 0.9344153 0.9345671 0.9347174 0.9348663 0.9350138 0.9351598 [169] 0.9353043 0.9354474 0.9355890 0.9357291 0.9358678 0.9360050 0.9361407 [176] 0.9362750 0.9364078 0.9365391 0.9366689 0.9367972 0.9369240 0.9370493 [183] 0.9371731 0.9372955 0.9374163 0.9375356 0.9376534 0.9377697 0.9378844 [190] 0.9379977 0.9381094 0.9382196 0.9383283 0.9384354 0.9385410 0.9386451 [197] 0.9387477 0.9388487 0.9389482 0.9390461 0.9391425 0.9392373 0.9393306 [204] 0.9394224 0.9395126 0.9396012 0.9396883 0.9397738 0.9398578 0.9399402 [211] 0.9400211 0.9401003 0.9401781 0.9402542 0.9403288 0.9404018 0.9404733 [218] 0.9405431 0.9406114 0.9406782 0.9407433 0.9408069 0.9408689 0.9409293 [225] 0.9409881 0.9410454 0.9411011 0.9411552 0.9412077 0.9412586 0.9413080 [232] 0.9413557 0.9414019 0.9414465 0.9414895 0.9415309 0.9415708 0.9416090 [239] 0.9416457 0.9416807 0.9417142 0.9417461 0.9417764 0.9418052 0.9418323 [246] 0.9418578 0.9418818 0.9419042 0.9419250 0.9419442 0.9419618 0.9419778 [253] 0.9419922 0.9420051 0.9420164 0.9420261 0.9420342 0.9420407 0.9420456 [260] 0.9420490 0.9420508 0.9420510 0.9420496 0.9420467 0.9420421 0.9420360 [267] 0.9420284 0.9420191 0.9420083 0.9419959 0.9419819 0.9419664 0.9419493 [274] 0.9419307 0.9419104 0.9418886 0.9418653 0.9418404 0.9418139 0.9417859 [281] 0.9417563 0.9417252 0.9416926 0.9416583 0.9416226 0.9415853 0.9415464 [288] 0.9415060 0.9414641 0.9414206 0.9413756 0.9413291 0.9412811 0.9412315 [295] 0.9411804 0.9411277 0.9410736 0.9410179 0.9409607 0.9409021 0.9408419 [302] 0.9407801 0.9407169 0.9406522 0.9405860 0.9405183 0.9404491 0.9403784 [309] 0.9403063 0.9402326 0.9401575 0.9400809 0.9400028 0.9399232 0.9398422 [316] 0.9397597 0.9396757 0.9395903 0.9395035 0.9394151 0.9393254 0.9392341 [323] 0.9391415 0.9390474 0.9389519 0.9388549 0.9387565 0.9386567 0.9385555 [330] 0.9384528 0.9383488 0.9382433 0.9381364 0.9380282 0.9379185 0.9378074 [337] 0.9376950 0.9375811 0.9374659 0.9373493 0.9372313 0.9371120 0.9369913 [344] 0.9368692 0.9367458 0.9366210 0.9364949 0.9363674 0.9362386 0.9361084 [351] 0.9359769 0.9358441 0.9357100 0.9355745 0.9354377 0.9352997 0.9351603 [358] 0.9350196 0.9348776 0.9347343 0.9345898 0.9344439 0.9342968 0.9341484 [365] 0.9339987 0.9338478 0.9336956 0.9335421 0.9333874 0.9332315 0.9330743 [372] 0.9329158 0.9327562 0.9325953 0.9324332 0.9322699 0.9321053 0.9319396 [379] 0.9317726 0.9316045 0.9314351 0.9312646 0.9310929 0.9309200 0.9307459 [386] 0.9305707 0.9303943 0.9302168 0.9300381 0.9298582 0.9296772 0.9294951 [393] 0.9293118 0.9291274 0.9289419 0.9287553 0.9285675 0.9283786 0.9281887 [400] 0.9279976 0.9278055 > mx [1] 0.942051 > mxli [1] 0.61 > 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/1z69r1257690002.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/2kkoq1257690002.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/3nzrv1257690002.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/4gtcs1257690002.tab") > > system("convert tmp/1z69r1257690002.ps tmp/1z69r1257690002.png") > system("convert tmp/2kkoq1257690002.ps tmp/2kkoq1257690002.png") > system("convert tmp/3nzrv1257690002.ps tmp/3nzrv1257690002.png") > > > proc.time() user system elapsed 1.259 0.842 1.366