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(99.3,98.7,107.9,101.0,97.6,103.0,94.1,94.1,115.1,116.5,103.4,112.5,95.6,97.5,119.3,100.9,97.7,115.3,92.8,99.2,118.7,110.1,110.3,112.9,102.2,99.4,116.1,103.8,101.8,113.7,89.7,99.5,122.9,108.6,114.4,110.5,104.1,103.6,121.6,101.1,116.0,120.1,96.0,105.0,124.7,123.9,123.6,114.8,108.8,106.1,123.2,106.2,115.2,120.6,109.5,114.4,121.4,129.5,124.3,112.6) > x <- c(95.9,95.3,100.4,97.3,82.3,97.0,93.5,90.9,107.8,110.9,98.1,106.5,93.4,95.7,109.0,97.6,92.7,107.5,91.7,95.7,111.4,106.0,104.8,108.7,97.3,97.1,106.1,98.6,98.5,105.5,86.2,98.3,111.3,105.0,105.7,103.5,96.9,98.1,111.7,94.7,104.2,109.7,91.3,102.6,114.2,115.8,113.5,107.1,104.5,101.9,116.0,102.0,108.1,112.9,104.5,109.1,113.4,123.9,117.7,108.3) > #'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.9331285 0.9332757 0.9334226 0.9335691 0.9337152 0.9338609 0.9340063 [8] 0.9341513 0.9342959 0.9344401 0.9345840 0.9347275 0.9348706 0.9350134 [15] 0.9351557 0.9352977 0.9354393 0.9355806 0.9357215 0.9358619 0.9360021 [22] 0.9361418 0.9362812 0.9364202 0.9365588 0.9366970 0.9368349 0.9369724 [29] 0.9371095 0.9372463 0.9373827 0.9375187 0.9376543 0.9377895 0.9379244 [36] 0.9380589 0.9381930 0.9383268 0.9384602 0.9385932 0.9387258 0.9388580 [43] 0.9389899 0.9391214 0.9392526 0.9393833 0.9395137 0.9396437 0.9397733 [50] 0.9399026 0.9400315 0.9401600 0.9402881 0.9404159 0.9405433 0.9406703 [57] 0.9407969 0.9409232 0.9410491 0.9411746 0.9412998 0.9414245 0.9415489 [64] 0.9416730 0.9417966 0.9419199 0.9420428 0.9421653 0.9422875 0.9424093 [71] 0.9425307 0.9426517 0.9427724 0.9428927 0.9430126 0.9431321 0.9432513 [78] 0.9433701 0.9434885 0.9436066 0.9437243 0.9438416 0.9439585 0.9440751 [85] 0.9441913 0.9443071 0.9444225 0.9445376 0.9446523 0.9447666 0.9448806 [92] 0.9449942 0.9451074 0.9452202 0.9453327 0.9454448 0.9455565 0.9456678 [99] 0.9457788 0.9458894 0.9459997 0.9461095 0.9462190 0.9463281 0.9464369 [106] 0.9465453 0.9466533 0.9467609 0.9468682 0.9469750 0.9470816 0.9471877 [113] 0.9472935 0.9473989 0.9475039 0.9476086 0.9477129 0.9478168 0.9479204 [120] 0.9480236 0.9481264 0.9482288 0.9483309 0.9484326 0.9485339 0.9486349 [127] 0.9487355 0.9488357 0.9489356 0.9490350 0.9491342 0.9492329 0.9493313 [134] 0.9494293 0.9495269 0.9496242 0.9497211 0.9498176 0.9499138 0.9500096 [141] 0.9501050 0.9502000 0.9502947 0.9503890 0.9504830 0.9505766 0.9506698 [148] 0.9507626 0.9508551 0.9509472 0.9510389 0.9511303 0.9512213 0.9513119 [155] 0.9514022 0.9514921 0.9515816 0.9516708 0.9517596 0.9518480 0.9519361 [162] 0.9520238 0.9521111 0.9521981 0.9522847 0.9523709 0.9524568 0.9525423 [169] 0.9526274 0.9527122 0.9527965 0.9528806 0.9529642 0.9530475 0.9531305 [176] 0.9532130 0.9532952 0.9533771 0.9534586 0.9535397 0.9536204 0.9537008 [183] 0.9537808 0.9538604 0.9539397 0.9540186 0.9540972 0.9541754 0.9542532 [190] 0.9543307 0.9544077 0.9544845 0.9545608 0.9546368 0.9547125 0.9547878 [197] 0.9548627 0.9549372 0.9550114 0.9550852 0.9551587 0.9552318 0.9553045 [204] 0.9553769 0.9554489 0.9555205 0.9555918 0.9556627 0.9557333 0.9558035 [211] 0.9558733 0.9559428 0.9560119 0.9560807 0.9561490 0.9562171 0.9562847 [218] 0.9563520 0.9564190 0.9564856 0.9565518 0.9566176 0.9566831 0.9567483 [225] 0.9568130 0.9568775 0.9569415 0.9570052 0.9570685 0.9571315 0.9571941 [232] 0.9572564 0.9573183 0.9573798 0.9574410 0.9575018 0.9575623 0.9576224 [239] 0.9576821 0.9577415 0.9578005 0.9578592 0.9579175 0.9579755 0.9580331 [246] 0.9580903 0.9581472 0.9582037 0.9582598 0.9583156 0.9583711 0.9584262 [253] 0.9584809 0.9585353 0.9585893 0.9586430 0.9586963 0.9587492 0.9588018 [260] 0.9588540 0.9589059 0.9589574 0.9590086 0.9590594 0.9591099 0.9591600 [267] 0.9592097 0.9592591 0.9593081 0.9593568 0.9594051 0.9594531 0.9595007 [274] 0.9595480 0.9595949 0.9596414 0.9596876 0.9597335 0.9597790 0.9598241 [281] 0.9598689 0.9599133 0.9599574 0.9600011 0.9600445 0.9600875 0.9601302 [288] 0.9601725 0.9602144 0.9602560 0.9602973 0.9603382 0.9603787 0.9604189 [295] 0.9604588 0.9604983 0.9605374 0.9605762 0.9606146 0.9606527 0.9606905 [302] 0.9607279 0.9607649 0.9608016 0.9608379 0.9608739 0.9609095 0.9609448 [309] 0.9609797 0.9610143 0.9610486 0.9610825 0.9611160 0.9611492 0.9611820 [316] 0.9612145 0.9612466 0.9612784 0.9613099 0.9613410 0.9613717 0.9614021 [323] 0.9614322 0.9614619 0.9614912 0.9615202 0.9615489 0.9615772 0.9616052 [330] 0.9616328 0.9616600 0.9616870 0.9617135 0.9617398 0.9617657 0.9617912 [337] 0.9618164 0.9618412 0.9618657 0.9618899 0.9619137 0.9619372 0.9619603 [344] 0.9619831 0.9620055 0.9620276 0.9620493 0.9620707 0.9620918 0.9621125 [351] 0.9621328 0.9621528 0.9621725 0.9621919 0.9622108 0.9622295 0.9622478 [358] 0.9622657 0.9622834 0.9623006 0.9623176 0.9623341 0.9623504 0.9623663 [365] 0.9623819 0.9623971 0.9624120 0.9624265 0.9624407 0.9624545 0.9624680 [372] 0.9624812 0.9624940 0.9625065 0.9625187 0.9625305 0.9625420 0.9625531 [379] 0.9625639 0.9625743 0.9625844 0.9625942 0.9626036 0.9626127 0.9626215 [386] 0.9626299 0.9626379 0.9626457 0.9626531 0.9626601 0.9626668 0.9626732 [393] 0.9626793 0.9626850 0.9626903 0.9626954 0.9627001 0.9627044 0.9627084 [400] 0.9627121 0.9627155 > mx [1] 0.9627155 > 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/rcomp/tmp/1hpqn1228485650.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/22acl1228485650.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/3yg2p1228485650.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/4qao61228485650.tab") > > system("convert tmp/1hpqn1228485650.ps tmp/1hpqn1228485650.png") > system("convert tmp/22acl1228485650.ps tmp/22acl1228485650.png") > system("convert tmp/3yg2p1228485650.ps tmp/3yg2p1228485650.png") > > > proc.time() user system elapsed 0.778 0.505 0.911