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(122.6,115.4,109,129.1,102.8,96.2,127.7,128.9,126.5,119.8,113.2,114.1,134.1,130,121.8,132.1,105.3,103,117.1,126.3,138.1,119.5,138,135.5,178.6,162.2,176.9,204.9,132.2,142.5,164.3,174.9,175.4,143,158.7,155.4,176.6,163.3,178.9,182.7,158.9,115.5,169.4,168,159.8,129,157.9,169.5,169.1,183.6,168.9,186.2,227.1,126.4,169.3,175,133.9,110.1,104.3,108.7,112.6) > x <- c(87.1,110.5,110.8,104.2,88.9,89.8,90,93.9,91.3,87.8,99.7,73.5,79.2,96.9,95.2,95.6,89.7,92.8,88,101.1,92.7,95.8,103.8,81.8,87.1,105.9,108.1,102.6,93.7,103.5,100.6,113.3,102.4,102.1,106.9,87.3,93.1,109.1,120.3,104.9,92.6,109.8,111.4,117.9,121.6,117.8,124.2,106.8,102.7,116.8,113.6,96.1,85,83.2,84.9,83,79.6,83.2,83.8,82.8,71.4) > #'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.3574854 0.3575360 0.3575864 0.3576366 0.3576866 0.3577364 0.3577860 [8] 0.3578355 0.3578847 0.3579338 0.3579827 0.3580314 0.3580800 0.3581283 [15] 0.3581764 0.3582244 0.3582722 0.3583198 0.3583672 0.3584144 0.3584614 [22] 0.3585083 0.3585549 0.3586014 0.3586477 0.3586938 0.3587397 0.3587854 [29] 0.3588309 0.3588763 0.3589214 0.3589664 0.3590112 0.3590558 0.3591002 [36] 0.3591444 0.3591884 0.3592323 0.3592759 0.3593194 0.3593626 0.3594057 [43] 0.3594486 0.3594913 0.3595339 0.3595762 0.3596183 0.3596603 0.3597020 [50] 0.3597436 0.3597850 0.3598262 0.3598672 0.3599080 0.3599486 0.3599891 [57] 0.3600293 0.3600694 0.3601092 0.3601489 0.3601884 0.3602277 0.3602668 [64] 0.3603057 0.3603445 0.3603830 0.3604213 0.3604595 0.3604975 0.3605352 [71] 0.3605728 0.3606102 0.3606474 0.3606844 0.3607212 0.3607579 0.3607943 [78] 0.3608306 0.3608666 0.3609025 0.3609382 0.3609736 0.3610089 0.3610440 [85] 0.3610789 0.3611137 0.3611482 0.3611825 0.3612167 0.3612506 0.3612844 [92] 0.3613180 0.3613513 0.3613845 0.3614175 0.3614503 0.3614829 0.3615154 [99] 0.3615476 0.3615796 0.3616115 0.3616431 0.3616746 0.3617059 0.3617369 [106] 0.3617678 0.3617985 0.3618290 0.3618593 0.3618894 0.3619194 0.3619491 [113] 0.3619787 0.3620080 0.3620372 0.3620661 0.3620949 0.3621235 0.3621519 [120] 0.3621801 0.3622081 0.3622359 0.3622635 0.3622910 0.3623182 0.3623452 [127] 0.3623721 0.3623988 0.3624252 0.3624515 0.3624776 0.3625035 0.3625292 [134] 0.3625547 0.3625800 0.3626051 0.3626301 0.3626548 0.3626794 0.3627037 [141] 0.3627279 0.3627519 0.3627756 0.3627992 0.3628226 0.3628458 0.3628688 [148] 0.3628917 0.3629143 0.3629367 0.3629590 0.3629810 0.3630029 0.3630245 [155] 0.3630460 0.3630673 0.3630884 0.3631093 0.3631300 0.3631505 0.3631708 [162] 0.3631910 0.3632109 0.3632307 0.3632502 0.3632696 0.3632888 0.3633077 [169] 0.3633265 0.3633451 0.3633635 0.3633818 0.3633998 0.3634176 0.3634353 [176] 0.3634527 0.3634700 0.3634870 0.3635039 0.3635206 0.3635371 0.3635534 [183] 0.3635695 0.3635854 0.3636012 0.3636167 0.3636321 0.3636472 0.3636622 [190] 0.3636770 0.3636915 0.3637059 0.3637201 0.3637341 0.3637480 0.3637616 [197] 0.3637750 0.3637883 0.3638014 0.3638142 0.3638269 0.3638394 0.3638517 [204] 0.3638638 0.3638757 0.3638874 0.3638990 0.3639103 0.3639215 0.3639325 [211] 0.3639432 0.3639538 0.3639642 0.3639744 0.3639845 0.3639943 0.3640039 [218] 0.3640134 0.3640226 0.3640317 0.3640406 0.3640493 0.3640578 0.3640661 [225] 0.3640743 0.3640822 0.3640899 0.3640975 0.3641049 0.3641121 0.3641191 [232] 0.3641259 0.3641325 0.3641389 0.3641452 0.3641512 0.3641571 0.3641628 [239] 0.3641683 0.3641736 0.3641787 0.3641836 0.3641884 0.3641929 0.3641973 [246] 0.3642015 0.3642054 0.3642093 0.3642129 0.3642163 0.3642195 0.3642226 [253] 0.3642255 0.3642282 0.3642307 0.3642330 0.3642351 0.3642370 0.3642388 [260] 0.3642403 0.3642417 0.3642429 0.3642439 0.3642447 0.3642454 0.3642458 [267] 0.3642461 0.3642462 0.3642461 0.3642458 0.3642453 0.3642446 0.3642438 [274] 0.3642428 0.3642416 0.3642402 0.3642386 0.3642368 0.3642349 0.3642327 [281] 0.3642304 0.3642279 0.3642252 0.3642223 0.3642193 0.3642160 0.3642126 [288] 0.3642090 0.3642052 0.3642013 0.3641971 0.3641928 0.3641882 0.3641835 [295] 0.3641786 0.3641736 0.3641683 0.3641629 0.3641573 0.3641515 0.3641455 [302] 0.3641393 0.3641330 0.3641265 0.3641198 0.3641129 0.3641058 0.3640986 [309] 0.3640911 0.3640835 0.3640757 0.3640678 0.3640596 0.3640513 0.3640428 [316] 0.3640341 0.3640252 0.3640161 0.3640069 0.3639975 0.3639879 0.3639781 [323] 0.3639682 0.3639580 0.3639477 0.3639372 0.3639266 0.3639157 0.3639047 [330] 0.3638935 0.3638821 0.3638706 0.3638588 0.3638469 0.3638348 0.3638225 [337] 0.3638101 0.3637975 0.3637847 0.3637717 0.3637585 0.3637452 0.3637317 [344] 0.3637180 0.3637041 0.3636901 0.3636759 0.3636615 0.3636469 0.3636322 [351] 0.3636173 0.3636022 0.3635869 0.3635715 0.3635559 0.3635401 0.3635241 [358] 0.3635080 0.3634916 0.3634751 0.3634585 0.3634416 0.3634246 0.3634074 [365] 0.3633901 0.3633725 0.3633548 0.3633370 0.3633189 0.3633007 0.3632823 [372] 0.3632637 0.3632450 0.3632261 0.3632070 0.3631877 0.3631683 0.3631487 [379] 0.3631289 0.3631090 0.3630888 0.3630686 0.3630481 0.3630275 0.3630067 [386] 0.3629857 0.3629646 0.3629432 0.3629218 0.3629001 0.3628783 0.3628563 [393] 0.3628341 0.3628118 0.3627893 0.3627667 0.3627438 0.3627208 0.3626977 [400] 0.3626743 0.3626508 > mx [1] 0.3642462 > mxli [1] 0.67 > 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/1olqy1258144691.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/2ura91258144691.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/3fmaw1258144691.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/493wt1258144691.tab") > > system("convert tmp/1olqy1258144691.ps tmp/1olqy1258144691.png") > system("convert tmp/2ura91258144691.ps tmp/2ura91258144691.png") > system("convert tmp/3fmaw1258144691.ps tmp/3fmaw1258144691.png") > > > proc.time() user system elapsed 0.818 0.528 1.098