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(19.2,26.6,26.6,31.4,31.2,26.4,20.7,20.7,15,13.3,8.7,10.2,4.3,-0.1,-4.6,-3.9,-3.5,-3.4,-2.5,-1.1,0.3,-0.9,3.6,2.7,-0.2,-1,5.8,6.4,9.6,13.2,10.6,10.9,12.9,15.9,12.2,9.1,9,17.4,14.7,17,13.7,9.5,14.8,13.6,12.6,8.9,10.2,12.7,16,10.4,9.9,9.5,8.6,10,3.5,-4.2,-4.4,-1.5,-0.1,0.8) > x <- c(4.8,5.5,5.4,5.9,5.8,5.1,4.1,4.4,3.6,3.5,3.1,2.9,2.2,1.4,1.2,1.3,1.3,1.3,1.8,1.8,1.8,1.7,2.1,2,1.7,1.9,2.3,2.4,2.5,2.8,2.6,2.2,2.8,2.8,2.8,2.3,2.2,3,2.9,2.7,2.7,2.3,2.4,2.8,2.3,2,1.9,2.3,2.7,1.8,2,2.1,2,2.4,1.7,1,1.2,1.4,1.7,1.8) > #'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.8071307 0.8081394 0.8091471 0.8101538 0.8111593 0.8121636 0.8131668 [8] 0.8141688 0.8151695 0.8161689 0.8171671 0.8181638 0.8191592 0.8201532 [15] 0.8211457 0.8221368 0.8231263 0.8241142 0.8251006 0.8260853 0.8270684 [22] 0.8280498 0.8290294 0.8300072 0.8309833 0.8319575 0.8329298 0.8339002 [29] 0.8348686 0.8358350 0.8367994 0.8377617 0.8387218 0.8396799 0.8406357 [36] 0.8415893 0.8425406 0.8434896 0.8444363 0.8453806 0.8463224 0.8472617 [43] 0.8481986 0.8491329 0.8500646 0.8509936 0.8519200 0.8528437 0.8537646 [50] 0.8546826 0.8555979 0.8565103 0.8574197 0.8583261 0.8592296 0.8601300 [57] 0.8610273 0.8619214 0.8628124 0.8637001 0.8645846 0.8654657 0.8663435 [64] 0.8672179 0.8680888 0.8689563 0.8698202 0.8706805 0.8715373 0.8723903 [71] 0.8732397 0.8740853 0.8749271 0.8757651 0.8765992 0.8774294 0.8782556 [78] 0.8790778 0.8798959 0.8807100 0.8815199 0.8823256 0.8831271 0.8839243 [85] 0.8847172 0.8855057 0.8862898 0.8870695 0.8878446 0.8886153 0.8893813 [92] 0.8901428 0.8908995 0.8916516 0.8923989 0.8931414 0.8938791 0.8946119 [99] 0.8953398 0.8960627 0.8967807 0.8974936 0.8982013 0.8989040 0.8996015 [106] 0.9002938 0.9009808 0.9016626 0.9023390 0.9030101 0.9036757 0.9043359 [113] 0.9049906 0.9056398 0.9062834 0.9069214 0.9075538 0.9081805 0.9088014 [120] 0.9094167 0.9100261 0.9106297 0.9112274 0.9118193 0.9124052 0.9129852 [127] 0.9135591 0.9141270 0.9146889 0.9152446 0.9157943 0.9163377 0.9168750 [134] 0.9174060 0.9179308 0.9184492 0.9189614 0.9194672 0.9199666 0.9204596 [141] 0.9209462 0.9214263 0.9218999 0.9223671 0.9228276 0.9232816 0.9237290 [148] 0.9241698 0.9246040 0.9250314 0.9254522 0.9258663 0.9262737 0.9266743 [155] 0.9270681 0.9274552 0.9278354 0.9282088 0.9285753 0.9289350 0.9292878 [162] 0.9296338 0.9299728 0.9303048 0.9306299 0.9309481 0.9312593 0.9315635 [169] 0.9318608 0.9321510 0.9324342 0.9327104 0.9329796 0.9332417 0.9334968 [176] 0.9337448 0.9339858 0.9342197 0.9344465 0.9346662 0.9348789 0.9350845 [183] 0.9352830 0.9354744 0.9356588 0.9358360 0.9360062 0.9361693 0.9363253 [190] 0.9364742 0.9366161 0.9367509 0.9368786 0.9369993 0.9371129 0.9372195 [197] 0.9373190 0.9374115 0.9374970 0.9375754 0.9376469 0.9377114 0.9377689 [204] 0.9378194 0.9378630 0.9378997 0.9379294 0.9379522 0.9379681 0.9379772 [211] 0.9379794 0.9379747 0.9379632 0.9379450 0.9379199 0.9378881 0.9378495 [218] 0.9378042 0.9377523 0.9376936 0.9376283 0.9375564 0.9374778 0.9373927 [225] 0.9373011 0.9372029 0.9370982 0.9369870 0.9368694 0.9367454 0.9366150 [232] 0.9364783 0.9363352 0.9361858 0.9360302 0.9358683 0.9357003 0.9355260 [239] 0.9353457 0.9351592 0.9349667 0.9347682 0.9345636 0.9343531 0.9341367 [246] 0.9339144 0.9336863 0.9334523 0.9332126 0.9329671 0.9327160 0.9324592 [253] 0.9321967 0.9319287 0.9316552 0.9313762 0.9310917 0.9308018 0.9305065 [260] 0.9302059 0.9299000 0.9295888 0.9292725 0.9289509 0.9286243 0.9282926 [267] 0.9279559 0.9276141 0.9272675 0.9269159 0.9265595 0.9261983 0.9258323 [274] 0.9254615 0.9250862 0.9247062 0.9243216 0.9239324 0.9235388 0.9231408 [281] 0.9227383 0.9223315 0.9219204 0.9215050 0.9210854 0.9206617 0.9202338 [288] 0.9198019 0.9193659 0.9189260 0.9184821 0.9180344 0.9175828 0.9171274 [295] 0.9166683 0.9162055 0.9157391 0.9152690 0.9147954 0.9143183 0.9138378 [302] 0.9133538 0.9128665 0.9123758 0.9118819 0.9113848 0.9108844 0.9103810 [309] 0.9098745 0.9093649 0.9088524 0.9083369 0.9078185 0.9072972 0.9067732 [316] 0.9062464 0.9057169 0.9051847 0.9046499 0.9041125 0.9035726 0.9030302 [323] 0.9024853 0.9019381 0.9013885 0.9008366 0.9002824 0.8997260 0.8991675 [330] 0.8986068 0.8980440 0.8974792 0.8969123 0.8963435 0.8957728 0.8952002 [337] 0.8946257 0.8940495 0.8934715 0.8928918 0.8923105 0.8917275 0.8911429 [344] 0.8905567 0.8899691 0.8893800 0.8887894 0.8881975 0.8876042 0.8870096 [351] 0.8864137 0.8858166 0.8852183 0.8846188 0.8840182 0.8834165 0.8828138 [358] 0.8822100 0.8816053 0.8809996 0.8803931 0.8797856 0.8791773 0.8785682 [365] 0.8779583 0.8773477 0.8767364 0.8761245 0.8755119 0.8748987 0.8742849 [372] 0.8736706 0.8730557 0.8724405 0.8718247 0.8712086 0.8705920 0.8699752 [379] 0.8693580 0.8687405 0.8681227 0.8675047 0.8668866 0.8662682 0.8656497 [386] 0.8650311 0.8644123 0.8637935 0.8631747 0.8625559 0.8619371 0.8613183 [393] 0.8606996 0.8600810 0.8594625 0.8588441 0.8582259 0.8576080 0.8569902 [400] 0.8563726 0.8557554 > mx [1] 0.9379794 > mxli [1] 0.1 > 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/1mreo1226432988.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/2erqr1226432988.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/3z2e31226432988.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/4syas1226432988.tab") > > system("convert tmp/1mreo1226432988.ps tmp/1mreo1226432988.png") > system("convert tmp/2erqr1226432988.ps tmp/2erqr1226432988.png") > system("convert tmp/3z2e31226432988.ps tmp/3z2e31226432988.png") > > > proc.time() user system elapsed 1.269 0.848 1.426