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(111.69,100.5,106.29,101.09,104.53,122.74,109.84,101.99,125.12,103.5,102.8,118.72,119.01,118.61,120.43,111.83,116.79,131.71,120.57,117.83,130.8,107.46,112.09,129.47,119.72,134.81,135.8,129.27,126.94,153.45,121.86,133.47,135.34,117.1,120.65,132.49,137.6,138.69,125.53,133.09,129.08,145.94,129.07,139.69,142.09,137.29,127.03,137.25,156.87,150.89,139.14,158.3,149,158.36,168.06,153.38,173.86,162.47,145.17,168.89,166.64,140.07,128.84,123.41,120.3,129.67,118.1,113.91,131.09,119.15) > x <- c(115.47,103.34,102.6,100.69,105.67,123.61,113.08,106.46,123.38,109.87,95.74,123.06,123.39,120.28,115.33,110.4,114.49,132.03,123.16,118.82,128.32,112.24,104.53,132.57,122.52,131.8,124.55,120.96,122.6,145.52,118.57,134.25,136.7,121.37,111.63,134.42,137.65,137.86,119.77,130.69,128.28,147.45,128.42,136.9,143.95,135.64,122.48,136.83,153.04,142.71,123.46,144.37,146.15,147.61,158.51,147.4,165.05,154.64,126.2,157.36,154.15,123.21,113.07,110.45,113.57,122.44,114.93,111.85,126.04,121.34) > #'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.9115384 0.9117245 0.9119101 0.9120952 0.9122799 0.9124642 0.9126480 [8] 0.9128313 0.9130142 0.9131967 0.9133787 0.9135602 0.9137413 0.9139219 [15] 0.9141021 0.9142819 0.9144612 0.9146400 0.9148184 0.9149963 0.9151738 [22] 0.9153508 0.9155273 0.9157034 0.9158791 0.9160543 0.9162290 0.9164033 [29] 0.9165771 0.9167504 0.9169233 0.9170958 0.9172678 0.9174393 0.9176103 [36] 0.9177809 0.9179511 0.9181207 0.9182900 0.9184587 0.9186270 0.9187948 [43] 0.9189622 0.9191291 0.9192955 0.9194615 0.9196270 0.9197921 0.9199566 [50] 0.9201208 0.9202844 0.9204476 0.9206103 0.9207726 0.9209343 0.9210957 [57] 0.9212565 0.9214169 0.9215768 0.9217362 0.9218952 0.9220537 0.9222117 [64] 0.9223693 0.9225264 0.9226830 0.9228392 0.9229949 0.9231501 0.9233048 [71] 0.9234591 0.9236129 0.9237662 0.9239190 0.9240714 0.9242233 0.9243747 [78] 0.9245257 0.9246762 0.9248262 0.9249757 0.9251248 0.9252734 0.9254215 [85] 0.9255691 0.9257163 0.9258629 0.9260091 0.9261549 0.9263001 0.9264449 [92] 0.9265892 0.9267330 0.9268763 0.9270192 0.9271616 0.9273035 0.9274449 [99] 0.9275859 0.9277263 0.9278663 0.9280058 0.9281449 0.9282834 0.9284215 [106] 0.9285591 0.9286962 0.9288328 0.9289690 0.9291046 0.9292398 0.9293745 [113] 0.9295088 0.9296425 0.9297757 0.9299085 0.9300408 0.9301726 0.9303040 [120] 0.9304348 0.9305652 0.9306950 0.9308244 0.9309534 0.9310818 0.9312097 [127] 0.9313372 0.9314642 0.9315907 0.9317167 0.9318422 0.9319672 0.9320918 [134] 0.9322159 0.9323394 0.9324625 0.9325852 0.9327073 0.9328289 0.9329501 [141] 0.9330708 0.9331909 0.9333106 0.9334298 0.9335486 0.9336668 0.9337846 [148] 0.9339018 0.9340186 0.9341349 0.9342507 0.9343660 0.9344809 0.9345952 [155] 0.9347091 0.9348224 0.9349353 0.9350477 0.9351596 0.9352711 0.9353820 [162] 0.9354924 0.9356024 0.9357119 0.9358208 0.9359293 0.9360373 0.9361449 [169] 0.9362519 0.9363584 0.9364645 0.9365701 0.9366751 0.9367797 0.9368838 [176] 0.9369874 0.9370906 0.9371932 0.9372953 0.9373970 0.9374982 0.9375988 [183] 0.9376990 0.9377987 0.9378980 0.9379967 0.9380949 0.9381927 0.9382899 [190] 0.9383867 0.9384830 0.9385788 0.9386741 0.9387689 0.9388632 0.9389571 [197] 0.9390504 0.9391433 0.9392357 0.9393276 0.9394190 0.9395099 0.9396003 [204] 0.9396902 0.9397797 0.9398686 0.9399571 0.9400451 0.9401326 0.9402196 [211] 0.9403061 0.9403921 0.9404776 0.9405627 0.9406473 0.9407313 0.9408149 [218] 0.9408980 0.9409806 0.9410628 0.9411444 0.9412255 0.9413062 0.9413864 [225] 0.9414661 0.9415453 0.9416240 0.9417022 0.9417800 0.9418572 0.9419340 [232] 0.9420103 0.9420861 0.9421614 0.9422362 0.9423105 0.9423844 0.9424577 [239] 0.9425306 0.9426030 0.9426749 0.9427463 0.9428173 0.9428877 0.9429577 [246] 0.9430272 0.9430962 0.9431647 0.9432327 0.9433002 0.9433673 0.9434339 [253] 0.9434999 0.9435656 0.9436307 0.9436953 0.9437595 0.9438231 0.9438863 [260] 0.9439490 0.9440112 0.9440730 0.9441342 0.9441950 0.9442553 0.9443151 [267] 0.9443744 0.9444333 0.9444917 0.9445495 0.9446069 0.9446639 0.9447203 [274] 0.9447763 0.9448317 0.9448867 0.9449413 0.9449953 0.9450489 0.9451019 [281] 0.9451545 0.9452067 0.9452583 0.9453095 0.9453602 0.9454104 0.9454601 [288] 0.9455093 0.9455581 0.9456064 0.9456542 0.9457016 0.9457484 0.9457948 [295] 0.9458407 0.9458862 0.9459311 0.9459756 0.9460196 0.9460632 0.9461062 [302] 0.9461488 0.9461909 0.9462326 0.9462737 0.9463144 0.9463546 0.9463944 [309] 0.9464337 0.9464725 0.9465108 0.9465486 0.9465860 0.9466229 0.9466594 [316] 0.9466953 0.9467308 0.9467659 0.9468004 0.9468345 0.9468681 0.9469013 [323] 0.9469339 0.9469661 0.9469979 0.9470292 0.9470600 0.9470903 0.9471202 [330] 0.9471496 0.9471785 0.9472070 0.9472350 0.9472625 0.9472896 0.9473162 [337] 0.9473423 0.9473680 0.9473932 0.9474180 0.9474422 0.9474661 0.9474894 [344] 0.9475123 0.9475347 0.9475567 0.9475782 0.9475993 0.9476198 0.9476400 [351] 0.9476596 0.9476788 0.9476976 0.9477158 0.9477337 0.9477510 0.9477679 [358] 0.9477844 0.9478004 0.9478159 0.9478310 0.9478456 0.9478598 0.9478735 [365] 0.9478867 0.9478995 0.9479118 0.9479237 0.9479352 0.9479461 0.9479566 [372] 0.9479667 0.9479763 0.9479855 0.9479942 0.9480025 0.9480103 0.9480176 [379] 0.9480245 0.9480310 0.9480370 0.9480425 0.9480476 0.9480523 0.9480565 [386] 0.9480603 0.9480636 0.9480664 0.9480689 0.9480708 0.9480724 0.9480734 [393] 0.9480741 0.9480743 0.9480740 0.9480733 0.9480722 0.9480706 0.9480685 [400] 0.9480661 0.9480631 > mx [1] 0.9480743 > mxli [1] 1.93 > 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/1t5ro1258035833.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/203z71258035833.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/3hry01258035833.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/46h4z1258035833.tab") > > system("convert tmp/1t5ro1258035833.ps tmp/1t5ro1258035833.png") > system("convert tmp/203z71258035833.ps tmp/203z71258035833.png") > system("convert tmp/3hry01258035833.ps tmp/3hry01258035833.png") > > > proc.time() user system elapsed 1.226 0.808 1.418