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(105.1,113.3,99.1,100.3,93.5,98.8,106.2,98.3,102.1,117.1,101.5,80.5,105.9,109.5,97.2,114.5,93.5,100.9,121.1,116.5,109.3,118.1,108.3,105.4,116.2,111.2,105.8,122.7,99.5,107.9,124.6,115,110.3,132.7,99.7,96.5,118.7,112.9,130.5,137.9,115,116.8,140.9,120.7,134.2,147.3,112.4,107.1,128.4,137.7,135,151,137.4,132.4,161.3,139.8,146,154.6,142.1,120.5) > x <- c(112.6,113.8,107.8,103.2,103.3,101.2,107.7,110.4,101.9,115.9,89.9,88.6,117.2,123.9,100,103.6,94.1,98.7,119.5,112.7,104.4,124.7,89.1,97,121.6,118.8,114,111.5,97.2,102.5,113.4,109.8,104.9,126.1,80,96.8,117.2,112.3,117.3,111.1,102.2,104.3,122.9,107.6,121.3,131.5,89,104.4,128.9,135.9,133.3,121.3,120.5,120.4,137.9,126.1,133.2,146.6,103.4,117.2) > #'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.7128595 0.7131490 0.7134381 0.7137267 0.7140147 0.7143024 0.7145895 [8] 0.7148761 0.7151623 0.7154480 0.7157332 0.7160179 0.7163021 0.7165859 [15] 0.7168691 0.7171519 0.7174341 0.7177159 0.7179972 0.7182780 0.7185583 [22] 0.7188382 0.7191175 0.7193963 0.7196746 0.7199525 0.7202298 0.7205067 [29] 0.7207830 0.7210589 0.7213342 0.7216091 0.7218834 0.7221573 0.7224306 [36] 0.7227035 0.7229758 0.7232476 0.7235190 0.7237898 0.7240601 0.7243299 [43] 0.7245992 0.7248680 0.7251363 0.7254041 0.7256714 0.7259381 0.7262044 [50] 0.7264701 0.7267354 0.7270001 0.7272643 0.7275280 0.7277911 0.7280538 [57] 0.7283159 0.7285775 0.7288386 0.7290992 0.7293593 0.7296188 0.7298779 [64] 0.7301364 0.7303944 0.7306518 0.7309088 0.7311652 0.7314211 0.7316765 [71] 0.7319313 0.7321856 0.7324394 0.7326927 0.7329455 0.7331977 0.7334494 [78] 0.7337005 0.7339512 0.7342013 0.7344508 0.7346999 0.7349484 0.7351964 [85] 0.7354438 0.7356907 0.7359371 0.7361829 0.7364282 0.7366730 0.7369173 [92] 0.7371610 0.7374041 0.7376468 0.7378889 0.7381304 0.7383714 0.7386119 [99] 0.7388518 0.7390912 0.7393301 0.7395684 0.7398062 0.7400434 0.7402801 [106] 0.7405162 0.7407518 0.7409869 0.7412214 0.7414554 0.7416888 0.7419217 [113] 0.7421540 0.7423858 0.7426170 0.7428477 0.7430779 0.7433075 0.7435365 [120] 0.7437650 0.7439929 0.7442203 0.7444472 0.7446735 0.7448992 0.7451244 [127] 0.7453490 0.7455731 0.7457966 0.7460196 0.7462420 0.7464639 0.7466852 [134] 0.7469060 0.7471262 0.7473458 0.7475649 0.7477834 0.7480014 0.7482188 [141] 0.7484357 0.7486520 0.7488677 0.7490829 0.7492975 0.7495116 0.7497251 [148] 0.7499380 0.7501504 0.7503622 0.7505735 0.7507842 0.7509943 0.7512039 [155] 0.7514129 0.7516213 0.7518292 0.7520365 0.7522433 0.7524494 0.7526551 [162] 0.7528601 0.7530646 0.7532685 0.7534719 0.7536747 0.7538769 0.7540786 [169] 0.7542796 0.7544802 0.7546801 0.7548795 0.7550783 0.7552766 0.7554742 [176] 0.7556713 0.7558679 0.7560638 0.7562592 0.7564541 0.7566483 0.7568420 [183] 0.7570351 0.7572277 0.7574196 0.7576110 0.7578018 0.7579921 0.7581818 [190] 0.7583709 0.7585594 0.7587474 0.7589347 0.7591216 0.7593078 0.7594934 [197] 0.7596785 0.7598630 0.7600470 0.7602303 0.7604131 0.7605953 0.7607770 [204] 0.7609580 0.7611385 0.7613184 0.7614977 0.7616765 0.7618546 0.7620322 [211] 0.7622092 0.7623857 0.7625615 0.7627368 0.7629115 0.7630856 0.7632592 [218] 0.7634321 0.7636045 0.7637763 0.7639475 0.7641182 0.7642883 0.7644577 [225] 0.7646266 0.7647950 0.7649627 0.7651299 0.7652965 0.7654625 0.7656279 [232] 0.7657927 0.7659570 0.7661207 0.7662838 0.7664463 0.7666082 0.7667696 [239] 0.7669303 0.7670905 0.7672501 0.7674092 0.7675676 0.7677255 0.7678827 [246] 0.7680394 0.7681955 0.7683511 0.7685060 0.7686604 0.7688142 0.7689673 [253] 0.7691200 0.7692720 0.7694234 0.7695743 0.7697246 0.7698743 0.7700234 [260] 0.7701719 0.7703198 0.7704672 0.7706140 0.7707602 0.7709058 0.7710508 [267] 0.7711952 0.7713391 0.7714824 0.7716251 0.7717672 0.7719087 0.7720496 [274] 0.7721900 0.7723297 0.7724689 0.7726075 0.7727455 0.7728829 0.7730198 [281] 0.7731560 0.7732917 0.7734268 0.7735613 0.7736952 0.7738286 0.7739613 [288] 0.7740935 0.7742251 0.7743561 0.7744865 0.7746163 0.7747455 0.7748742 [295] 0.7750023 0.7751298 0.7752567 0.7753830 0.7755087 0.7756339 0.7757585 [302] 0.7758824 0.7760058 0.7761287 0.7762509 0.7763725 0.7764936 0.7766141 [309] 0.7767340 0.7768533 0.7769720 0.7770902 0.7772077 0.7773247 0.7774411 [316] 0.7775569 0.7776722 0.7777868 0.7779009 0.7780144 0.7781273 0.7782396 [323] 0.7783513 0.7784625 0.7785730 0.7786830 0.7787924 0.7789012 0.7790095 [330] 0.7791171 0.7792242 0.7793307 0.7794366 0.7795419 0.7796467 0.7797508 [337] 0.7798544 0.7799574 0.7800598 0.7801617 0.7802629 0.7803636 0.7804637 [344] 0.7805632 0.7806622 0.7807605 0.7808583 0.7809555 0.7810521 0.7811482 [351] 0.7812436 0.7813385 0.7814328 0.7815265 0.7816197 0.7817122 0.7818042 [358] 0.7818956 0.7819865 0.7820767 0.7821664 0.7822555 0.7823440 0.7824320 [365] 0.7825193 0.7826061 0.7826923 0.7827780 0.7828630 0.7829475 0.7830314 [372] 0.7831147 0.7831975 0.7832797 0.7833613 0.7834423 0.7835228 0.7836026 [379] 0.7836819 0.7837607 0.7838388 0.7839164 0.7839934 0.7840699 0.7841457 [386] 0.7842210 0.7842957 0.7843699 0.7844435 0.7845165 0.7845889 0.7846607 [393] 0.7847320 0.7848027 0.7848729 0.7849425 0.7850115 0.7850799 0.7851478 [400] 0.7852151 0.7852818 > mx [1] 0.7852818 > 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/1dc7w1194705309.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/2b30i1194705309.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/39gkv1194705309.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/49y7i1194705310.tab") > > system("convert tmp/1dc7w1194705309.ps tmp/1dc7w1194705309.png") > system("convert tmp/2b30i1194705309.ps tmp/2b30i1194705309.png") > system("convert tmp/39gkv1194705309.ps tmp/39gkv1194705309.png") > > > proc.time() user system elapsed 1.028 0.515 1.164