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(100.4,123.3,156.6,136.2,147.5,143.8,135.8,121.6,128,129.7,136.2,130.5,99.2) > x <- c(96.2,103.4,117.1,110.3,116.3,112.5,111.8,112.1,93.3,109.1,118.1,108.1,99.9) > #'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.7201283 0.7202422 0.7203560 0.7204697 0.7205833 0.7206967 0.7208101 [8] 0.7209234 0.7210365 0.7211495 0.7212625 0.7213753 0.7214880 0.7216006 [15] 0.7217130 0.7218254 0.7219377 0.7220498 0.7221619 0.7222738 0.7223856 [22] 0.7224973 0.7226089 0.7227204 0.7228317 0.7229430 0.7230541 0.7231651 [29] 0.7232761 0.7233869 0.7234976 0.7236081 0.7237186 0.7238290 0.7239392 [36] 0.7240493 0.7241593 0.7242692 0.7243790 0.7244887 0.7245983 0.7247077 [43] 0.7248171 0.7249263 0.7250354 0.7251444 0.7252533 0.7253620 0.7254707 [50] 0.7255792 0.7256877 0.7257960 0.7259042 0.7260122 0.7261202 0.7262281 [57] 0.7263358 0.7264434 0.7265509 0.7266583 0.7267656 0.7268728 0.7269798 [64] 0.7270867 0.7271936 0.7273003 0.7274069 0.7275133 0.7276197 0.7277259 [71] 0.7278320 0.7279380 0.7280439 0.7281497 0.7282554 0.7283609 0.7284663 [78] 0.7285717 0.7286768 0.7287819 0.7288869 0.7289917 0.7290965 0.7292011 [85] 0.7293056 0.7294099 0.7295142 0.7296183 0.7297224 0.7298263 0.7299300 [92] 0.7300337 0.7301373 0.7302407 0.7303440 0.7304472 0.7305503 0.7306533 [99] 0.7307561 0.7308588 0.7309614 0.7310639 0.7311663 0.7312686 0.7313707 [106] 0.7314727 0.7315746 0.7316764 0.7317781 0.7318796 0.7319810 0.7320823 [113] 0.7321835 0.7322846 0.7323855 0.7324863 0.7325870 0.7326876 0.7327881 [120] 0.7328884 0.7329887 0.7330888 0.7331888 0.7332886 0.7333884 0.7334880 [127] 0.7335875 0.7336869 0.7337862 0.7338853 0.7339843 0.7340832 0.7341820 [134] 0.7342807 0.7343792 0.7344776 0.7345759 0.7346741 0.7347722 0.7348701 [141] 0.7349679 0.7350656 0.7351632 0.7352606 0.7353580 0.7354552 0.7355522 [148] 0.7356492 0.7357460 0.7358428 0.7359394 0.7360358 0.7361322 0.7362284 [155] 0.7363245 0.7364205 0.7365164 0.7366121 0.7367077 0.7368032 0.7368986 [162] 0.7369939 0.7370890 0.7371840 0.7372789 0.7373736 0.7374683 0.7375628 [169] 0.7376572 0.7377514 0.7378456 0.7379396 0.7380335 0.7381273 0.7382209 [176] 0.7383144 0.7384078 0.7385011 0.7385943 0.7386873 0.7387802 0.7388730 [183] 0.7389656 0.7390582 0.7391506 0.7392429 0.7393350 0.7394271 0.7395190 [190] 0.7396108 0.7397024 0.7397940 0.7398854 0.7399767 0.7400678 0.7401589 [197] 0.7402498 0.7403406 0.7404312 0.7405218 0.7406122 0.7407025 0.7407926 [204] 0.7408827 0.7409726 0.7410624 0.7411520 0.7412415 0.7413310 0.7414202 [211] 0.7415094 0.7415984 0.7416873 0.7417761 0.7418648 0.7419533 0.7420417 [218] 0.7421300 0.7422181 0.7423061 0.7423940 0.7424818 0.7425694 0.7426569 [225] 0.7427443 0.7428316 0.7429187 0.7430057 0.7430926 0.7431794 0.7432660 [232] 0.7433525 0.7434389 0.7435251 0.7436112 0.7436972 0.7437831 0.7438688 [239] 0.7439544 0.7440399 0.7441253 0.7442105 0.7442956 0.7443806 0.7444654 [246] 0.7445501 0.7446347 0.7447192 0.7448035 0.7448877 0.7449718 0.7450557 [253] 0.7451396 0.7452232 0.7453068 0.7453902 0.7454735 0.7455567 0.7456398 [260] 0.7457227 0.7458055 0.7458882 0.7459707 0.7460531 0.7461354 0.7462175 [267] 0.7462995 0.7463814 0.7464632 0.7465448 0.7466263 0.7467077 0.7467890 [274] 0.7468701 0.7469511 0.7470319 0.7471127 0.7471933 0.7472737 0.7473541 [281] 0.7474343 0.7475144 0.7475943 0.7476742 0.7477538 0.7478334 0.7479128 [288] 0.7479922 0.7480713 0.7481504 0.7482293 0.7483081 0.7483867 0.7484653 [295] 0.7485437 0.7486219 0.7487001 0.7487781 0.7488559 0.7489337 0.7490113 [302] 0.7490888 0.7491661 0.7492434 0.7493205 0.7493974 0.7494743 0.7495510 [309] 0.7496275 0.7497040 0.7497803 0.7498565 0.7499325 0.7500084 0.7500842 [316] 0.7501599 0.7502354 0.7503108 0.7503860 0.7504612 0.7505362 0.7506110 [323] 0.7506858 0.7507604 0.7508349 0.7509092 0.7509834 0.7510575 0.7511315 [330] 0.7512053 0.7512790 0.7513525 0.7514260 0.7514992 0.7515724 0.7516454 [337] 0.7517183 0.7517911 0.7518637 0.7519363 0.7520086 0.7520809 0.7521530 [344] 0.7522250 0.7522968 0.7523685 0.7524401 0.7525115 0.7525829 0.7526540 [351] 0.7527251 0.7527960 0.7528668 0.7529375 0.7530080 0.7530784 0.7531486 [358] 0.7532188 0.7532888 0.7533586 0.7534284 0.7534980 0.7535674 0.7536368 [365] 0.7537060 0.7537750 0.7538440 0.7539128 0.7539815 0.7540500 0.7541184 [372] 0.7541867 0.7542548 0.7543228 0.7543907 0.7544585 0.7545261 0.7545935 [379] 0.7546609 0.7547281 0.7547952 0.7548621 0.7549289 0.7549956 0.7550622 [386] 0.7551286 0.7551949 0.7552610 0.7553270 0.7553929 0.7554587 0.7555243 [393] 0.7555898 0.7556551 0.7557203 0.7557854 0.7558504 0.7559152 0.7559799 [400] 0.7560444 0.7561089 > mx [1] 0.7561089 > 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/freestat/rcomp/tmp/1fv461226521040.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/2frfg1226521040.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/30fjh1226521040.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/4ukwe1226521040.tab") > > system("convert tmp/1fv461226521040.ps tmp/1fv461226521040.png") > system("convert tmp/2frfg1226521040.ps tmp/2frfg1226521040.png") > system("convert tmp/30fjh1226521040.ps tmp/30fjh1226521040.png") > > > proc.time() user system elapsed 1.244 0.827 3.080