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(276427,266424,267153,268381,262522,255542,253158,243803,250741,280445,285257,270976,261076) > x <- c(250643,243422,247105,248541,245039,237080,237085,225554,226839,247934,248333,246969,245098) > #'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.8613971 0.8614353 0.8614699 0.8615049 0.8615380 0.8615684 0.8616027 [8] 0.8616386 0.8616683 0.8617014 0.8617347 0.8617697 0.8618072 0.8618405 [15] 0.8618745 0.8619059 0.8619416 0.8619727 0.8620062 0.8620393 0.8620725 [22] 0.8621069 0.8621390 0.8621731 0.8622074 0.8622396 0.8622736 0.8623074 [29] 0.8623399 0.8623740 0.8624071 0.8624405 0.8624737 0.8625070 0.8625402 [36] 0.8625733 0.8626065 0.8626399 0.8626732 0.8627065 0.8627396 0.8627727 [43] 0.8628060 0.8628391 0.8628722 0.8629055 0.8629385 0.8629717 0.8630047 [50] 0.8630379 0.8630710 0.8631040 0.8631371 0.8631701 0.8632032 0.8632362 [57] 0.8632692 0.8633022 0.8633352 0.8633682 0.8634011 0.8634341 0.8634670 [64] 0.8635000 0.8635329 0.8635658 0.8635987 0.8636316 0.8636644 0.8636973 [71] 0.8637301 0.8637629 0.8637958 0.8638286 0.8638614 0.8638942 0.8639269 [78] 0.8639597 0.8639924 0.8640252 0.8640579 0.8640906 0.8641233 0.8641560 [85] 0.8641887 0.8642213 0.8642540 0.8642866 0.8643192 0.8643518 0.8643844 [92] 0.8644170 0.8644496 0.8644822 0.8645147 0.8645473 0.8645798 0.8646123 [99] 0.8646448 0.8646773 0.8647098 0.8647422 0.8647747 0.8648071 0.8648396 [106] 0.8648720 0.8649044 0.8649368 0.8649692 0.8650015 0.8650339 0.8650662 [113] 0.8650985 0.8651309 0.8651632 0.8651955 0.8652277 0.8652600 0.8652923 [120] 0.8653245 0.8653567 0.8653890 0.8654212 0.8654533 0.8654855 0.8655177 [127] 0.8655499 0.8655820 0.8656141 0.8656462 0.8656784 0.8657104 0.8657425 [134] 0.8657746 0.8658066 0.8658387 0.8658707 0.8659027 0.8659347 0.8659667 [141] 0.8659987 0.8660307 0.8660626 0.8660946 0.8661265 0.8661584 0.8661903 [148] 0.8662222 0.8662541 0.8662860 0.8663178 0.8663497 0.8663815 0.8664133 [155] 0.8664451 0.8664769 0.8665087 0.8665405 0.8665722 0.8666039 0.8666357 [162] 0.8666674 0.8666991 0.8667308 0.8667625 0.8667941 0.8668258 0.8668574 [169] 0.8668890 0.8669206 0.8669522 0.8669838 0.8670154 0.8670470 0.8670785 [176] 0.8671101 0.8671416 0.8671731 0.8672046 0.8672361 0.8672675 0.8672990 [183] 0.8673304 0.8673619 0.8673933 0.8674247 0.8674561 0.8674875 0.8675189 [190] 0.8675502 0.8675816 0.8676129 0.8676442 0.8676755 0.8677068 0.8677381 [197] 0.8677693 0.8678006 0.8678318 0.8678631 0.8678943 0.8679255 0.8679567 [204] 0.8679878 0.8680190 0.8680501 0.8680813 0.8681124 0.8681435 0.8681746 [211] 0.8682057 0.8682368 0.8682678 0.8682989 0.8683299 0.8683609 0.8683919 [218] 0.8684229 0.8684539 0.8684849 0.8685158 0.8685468 0.8685777 0.8686086 [225] 0.8686395 0.8686704 0.8687013 0.8687321 0.8687630 0.8687938 0.8688246 [232] 0.8688554 0.8688862 0.8689170 0.8689478 0.8689785 0.8690093 0.8690400 [239] 0.8690707 0.8691014 0.8691321 0.8691628 0.8691935 0.8692241 0.8692548 [246] 0.8692854 0.8693160 0.8693466 0.8693772 0.8694078 0.8694383 0.8694689 [253] 0.8694994 0.8695299 0.8695604 0.8695909 0.8696214 0.8696518 0.8696823 [260] 0.8697127 0.8697432 0.8697736 0.8698040 0.8698344 0.8698647 0.8698951 [267] 0.8699254 0.8699558 0.8699861 0.8700164 0.8700467 0.8700770 0.8701072 [274] 0.8701375 0.8701677 0.8701979 0.8702281 0.8702583 0.8702885 0.8703187 [281] 0.8703488 0.8703790 0.8704091 0.8704392 0.8704693 0.8704994 0.8705295 [288] 0.8705596 0.8705896 0.8706197 0.8706497 0.8706797 0.8707097 0.8707397 [295] 0.8707696 0.8707996 0.8708295 0.8708595 0.8708894 0.8709193 0.8709492 [302] 0.8709790 0.8710089 0.8710387 0.8710686 0.8710984 0.8711282 0.8711580 [309] 0.8711878 0.8712175 0.8712473 0.8712770 0.8713067 0.8713364 0.8713661 [316] 0.8713958 0.8714255 0.8714552 0.8714848 0.8715144 0.8715440 0.8715736 [323] 0.8716032 0.8716328 0.8716624 0.8716919 0.8717214 0.8717510 0.8717805 [330] 0.8718100 0.8718394 0.8718689 0.8718983 0.8719278 0.8719572 0.8719866 [337] 0.8720160 0.8720454 0.8720748 0.8721041 0.8721334 0.8721628 0.8721921 [344] 0.8722214 0.8722507 0.8722799 0.8723092 0.8723384 0.8723677 0.8723969 [351] 0.8724261 0.8724553 0.8724844 0.8725136 0.8725427 0.8725719 0.8726010 [358] 0.8726301 0.8726592 0.8726883 0.8727173 0.8727464 0.8727754 0.8728044 [365] 0.8728334 0.8728624 0.8728914 0.8729204 0.8729493 0.8729783 0.8730072 [372] 0.8730361 0.8730650 0.8730939 0.8731227 0.8731516 0.8731804 0.8732093 [379] 0.8732381 0.8732669 0.8732957 0.8733244 0.8733532 0.8733819 0.8734106 [386] 0.8734394 0.8734681 0.8734967 0.8735254 0.8735541 0.8735827 0.8736113 [393] 0.8736400 0.8736686 0.8736971 0.8737257 0.8737543 0.8737828 0.8738114 [400] 0.8738399 0.8738684 > mx [1] 0.8738684 > 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/1656l1226482634.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/2hd1q1226482634.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/31boe1226482634.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/4ocwi1226482634.tab") > > system("convert tmp/1656l1226482634.ps tmp/1656l1226482634.png") > system("convert tmp/2hd1q1226482634.ps tmp/2hd1q1226482634.png") > system("convert tmp/31boe1226482634.ps tmp/31boe1226482634.png") > > > proc.time() user system elapsed 1.206 0.793 1.414