R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(115.8,112.2,115.8,120.7,118.4,113.1,116.1,114.4,115.6,113.6,109.2,114.2,115,110.1,114.1,111.8,118.5,120.3,120.6,116.9,122.4,118.2,114.2,119.5,117.6,120.3,120.8,117,121.4,121,120.7,118.2,121.2,121.6,122.6,122.9,111.2,121.7,122.1,117.8,123.8,123.5,119.1,125.5,118.9,119.3,123,115.2,119.2,118.4,113.7,119.7,114.5,113,115.2,113.5,112.9,113.4,112.2,113.1) > x <- c(103.5,104.1,101.9,102,100.7,99,96.5,101.8,100.5,103.3,102.3,100.4,103,99,104.8,104.5,104.8,103.8,106.3,105.2,108.2,106.2,103.9,104.9,106.2,107.9,106.9,110.3,109.8,108.3,110.9,109.8,109.3,109,107.9,108.4,107.2,109.5,109.9,108,114.7,115.6,107.6,115.9,111.8,110,109.2,108,105.6,103,99.6,97.9,97.6,96.2,97.9,94.5,95.4,94.4,96.3,95.1) > #'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.7003059 0.7003650 0.7004242 0.7004832 0.7005422 0.7006012 0.7006601 [8] 0.7007190 0.7007778 0.7008365 0.7008952 0.7009539 0.7010125 0.7010710 [15] 0.7011295 0.7011880 0.7012464 0.7013047 0.7013630 0.7014212 0.7014794 [22] 0.7015376 0.7015957 0.7016537 0.7017117 0.7017696 0.7018275 0.7018853 [29] 0.7019431 0.7020008 0.7020585 0.7021161 0.7021737 0.7022312 0.7022886 [36] 0.7023460 0.7024034 0.7024607 0.7025180 0.7025751 0.7026323 0.7026894 [43] 0.7027464 0.7028034 0.7028603 0.7029172 0.7029741 0.7030308 0.7030876 [50] 0.7031442 0.7032008 0.7032574 0.7033139 0.7033704 0.7034268 0.7034831 [57] 0.7035394 0.7035957 0.7036518 0.7037080 0.7037641 0.7038201 0.7038761 [64] 0.7039320 0.7039879 0.7040437 0.7040994 0.7041551 0.7042108 0.7042664 [71] 0.7043219 0.7043774 0.7044328 0.7044882 0.7045435 0.7045988 0.7046540 [78] 0.7047092 0.7047643 0.7048193 0.7048743 0.7049293 0.7049842 0.7050390 [85] 0.7050938 0.7051485 0.7052032 0.7052578 0.7053123 0.7053668 0.7054213 [92] 0.7054757 0.7055300 0.7055843 0.7056385 0.7056927 0.7057468 0.7058009 [99] 0.7058549 0.7059088 0.7059627 0.7060166 0.7060703 0.7061241 0.7061777 [106] 0.7062313 0.7062849 0.7063384 0.7063919 0.7064452 0.7064986 0.7065519 [113] 0.7066051 0.7066582 0.7067113 0.7067644 0.7068174 0.7068703 0.7069232 [120] 0.7069760 0.7070288 0.7070815 0.7071342 0.7071868 0.7072393 0.7072918 [127] 0.7073442 0.7073966 0.7074489 0.7075012 0.7075534 0.7076055 0.7076576 [134] 0.7077096 0.7077616 0.7078135 0.7078654 0.7079172 0.7079689 0.7080206 [141] 0.7080722 0.7081238 0.7081753 0.7082268 0.7082781 0.7083295 0.7083808 [148] 0.7084320 0.7084831 0.7085343 0.7085853 0.7086363 0.7086872 0.7087381 [155] 0.7087889 0.7088397 0.7088904 0.7089410 0.7089916 0.7090421 0.7090926 [162] 0.7091430 0.7091933 0.7092436 0.7092938 0.7093440 0.7093941 0.7094442 [169] 0.7094942 0.7095441 0.7095940 0.7096438 0.7096935 0.7097432 0.7097929 [176] 0.7098425 0.7098920 0.7099414 0.7099908 0.7100402 0.7100895 0.7101387 [183] 0.7101879 0.7102370 0.7102860 0.7103350 0.7103839 0.7104328 0.7104816 [190] 0.7105303 0.7105790 0.7106276 0.7106762 0.7107247 0.7107731 0.7108215 [197] 0.7108699 0.7109181 0.7109663 0.7110145 0.7110626 0.7111106 0.7111585 [204] 0.7112064 0.7112543 0.7113021 0.7113498 0.7113974 0.7114450 0.7114926 [211] 0.7115400 0.7115875 0.7116348 0.7116821 0.7117293 0.7117765 0.7118236 [218] 0.7118707 0.7119177 0.7119646 0.7120114 0.7120582 0.7121050 0.7121517 [225] 0.7121983 0.7122448 0.7122913 0.7123378 0.7123841 0.7124305 0.7124767 [232] 0.7125229 0.7125690 0.7126151 0.7126611 0.7127070 0.7127529 0.7127987 [239] 0.7128445 0.7128902 0.7129358 0.7129814 0.7130269 0.7130723 0.7131177 [246] 0.7131630 0.7132082 0.7132534 0.7132986 0.7133436 0.7133886 0.7134336 [253] 0.7134785 0.7135233 0.7135680 0.7136127 0.7136573 0.7137019 0.7137464 [260] 0.7137908 0.7138352 0.7138795 0.7139238 0.7139680 0.7140121 0.7140561 [267] 0.7141001 0.7141441 0.7141879 0.7142317 0.7142755 0.7143192 0.7143628 [274] 0.7144063 0.7144498 0.7144932 0.7145366 0.7145799 0.7146231 0.7146663 [281] 0.7147094 0.7147524 0.7147954 0.7148383 0.7148812 0.7149239 0.7149667 [288] 0.7150093 0.7150519 0.7150944 0.7151369 0.7151793 0.7152216 0.7152639 [295] 0.7153061 0.7153482 0.7153903 0.7154323 0.7154743 0.7155162 0.7155580 [302] 0.7155997 0.7156414 0.7156830 0.7157246 0.7157661 0.7158075 0.7158489 [309] 0.7158902 0.7159314 0.7159725 0.7160136 0.7160547 0.7160957 0.7161366 [316] 0.7161774 0.7162182 0.7162589 0.7162995 0.7163401 0.7163806 0.7164211 [323] 0.7164614 0.7165017 0.7165420 0.7165822 0.7166223 0.7166623 0.7167023 [330] 0.7167422 0.7167821 0.7168219 0.7168616 0.7169013 0.7169408 0.7169804 [337] 0.7170198 0.7170592 0.7170985 0.7171378 0.7171770 0.7172161 0.7172552 [344] 0.7172942 0.7173331 0.7173719 0.7174107 0.7174494 0.7174881 0.7175267 [351] 0.7175652 0.7176037 0.7176421 0.7176804 0.7177186 0.7177568 0.7177950 [358] 0.7178330 0.7178710 0.7179089 0.7179468 0.7179846 0.7180223 0.7180599 [365] 0.7180975 0.7181350 0.7181725 0.7182099 0.7182472 0.7182844 0.7183216 [372] 0.7183587 0.7183958 0.7184327 0.7184696 0.7185065 0.7185433 0.7185800 [379] 0.7186166 0.7186532 0.7186897 0.7187261 0.7187625 0.7187988 0.7188350 [386] 0.7188712 0.7189072 0.7189433 0.7189792 0.7190151 0.7190509 0.7190867 [393] 0.7191224 0.7191580 0.7191935 0.7192290 0.7192644 0.7192998 0.7193350 [400] 0.7193702 0.7194054 > mx [1] 0.7194054 > 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/1yeg71258117198.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/2llz61258117198.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/3m67t1258117198.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > 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/410go1258117198.tab") > > system("convert tmp/1yeg71258117198.ps tmp/1yeg71258117198.png") > system("convert tmp/2llz61258117198.ps tmp/2llz61258117198.png") > system("convert tmp/3m67t1258117198.ps tmp/3m67t1258117198.png") > > > proc.time() user system elapsed 0.758 0.482 0.900