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(145.3,143.6,142.8,155.9,156.2,149.8,152.7,155.5,159.3,143,141.4,142.8,146.4,152.3,164.3,168,171.3,162.7,150.2,142.5,138.2,138,145.1,138.4,131.8,130.8,126.3,123,124,120.8,122.1,106.5,104.3,108.7,113.8,112.5,106.1,98.4,96,99.3,97.5,95.3,88,94.7,99.4,98.9,96.4,95.3,99.5,101.6,103.9,106.6,108.3,102,93.8,91.6,97.7,94.8,98,103.8,97.8,91.2,89.3,87.5,90.4,94.2,102.2,101.3,96,90.8,93.2,90.9,91.1,90.2,94.3,96,99,103.3,113.1,112.8,112.1,107.4,111,110.5,110.8,112.4,111.5,116.2,122.5,121.3,113.9,110.7,120.8,141.1,147.4,148,158.1,165,187,190.3,182.4,168.8,151.2,120.1,112.5,106.2,107.1,108.5,106.5,108.3,125.6,124,127.2,136.9,135.8,124.3,115.4,113.6,114.4,118.4,117,116.5,115.4,113.6,117.4,116.9,116.4,111.1,110.2,118.9,131.8,130.6,138.3,148.4,148.7,144.3,152.5,162.9,167.2,166.5,185.6) > x <- c(174.1,180.4,182.6,207.1,213.7,186.5,179.1,168.3,156.5,144.3,138.9,137.8,136.3,140.3,149.1,149.2,140.4,129,124.7,130.8,130.1,133.2,130.1,126.6,124.8,125.3,126.9,120.1,118.7,117.7,113.4,107.5,107.6,114.3,114.9,111.2,109.9,108.6,109.2,106.4,103.7,103,96.9,104.7,102.2,99,95.8,94.5,102.7,103.2,105.6,103.9,107.2,100.7,92.1,90.3,93.4,98.5,100.8,102.3,104.7,101.1,101.4,99.5,98.4,96.3,100.7,101.2,100.3,97.8,97.4,98.6,99.7,99,98.1,97,98.5,103.8,114.4,124.5,134.2,131.8,125.6,119.9,114.9,115.5,112.5,111.4,115.3,110.8,103.7,111.1,113,111.2,117.6,121.7,127.3,129.8,137.1,141.4,137.4,130.7,117.2,110.8,111.4,108.2,108.8,110.2,109.5,109.5,116,111.2,112.1,114,119.1,114.1,115.1,115.4,110.8,116,119.2,126.5,127.8,131.3,140.3,137.3,143,134.5,139.9,159.3,170.4,175,175.8,180.9,180.3,169.6,172.3,184.8,177.7,184.6,211.4) > #'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.8092545 0.8091921 0.8091287 0.8090644 0.8089991 0.8089329 0.8088657 [8] 0.8087975 0.8087284 0.8086583 0.8085873 0.8085153 0.8084423 0.8083684 [15] 0.8082935 0.8082176 0.8081408 0.8080629 0.8079841 0.8079044 0.8078237 [22] 0.8077419 0.8076593 0.8075756 0.8074910 0.8074053 0.8073187 0.8072312 [29] 0.8071426 0.8070530 0.8069625 0.8068710 0.8067785 0.8066850 0.8065905 [36] 0.8064951 0.8063986 0.8063012 0.8062027 0.8061033 0.8060029 0.8059014 [43] 0.8057990 0.8056956 0.8055912 0.8054858 0.8053794 0.8052720 0.8051636 [50] 0.8050542 0.8049438 0.8048324 0.8047200 0.8046066 0.8044921 0.8043767 [57] 0.8042603 0.8041428 0.8040244 0.8039049 0.8037845 0.8036630 0.8035405 [64] 0.8034170 0.8032925 0.8031670 0.8030405 0.8029130 0.8027844 0.8026549 [71] 0.8025243 0.8023927 0.8022601 0.8021264 0.8019918 0.8018561 0.8017195 [78] 0.8015818 0.8014431 0.8013033 0.8011626 0.8010208 0.8008780 0.8007342 [85] 0.8005894 0.8004436 0.8002967 0.8001488 0.7999999 0.7998500 0.7996990 [92] 0.7995470 0.7993940 0.7992400 0.7990850 0.7989289 0.7987718 0.7986137 [99] 0.7984545 0.7982944 0.7981332 0.7979710 0.7978078 0.7976435 0.7974782 [106] 0.7973119 0.7971446 0.7969762 0.7968068 0.7966364 0.7964650 0.7962926 [113] 0.7961191 0.7959446 0.7957691 0.7955925 0.7954150 0.7952364 0.7950567 [120] 0.7948761 0.7946944 0.7945117 0.7943280 0.7941433 0.7939576 0.7937708 [127] 0.7935830 0.7933942 0.7932043 0.7930135 0.7928216 0.7926287 0.7924347 [134] 0.7922398 0.7920438 0.7918469 0.7916489 0.7914498 0.7912498 0.7910488 [141] 0.7908467 0.7906436 0.7904395 0.7902344 0.7900282 0.7898211 0.7896129 [148] 0.7894038 0.7891936 0.7889824 0.7887702 0.7885570 0.7883428 0.7881275 [155] 0.7879113 0.7876940 0.7874758 0.7872565 0.7870362 0.7868150 0.7865927 [162] 0.7863694 0.7861451 0.7859198 0.7856935 0.7854662 0.7852380 0.7850087 [169] 0.7847784 0.7845471 0.7843148 0.7840816 0.7838473 0.7836121 0.7833758 [176] 0.7831386 0.7829004 0.7826611 0.7824209 0.7821798 0.7819376 0.7816944 [183] 0.7814503 0.7812052 0.7809591 0.7807120 0.7804639 0.7802149 0.7799649 [190] 0.7797139 0.7794619 0.7792090 0.7789551 0.7787002 0.7784444 0.7781875 [197] 0.7779298 0.7776710 0.7774113 0.7771507 0.7768890 0.7766264 0.7763629 [204] 0.7760984 0.7758330 0.7755666 0.7752992 0.7750309 0.7747616 0.7744914 [211] 0.7742203 0.7739482 0.7736751 0.7734012 0.7731263 0.7728504 0.7725736 [218] 0.7722959 0.7720172 0.7717376 0.7714571 0.7711757 0.7708933 0.7706100 [225] 0.7703258 0.7700407 0.7697546 0.7694676 0.7691798 0.7688910 0.7686012 [232] 0.7683106 0.7680191 0.7677266 0.7674333 0.7671391 0.7668439 0.7665479 [239] 0.7662509 0.7659531 0.7656544 0.7653548 0.7650542 0.7647529 0.7644506 [246] 0.7641474 0.7638434 0.7635385 0.7632327 0.7629260 0.7626185 0.7623100 [253] 0.7620008 0.7616906 0.7613796 0.7610677 0.7607550 0.7604414 0.7601270 [260] 0.7598117 0.7594955 0.7591786 0.7588607 0.7585420 0.7582225 0.7579021 [267] 0.7575809 0.7572589 0.7569360 0.7566124 0.7562878 0.7559625 0.7556363 [274] 0.7553093 0.7549815 0.7546529 0.7543234 0.7539932 0.7536621 0.7533303 [281] 0.7529976 0.7526642 0.7523299 0.7519948 0.7516590 0.7513223 0.7509849 [288] 0.7506467 0.7503077 0.7499679 0.7496273 0.7492860 0.7489439 0.7486010 [295] 0.7482574 0.7479130 0.7475678 0.7472219 0.7468752 0.7465277 0.7461795 [302] 0.7458306 0.7454809 0.7451305 0.7447793 0.7444274 0.7440747 0.7437213 [309] 0.7433672 0.7430124 0.7426568 0.7423005 0.7419435 0.7415858 0.7412274 [316] 0.7408683 0.7405084 0.7401478 0.7397866 0.7394246 0.7390620 0.7386986 [323] 0.7383346 0.7379699 0.7376045 0.7372384 0.7368716 0.7365042 0.7361360 [330] 0.7357673 0.7353978 0.7350277 0.7346569 0.7342855 0.7339134 0.7335406 [337] 0.7331672 0.7327932 0.7324185 0.7320432 0.7316672 0.7312906 0.7309134 [344] 0.7305355 0.7301570 0.7297779 0.7293982 0.7290178 0.7286369 0.7282553 [351] 0.7278731 0.7274904 0.7271070 0.7267230 0.7263384 0.7259533 0.7255675 [358] 0.7251812 0.7247942 0.7244067 0.7240187 0.7236300 0.7232408 0.7228510 [365] 0.7224606 0.7220697 0.7216782 0.7212862 0.7208936 0.7205005 0.7201068 [372] 0.7197126 0.7193178 0.7189226 0.7185267 0.7181304 0.7177335 0.7173361 [379] 0.7169382 0.7165397 0.7161408 0.7157413 0.7153413 0.7149409 0.7145399 [386] 0.7141384 0.7137364 0.7133340 0.7129310 0.7125276 0.7121236 0.7117193 [393] 0.7113144 0.7109090 0.7105032 0.7100969 0.7096902 0.7092830 0.7088753 [400] 0.7084672 0.7080586 > mx [1] 0.8092545 > 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/1wxac1226418254.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/25qu01226418254.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/34j8q1226418254.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/414ra1226418254.tab") > > system("convert tmp/1wxac1226418254.ps tmp/1wxac1226418254.png") > system("convert tmp/25qu01226418254.ps tmp/25qu01226418254.png") > system("convert tmp/34j8q1226418254.ps tmp/34j8q1226418254.png") > > > proc.time() user system elapsed 1.245 0.832 1.371