R version 2.6.0 (2007-10-03) Copyright (C) 2007 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(1962.3,2095.2,2161,2115.1,1929,2004.5,2009.9,1524.9,2061.1,2261.6,2103.6,2224.3,2173.8,2119.2,2226.4,2159.6,1918.3,2116.1,1948.3,1514.3,2180.5,2312.6,2019.8,2200.8,2028.9,2178.7,2433.7,2230.5,1884.2,2372.7,1918.6,1679.4,2327.3,2225.2,2211.7,2463.6,2029.5,2173.6,2387,2234,2179.9,2397,1960.2,1824.1,2479.3,2234.9,2345.9,2428.9,2179.4,2216.9,2642.3,2340.5,2474.6,2641.8,2165.1,1996.2,2562.9,2529.9,2549.6,2455.1,2472,2424.7,2820.1,2666,2654.6,2732.2,2546.9) > x <- c(9884.9,10174.5,11395.4,10760.2,10570.1,10536,9902.6,8889,10837.3,11624.1,10509,10984.9,10649.1,10855.7,11677.4,10760.2,10046.2,10772.8,9987.7,8638.7,11063.7,11855.7,10684.5,11337.4,10478,11123.9,12909.3,11339.9,10462.2,12733.5,10519.2,10414.9,12476.8,12384.6,12266.7,12919.9,11497.3,12142,13919.4,12656.8,12034.1,13199.7,10881.3,11301.2,13643.9,12517,13981.1,14275.7,13435,13565.7,16216.3,12970,14079.9,14235,12213.4,12581,14130.4,14210.8,14378.5,13142.8,13714.7,13621.9,15379.8,14441.8,15354.8,15537.8,14552.7) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2007), Box-Cox Linearity Plot (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxlin.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description > 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.9013782 0.9014547 0.9015306 0.9016060 0.9016808 0.9017550 0.9018287 [8] 0.9019018 0.9019744 0.9020465 0.9021180 0.9021889 0.9022593 0.9023291 [15] 0.9023984 0.9024671 0.9025353 0.9026029 0.9026700 0.9027366 0.9028026 [22] 0.9028680 0.9029329 0.9029973 0.9030611 0.9031243 0.9031871 0.9032492 [29] 0.9033109 0.9033719 0.9034325 0.9034925 0.9035519 0.9036109 0.9036692 [36] 0.9037271 0.9037844 0.9038411 0.9038973 0.9039530 0.9040082 0.9040628 [43] 0.9041168 0.9041704 0.9042234 0.9042758 0.9043277 0.9043791 0.9044300 [50] 0.9044803 0.9045301 0.9045793 0.9046280 0.9046762 0.9047239 0.9047710 [57] 0.9048176 0.9048636 0.9049092 0.9049542 0.9049986 0.9050426 0.9050860 [64] 0.9051289 0.9051712 0.9052131 0.9052544 0.9052952 0.9053354 0.9053752 [71] 0.9054144 0.9054531 0.9054912 0.9055289 0.9055660 0.9056026 0.9056387 [78] 0.9056742 0.9057093 0.9057438 0.9057778 0.9058113 0.9058443 0.9058767 [85] 0.9059086 0.9059401 0.9059710 0.9060014 0.9060312 0.9060606 0.9060894 [92] 0.9061178 0.9061456 0.9061729 0.9061997 0.9062260 0.9062518 0.9062770 [99] 0.9063018 0.9063260 0.9063498 0.9063730 0.9063957 0.9064179 0.9064397 [106] 0.9064609 0.9064816 0.9065018 0.9065215 0.9065407 0.9065593 0.9065775 [113] 0.9065952 0.9066124 0.9066291 0.9066453 0.9066610 0.9066761 0.9066908 [120] 0.9067050 0.9067187 0.9067319 0.9067446 0.9067568 0.9067685 0.9067797 [127] 0.9067905 0.9068007 0.9068104 0.9068197 0.9068284 0.9068367 0.9068444 [134] 0.9068517 0.9068585 0.9068648 0.9068706 0.9068759 0.9068808 0.9068851 [141] 0.9068890 0.9068924 0.9068953 0.9068977 0.9068996 0.9069010 0.9069020 [148] 0.9069025 0.9069025 0.9069020 0.9069010 0.9068996 0.9068976 0.9068952 [155] 0.9068923 0.9068890 0.9068851 0.9068808 0.9068760 0.9068707 0.9068650 [162] 0.9068588 0.9068521 0.9068449 0.9068373 0.9068292 0.9068206 0.9068115 [169] 0.9068020 0.9067920 0.9067815 0.9067706 0.9067592 0.9067473 0.9067350 [176] 0.9067222 0.9067089 0.9066952 0.9066810 0.9066663 0.9066512 0.9066356 [183] 0.9066195 0.9066030 0.9065860 0.9065686 0.9065507 0.9065323 0.9065135 [190] 0.9064942 0.9064744 0.9064542 0.9064336 0.9064124 0.9063909 0.9063688 [197] 0.9063464 0.9063234 0.9063000 0.9062762 0.9062519 0.9062271 0.9062019 [204] 0.9061763 0.9061502 0.9061236 0.9060966 0.9060691 0.9060412 0.9060129 [211] 0.9059841 0.9059548 0.9059251 0.9058950 0.9058644 0.9058333 0.9058019 [218] 0.9057699 0.9057376 0.9057048 0.9056715 0.9056378 0.9056037 0.9055691 [225] 0.9055341 0.9054986 0.9054627 0.9054264 0.9053896 0.9053524 0.9053147 [232] 0.9052767 0.9052381 0.9051992 0.9051598 0.9051199 0.9050797 0.9050390 [239] 0.9049979 0.9049563 0.9049143 0.9048719 0.9048290 0.9047857 0.9047420 [246] 0.9046979 0.9046533 0.9046083 0.9045629 0.9045170 0.9044707 0.9044240 [253] 0.9043769 0.9043293 0.9042813 0.9042329 0.9041841 0.9041348 0.9040851 [260] 0.9040350 0.9039845 0.9039335 0.9038822 0.9038304 0.9037782 0.9037255 [267] 0.9036725 0.9036190 0.9035651 0.9035108 0.9034561 0.9034010 0.9033454 [274] 0.9032895 0.9032331 0.9031763 0.9031191 0.9030615 0.9030034 0.9029450 [281] 0.9028861 0.9028269 0.9027672 0.9027071 0.9026466 0.9025857 0.9025243 [288] 0.9024626 0.9024005 0.9023379 0.9022750 0.9022116 0.9021479 0.9020837 [295] 0.9020191 0.9019541 0.9018887 0.9018229 0.9017568 0.9016902 0.9016232 [302] 0.9015558 0.9014880 0.9014198 0.9013512 0.9012822 0.9012128 0.9011430 [309] 0.9010728 0.9010022 0.9009312 0.9008598 0.9007880 0.9007158 0.9006432 [316] 0.9005702 0.9004969 0.9004231 0.9003489 0.9002744 0.9001994 0.9001241 [323] 0.9000484 0.8999722 0.8998957 0.8998188 0.8997415 0.8996638 0.8995857 [330] 0.8995073 0.8994284 0.8993492 0.8992696 0.8991895 0.8991091 0.8990283 [337] 0.8989472 0.8988656 0.8987837 0.8987013 0.8986186 0.8985355 0.8984520 [344] 0.8983682 0.8982839 0.8981993 0.8981143 0.8980289 0.8979431 0.8978570 [351] 0.8977704 0.8976835 0.8975962 0.8975085 0.8974205 0.8973321 0.8972433 [358] 0.8971541 0.8970645 0.8969746 0.8968843 0.8967936 0.8967025 0.8966111 [365] 0.8965193 0.8964271 0.8963346 0.8962416 0.8961483 0.8960547 0.8959606 [372] 0.8958662 0.8957714 0.8956763 0.8955807 0.8954848 0.8953886 0.8952920 [379] 0.8951950 0.8950976 0.8949999 0.8949018 0.8948033 0.8947045 0.8946053 [386] 0.8945057 0.8944058 0.8943055 0.8942048 0.8941038 0.8940024 0.8939007 [393] 0.8937985 0.8936961 0.8935932 0.8934900 0.8933865 0.8932826 0.8931783 [400] 0.8930737 0.8929687 > mx [1] 0.9069025 > mxli [1] -0.53 > 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/1j98v1194211008.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/211cv1194211008.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/3ma2g1194211008.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 > 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/47rba1194211009.tab") > > system("convert tmp/1j98v1194211008.ps tmp/1j98v1194211008.png") > system("convert tmp/211cv1194211008.ps tmp/211cv1194211008.png") > system("convert tmp/3ma2g1194211008.ps tmp/3ma2g1194211008.png") > > > proc.time() user system elapsed 1.056 0.526 1.193