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(109.7,99.1,86.7,111.4,78.4,76.7,114.2,99.7,94.2,173.5,83.1,88.9,132.0,122.1,105.1,133.7,63.6,112.7,120.5,112.0,126.2,209.2,91.0,116.7,137.6,108.1,136.6,152.3,114.3,120.7,131.8,129.4,187.5,189.5,109.2,158.1,176.2,125.5,155.0,170.3,99.4,139.2,169.6,136.1,168.2,318.6,154.1,161.4,183.4,166.3,203,174.6,124.3,154.4,170.5,169.4,171.1,289.2,145.6,134.4,168.2) > x <- c(115.6,111.3,114.6,137.5,83.7,106.0,123.4,126.5,120.0,141.6,90.5,96.5,113.5,120.1,123.9,144.4,90.8,114.2,138.1,135.0,131.3,144.6,101.7,108.7,135.3,124.3,138.3,158.2,93.5,124.8,154.4,152.8,148.9,170.3,124.8,134.4,154.0,147.9,168.1,175.7,116.7,140.8,164.2,173.8,167.8,166.6,135.1,158.1,151.8,166.7,165.3,187.0,125.2,144.4,181.7,175.9,166.3,181.5,121.8,134.8,162.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.6976104 0.6979503 0.6982893 0.6986275 0.6989649 0.6993015 0.6996373 [8] 0.6999723 0.7003064 0.7006397 0.7009722 0.7013038 0.7016346 0.7019646 [15] 0.7022937 0.7026220 0.7029494 0.7032760 0.7036017 0.7039266 0.7042506 [22] 0.7045737 0.7048960 0.7052174 0.7055379 0.7058576 0.7061764 0.7064943 [29] 0.7068113 0.7071274 0.7074427 0.7077571 0.7080705 0.7083831 0.7086948 [36] 0.7090055 0.7093154 0.7096244 0.7099324 0.7102396 0.7105458 0.7108511 [43] 0.7111555 0.7114590 0.7117616 0.7120632 0.7123639 0.7126637 0.7129625 [50] 0.7132604 0.7135574 0.7138534 0.7141485 0.7144426 0.7147358 0.7150280 [57] 0.7153193 0.7156096 0.7158990 0.7161874 0.7164749 0.7167614 0.7170469 [64] 0.7173314 0.7176150 0.7178976 0.7181793 0.7184599 0.7187396 0.7190183 [71] 0.7192961 0.7195728 0.7198486 0.7201233 0.7203971 0.7206699 0.7209417 [78] 0.7212125 0.7214823 0.7217511 0.7220189 0.7222857 0.7225515 0.7228163 [85] 0.7230800 0.7233428 0.7236046 0.7238653 0.7241250 0.7243837 0.7246414 [92] 0.7248981 0.7251537 0.7254084 0.7256620 0.7259145 0.7261661 0.7264166 [99] 0.7266661 0.7269145 0.7271619 0.7274083 0.7276537 0.7278980 0.7281412 [106] 0.7283835 0.7286246 0.7288648 0.7291039 0.7293419 0.7295789 0.7298148 [113] 0.7300497 0.7302836 0.7305164 0.7307481 0.7309788 0.7312084 0.7314370 [120] 0.7316645 0.7318910 0.7321164 0.7323407 0.7325639 0.7327862 0.7330073 [127] 0.7332274 0.7334464 0.7336643 0.7338812 0.7340970 0.7343117 0.7345254 [134] 0.7347380 0.7349495 0.7351599 0.7353693 0.7355776 0.7357848 0.7359909 [141] 0.7361960 0.7364000 0.7366029 0.7368047 0.7370054 0.7372051 0.7374037 [148] 0.7376012 0.7377976 0.7379930 0.7381872 0.7383804 0.7385725 0.7387635 [155] 0.7389534 0.7391423 0.7393300 0.7395167 0.7397022 0.7398867 0.7400701 [162] 0.7402525 0.7404337 0.7406138 0.7407929 0.7409708 0.7411477 0.7413235 [169] 0.7414982 0.7416718 0.7418443 0.7420158 0.7421861 0.7423554 0.7425235 [176] 0.7426906 0.7428566 0.7430215 0.7431853 0.7433480 0.7435096 0.7436702 [183] 0.7438296 0.7439880 0.7441453 0.7443014 0.7444565 0.7446105 0.7447635 [190] 0.7449153 0.7450660 0.7452157 0.7453643 0.7455117 0.7456581 0.7458034 [197] 0.7459477 0.7460908 0.7462328 0.7463738 0.7465137 0.7466525 0.7467902 [204] 0.7469268 0.7470624 0.7471969 0.7473302 0.7474625 0.7475938 0.7477239 [211] 0.7478530 0.7479810 0.7481079 0.7482337 0.7483585 0.7484821 0.7486047 [218] 0.7487263 0.7488467 0.7489661 0.7490844 0.7492016 0.7493178 0.7494329 [225] 0.7495469 0.7496599 0.7497718 0.7498826 0.7499923 0.7501010 0.7502086 [232] 0.7503152 0.7504207 0.7505251 0.7506285 0.7507308 0.7508321 0.7509323 [239] 0.7510314 0.7511295 0.7512265 0.7513225 0.7514174 0.7515113 0.7516041 [246] 0.7516959 0.7517866 0.7518763 0.7519649 0.7520525 0.7521391 0.7522246 [253] 0.7523090 0.7523925 0.7524748 0.7525562 0.7526365 0.7527158 0.7527940 [260] 0.7528712 0.7529474 0.7530225 0.7530966 0.7531697 0.7532418 0.7533128 [267] 0.7533828 0.7534518 0.7535198 0.7535867 0.7536527 0.7537176 0.7537815 [274] 0.7538444 0.7539063 0.7539671 0.7540270 0.7540858 0.7541437 0.7542005 [281] 0.7542564 0.7543112 0.7543650 0.7544179 0.7544697 0.7545206 0.7545704 [288] 0.7546193 0.7546672 0.7547140 0.7547599 0.7548049 0.7548488 0.7548917 [295] 0.7549337 0.7549747 0.7550147 0.7550537 0.7550918 0.7551289 0.7551650 [302] 0.7552001 0.7552343 0.7552675 0.7552998 0.7553311 0.7553614 0.7553908 [309] 0.7554192 0.7554467 0.7554732 0.7554988 0.7555234 0.7555471 0.7555698 [316] 0.7555916 0.7556124 0.7556323 0.7556513 0.7556693 0.7556864 0.7557025 [323] 0.7557178 0.7557321 0.7557455 0.7557579 0.7557694 0.7557800 0.7557897 [330] 0.7557985 0.7558064 0.7558133 0.7558194 0.7558245 0.7558287 0.7558320 [337] 0.7558344 0.7558359 0.7558366 0.7558363 0.7558351 0.7558330 0.7558301 [344] 0.7558262 0.7558215 0.7558158 0.7558093 0.7558020 0.7557937 0.7557846 [351] 0.7557745 0.7557637 0.7557519 0.7557393 0.7557258 0.7557114 0.7556962 [358] 0.7556801 0.7556632 0.7556454 0.7556268 0.7556073 0.7555869 0.7555658 [365] 0.7555437 0.7555208 0.7554971 0.7554726 0.7554472 0.7554209 0.7553939 [372] 0.7553660 0.7553373 0.7553077 0.7552774 0.7552462 0.7552142 0.7551813 [379] 0.7551477 0.7551132 0.7550780 0.7550419 0.7550050 0.7549674 0.7549289 [386] 0.7548896 0.7548495 0.7548086 0.7547670 0.7547245 0.7546813 0.7546372 [393] 0.7545924 0.7545468 0.7545004 0.7544533 0.7544053 0.7543566 0.7543071 [400] 0.7542569 0.7542059 > mx [1] 0.7558366 > mxli [1] 1.38 > 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/1d0wa1257448127.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/2el3e1257448127.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/30bp61257448127.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/4q7uw1257448127.tab") > > system("convert tmp/1d0wa1257448127.ps tmp/1d0wa1257448127.png") > system("convert tmp/2el3e1257448127.ps tmp/2el3e1257448127.png") > system("convert tmp/30bp61257448127.ps tmp/30bp61257448127.png") > > > proc.time() user system elapsed 1.238 0.812 1.375