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(108.8,128.4,121.1,119.5,128.7,108.7,105.5,119.8,111.3,110.6,120.1,97.5,107.7,127.3,117.2,119.8,116.2,111,112.4,130.6,109.1,118.8,123.9,101.6,112.8,128,129.6,125.8,119.5,115.7,113.6,129.7,112,116.8,127,112.1,114.2,121.1,131.6,125,120.4,117.7,117.5,120.6,127.5,112.3,124.5,115.2,104.7,130.9,129.2,113.5,125.6,107.6,107,121.6,110.7,106.3,118.6,104.6) > x <- c(83.4,113.6,112.9,104,109.9,99,106.3,128.9,111.1,102.9,130,87,87.5,117.6,103.4,110.8,112.6,102.5,112.4,135.6,105.1,127.7,137,91,90.5,122.4,123.3,124.3,120,118.1,119,142.7,123.6,129.6,151.6,110.4,99.2,130.5,136.2,129.7,128,121.6,135.8,143.8,147.5,136.2,156.6,123.3,104.5,139.8,136.5,112.1,118.5,94.4,102.3,111.4,99.2,87.8,115.8,79.7) > #'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.7454254 0.7455258 0.7456255 0.7457245 0.7458228 0.7459204 0.7460172 [8] 0.7461134 0.7462088 0.7463035 0.7463975 0.7464908 0.7465834 0.7466753 [15] 0.7467664 0.7468568 0.7469465 0.7470355 0.7471238 0.7472113 0.7472981 [22] 0.7473842 0.7474695 0.7475542 0.7476381 0.7477212 0.7478037 0.7478854 [29] 0.7479664 0.7480467 0.7481262 0.7482050 0.7482830 0.7483604 0.7484370 [36] 0.7485128 0.7485879 0.7486623 0.7487360 0.7488089 0.7488810 0.7489525 [43] 0.7490232 0.7490931 0.7491623 0.7492308 0.7492985 0.7493655 0.7494317 [50] 0.7494972 0.7495619 0.7496259 0.7496892 0.7497517 0.7498135 0.7498745 [57] 0.7499347 0.7499942 0.7500530 0.7501110 0.7501682 0.7502247 0.7502805 [64] 0.7503355 0.7503897 0.7504432 0.7504960 0.7505479 0.7505992 0.7506496 [71] 0.7506993 0.7507483 0.7507965 0.7508439 0.7508906 0.7509365 0.7509817 [78] 0.7510261 0.7510697 0.7511126 0.7511547 0.7511960 0.7512366 0.7512765 [85] 0.7513155 0.7513538 0.7513914 0.7514281 0.7514642 0.7514994 0.7515339 [92] 0.7515676 0.7516005 0.7516327 0.7516641 0.7516948 0.7517247 0.7517538 [99] 0.7517821 0.7518097 0.7518365 0.7518625 0.7518878 0.7519123 0.7519360 [106] 0.7519590 0.7519812 0.7520026 0.7520232 0.7520431 0.7520622 0.7520805 [113] 0.7520981 0.7521149 0.7521309 0.7521462 0.7521606 0.7521743 0.7521873 [120] 0.7521994 0.7522108 0.7522214 0.7522313 0.7522403 0.7522486 0.7522561 [127] 0.7522629 0.7522688 0.7522740 0.7522784 0.7522821 0.7522850 0.7522871 [134] 0.7522884 0.7522889 0.7522887 0.7522877 0.7522859 0.7522834 0.7522801 [141] 0.7522760 0.7522711 0.7522654 0.7522590 0.7522518 0.7522438 0.7522351 [148] 0.7522256 0.7522153 0.7522042 0.7521924 0.7521797 0.7521664 0.7521522 [155] 0.7521372 0.7521215 0.7521050 0.7520878 0.7520698 0.7520509 0.7520314 [162] 0.7520110 0.7519899 0.7519680 0.7519453 0.7519219 0.7518976 0.7518726 [169] 0.7518469 0.7518203 0.7517930 0.7517650 0.7517361 0.7517065 0.7516761 [176] 0.7516449 0.7516130 0.7515803 0.7515468 0.7515126 0.7514776 0.7514418 [183] 0.7514053 0.7513679 0.7513299 0.7512910 0.7512514 0.7512110 0.7511698 [190] 0.7511279 0.7510852 0.7510418 0.7509976 0.7509526 0.7509068 0.7508603 [197] 0.7508130 0.7507650 0.7507162 0.7506666 0.7506163 0.7505652 0.7505134 [204] 0.7504607 0.7504074 0.7503532 0.7502983 0.7502427 0.7501863 0.7501291 [211] 0.7500712 0.7500125 0.7499530 0.7498928 0.7498319 0.7497702 0.7497077 [218] 0.7496445 0.7495805 0.7495158 0.7494503 0.7493840 0.7493171 0.7492493 [225] 0.7491808 0.7491116 0.7490416 0.7489708 0.7488994 0.7488271 0.7487541 [232] 0.7486804 0.7486059 0.7485307 0.7484547 0.7483780 0.7483006 0.7482224 [239] 0.7481434 0.7480637 0.7479833 0.7479021 0.7478202 0.7477376 0.7476542 [246] 0.7475701 0.7474852 0.7473996 0.7473133 0.7472262 0.7471384 0.7470499 [253] 0.7469606 0.7468706 0.7467799 0.7466885 0.7465963 0.7465033 0.7464097 [260] 0.7463153 0.7462202 0.7461244 0.7460278 0.7459306 0.7458326 0.7457338 [267] 0.7456344 0.7455342 0.7454333 0.7453317 0.7452294 0.7451263 0.7450226 [274] 0.7449181 0.7448129 0.7447070 0.7446004 0.7444930 0.7443850 0.7442762 [281] 0.7441668 0.7440566 0.7439457 0.7438341 0.7437218 0.7436088 0.7434951 [288] 0.7433807 0.7432655 0.7431497 0.7430332 0.7429160 0.7427981 0.7426794 [295] 0.7425601 0.7424401 0.7423194 0.7421980 0.7420759 0.7419531 0.7418296 [302] 0.7417054 0.7415806 0.7414550 0.7413288 0.7412019 0.7410742 0.7409459 [309] 0.7408170 0.7406873 0.7405570 0.7404259 0.7402942 0.7401618 0.7400288 [316] 0.7398950 0.7397606 0.7396255 0.7394898 0.7393533 0.7392162 0.7390785 [323] 0.7389400 0.7388009 0.7386611 0.7385207 0.7383796 0.7382378 0.7380954 [330] 0.7379523 0.7378085 0.7376641 0.7375190 0.7373733 0.7372269 0.7370798 [337] 0.7369322 0.7367838 0.7366348 0.7364852 0.7363349 0.7361839 0.7360323 [344] 0.7358801 0.7357272 0.7355737 0.7354195 0.7352647 0.7351092 0.7349531 [351] 0.7347964 0.7346391 0.7344811 0.7343224 0.7341632 0.7340033 0.7338427 [358] 0.7336816 0.7335198 0.7333574 0.7331944 0.7330307 0.7328664 0.7327015 [365] 0.7325360 0.7323699 0.7322031 0.7320357 0.7318677 0.7316991 0.7315299 [372] 0.7313601 0.7311896 0.7310186 0.7308469 0.7306747 0.7305018 0.7303283 [379] 0.7301542 0.7299796 0.7298043 0.7296284 0.7294519 0.7292748 0.7290972 [386] 0.7289189 0.7287400 0.7285606 0.7283806 0.7281999 0.7280187 0.7278369 [393] 0.7276545 0.7274716 0.7272880 0.7271039 0.7269192 0.7267339 0.7265480 [400] 0.7263616 0.7261746 > mx [1] 0.752289 > mxli [1] -0.66 > 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/19x411258128361.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/23ju61258128361.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/37keq1258128361.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/486331258128361.tab") > > system("convert tmp/19x411258128361.ps tmp/19x411258128361.png") > system("convert tmp/23ju61258128361.ps tmp/23ju61258128361.png") > system("convert tmp/37keq1258128361.ps tmp/37keq1258128361.png") > > > proc.time() user system elapsed 0.808 0.525 1.034