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(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) > x <- 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) > #'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.7455747 0.7456969 0.7458184 0.7459392 0.7460594 0.7461789 0.7462978 [8] 0.7464159 0.7465334 0.7466502 0.7467663 0.7468818 0.7469965 0.7471106 [15] 0.7472240 0.7473367 0.7474487 0.7475600 0.7476707 0.7477806 0.7478898 [22] 0.7479984 0.7481062 0.7482133 0.7483198 0.7484255 0.7485305 0.7486348 [29] 0.7487384 0.7488413 0.7489435 0.7490449 0.7491457 0.7492457 0.7493450 [36] 0.7494436 0.7495415 0.7496386 0.7497350 0.7498307 0.7499257 0.7500199 [43] 0.7501134 0.7502062 0.7502982 0.7503895 0.7504800 0.7505698 0.7506589 [50] 0.7507472 0.7508348 0.7509216 0.7510077 0.7510931 0.7511776 0.7512615 [57] 0.7513445 0.7514269 0.7515084 0.7515892 0.7516693 0.7517486 0.7518271 [64] 0.7519048 0.7519818 0.7520581 0.7521335 0.7522082 0.7522821 0.7523552 [71] 0.7524276 0.7524992 0.7525700 0.7526400 0.7527093 0.7527777 0.7528454 [78] 0.7529123 0.7529784 0.7530437 0.7531083 0.7531720 0.7532350 0.7532971 [85] 0.7533585 0.7534190 0.7534788 0.7535378 0.7535959 0.7536533 0.7537099 [92] 0.7537656 0.7538206 0.7538747 0.7539280 0.7539805 0.7540323 0.7540832 [99] 0.7541332 0.7541825 0.7542310 0.7542786 0.7543254 0.7543714 0.7544166 [106] 0.7544609 0.7545044 0.7545471 0.7545890 0.7546300 0.7546703 0.7547096 [113] 0.7547482 0.7547859 0.7548228 0.7548588 0.7548940 0.7549284 0.7549619 [120] 0.7549946 0.7550265 0.7550575 0.7550876 0.7551170 0.7551454 0.7551730 [127] 0.7551998 0.7552257 0.7552508 0.7552750 0.7552984 0.7553209 0.7553426 [134] 0.7553634 0.7553833 0.7554024 0.7554206 0.7554380 0.7554544 0.7554701 [141] 0.7554849 0.7554988 0.7555118 0.7555240 0.7555353 0.7555457 0.7555552 [148] 0.7555639 0.7555718 0.7555787 0.7555848 0.7555899 0.7555943 0.7555977 [155] 0.7556003 0.7556019 0.7556027 0.7556026 0.7556017 0.7555998 0.7555971 [162] 0.7555935 0.7555890 0.7555836 0.7555773 0.7555701 0.7555621 0.7555531 [169] 0.7555433 0.7555325 0.7555209 0.7555084 0.7554950 0.7554806 0.7554654 [176] 0.7554493 0.7554323 0.7554144 0.7553956 0.7553759 0.7553553 0.7553338 [183] 0.7553114 0.7552881 0.7552638 0.7552387 0.7552127 0.7551857 0.7551579 [190] 0.7551291 0.7550995 0.7550689 0.7550374 0.7550050 0.7549717 0.7549375 [197] 0.7549024 0.7548663 0.7548294 0.7547915 0.7547527 0.7547130 0.7546724 [204] 0.7546308 0.7545884 0.7545450 0.7545007 0.7544555 0.7544094 0.7543623 [211] 0.7543143 0.7542654 0.7542156 0.7541649 0.7541132 0.7540606 0.7540071 [218] 0.7539526 0.7538973 0.7538410 0.7537838 0.7537256 0.7536665 0.7536065 [225] 0.7535456 0.7534837 0.7534210 0.7533572 0.7532926 0.7532270 0.7531605 [232] 0.7530931 0.7530247 0.7529554 0.7528852 0.7528140 0.7527419 0.7526689 [239] 0.7525949 0.7525200 0.7524442 0.7523674 0.7522897 0.7522111 0.7521315 [246] 0.7520510 0.7519696 0.7518872 0.7518039 0.7517197 0.7516345 0.7515484 [253] 0.7514613 0.7513733 0.7512844 0.7511945 0.7511037 0.7510120 0.7509193 [260] 0.7508257 0.7507311 0.7506356 0.7505392 0.7504418 0.7503435 0.7502443 [267] 0.7501441 0.7500430 0.7499409 0.7498379 0.7497340 0.7496291 0.7495233 [274] 0.7494165 0.7493088 0.7492002 0.7490906 0.7489801 0.7488687 0.7487563 [281] 0.7486429 0.7485287 0.7484135 0.7482973 0.7481803 0.7480622 0.7479433 [288] 0.7478234 0.7477026 0.7475808 0.7474581 0.7473345 0.7472099 0.7470844 [295] 0.7469579 0.7468305 0.7467022 0.7465729 0.7464427 0.7463116 0.7461795 [302] 0.7460465 0.7459126 0.7457777 0.7456419 0.7455052 0.7453675 0.7452289 [309] 0.7450893 0.7449489 0.7448074 0.7446651 0.7445218 0.7443776 0.7442325 [316] 0.7440864 0.7439394 0.7437915 0.7436426 0.7434929 0.7433421 0.7431905 [323] 0.7430379 0.7428844 0.7427300 0.7425746 0.7424184 0.7422612 0.7421030 [330] 0.7419440 0.7417840 0.7416231 0.7414613 0.7412985 0.7411349 0.7409703 [337] 0.7408047 0.7406383 0.7404710 0.7403027 0.7401335 0.7399634 0.7397924 [344] 0.7396204 0.7394476 0.7392738 0.7390991 0.7389235 0.7387470 0.7385695 [351] 0.7383912 0.7382119 0.7380318 0.7378507 0.7376687 0.7374858 0.7373020 [358] 0.7371173 0.7369317 0.7367451 0.7365577 0.7363694 0.7361801 0.7359900 [365] 0.7357990 0.7356070 0.7354142 0.7352204 0.7350258 0.7348303 0.7346338 [372] 0.7344365 0.7342383 0.7340392 0.7338391 0.7336382 0.7334364 0.7332337 [379] 0.7330302 0.7328257 0.7326204 0.7324141 0.7322070 0.7319990 0.7317901 [386] 0.7315803 0.7313696 0.7311581 0.7309457 0.7307324 0.7305182 0.7303031 [393] 0.7300872 0.7298704 0.7296527 0.7294342 0.7292147 0.7289944 0.7287733 [400] 0.7285512 0.7283283 > mx [1] 0.7556027 > mxli [1] -0.44 > 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/1s5e11197026316.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/27i4g1197026316.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/39ncd1197026316.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/4fg7w1197026316.tab") > > system("convert tmp/1s5e11197026316.ps tmp/1s5e11197026316.png") > system("convert tmp/27i4g1197026316.ps tmp/27i4g1197026316.png") > system("convert tmp/39ncd1197026316.ps tmp/39ncd1197026316.png") > > > proc.time() user system elapsed 1.053 0.515 1.392