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(18,16,19,18,23,20,20,15,17,16,15,10,13,10,19,21,17,16,17,14,18,17,14,15,16,11,15,13,17,16,9,17,15,12,12,12,12,4,7,4,3,3,0,5,3,4,3,10,4,1,1,8,5,4,0,2,7,6,9,10) > x <- c(611,594,595,591,589,584,573,567,569,621,629,628,612,595,597,593,590,580,574,573,573,620,626,620,588,566,557,561,549,532,526,511,499,555,565,542,527,510,514,517,508,493,490,469,478,528,534,518,506,502,516,528,533,536,537,524,536,587,597,581) > #'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.6760272 0.6760149 0.6760024 0.6759898 0.6759770 0.6759640 0.6759509 [8] 0.6759377 0.6759242 0.6759106 0.6758969 0.6758830 0.6758689 0.6758547 [15] 0.6758403 0.6758257 0.6758110 0.6757961 0.6757811 0.6757659 0.6757505 [22] 0.6757350 0.6757193 0.6757035 0.6756875 0.6756713 0.6756550 0.6756385 [29] 0.6756219 0.6756051 0.6755881 0.6755710 0.6755537 0.6755363 0.6755187 [36] 0.6755010 0.6754830 0.6754650 0.6754467 0.6754283 0.6754098 0.6753911 [43] 0.6753722 0.6753532 0.6753340 0.6753146 0.6752951 0.6752754 0.6752556 [50] 0.6752356 0.6752155 0.6751952 0.6751747 0.6751541 0.6751333 0.6751124 [57] 0.6750913 0.6750700 0.6750486 0.6750271 0.6750053 0.6749834 0.6749614 [64] 0.6749392 0.6749168 0.6748943 0.6748716 0.6748488 0.6748258 0.6748026 [71] 0.6747793 0.6747559 0.6747322 0.6747084 0.6746845 0.6746604 0.6746361 [78] 0.6746117 0.6745872 0.6745624 0.6745375 0.6745125 0.6744873 0.6744619 [85] 0.6744364 0.6744107 0.6743849 0.6743589 0.6743328 0.6743065 0.6742800 [92] 0.6742534 0.6742266 0.6741997 0.6741726 0.6741454 0.6741180 0.6740904 [99] 0.6740627 0.6740348 0.6740068 0.6739786 0.6739503 0.6739218 0.6738932 [106] 0.6738643 0.6738354 0.6738063 0.6737770 0.6737476 0.6737180 0.6736883 [113] 0.6736584 0.6736283 0.6735981 0.6735677 0.6735372 0.6735066 0.6734757 [120] 0.6734447 0.6734136 0.6733823 0.6733509 0.6733193 0.6732875 0.6732556 [127] 0.6732235 0.6731913 0.6731589 0.6731264 0.6730937 0.6730609 0.6730279 [134] 0.6729947 0.6729614 0.6729280 0.6728944 0.6728606 0.6728267 0.6727926 [141] 0.6727584 0.6727240 0.6726895 0.6726548 0.6726199 0.6725849 0.6725498 [148] 0.6725145 0.6724790 0.6724434 0.6724077 0.6723718 0.6723357 0.6722995 [155] 0.6722631 0.6722266 0.6721899 0.6721531 0.6721161 0.6720789 0.6720417 [162] 0.6720042 0.6719666 0.6719289 0.6718910 0.6718529 0.6718147 0.6717764 [169] 0.6717379 0.6716992 0.6716604 0.6716214 0.6715823 0.6715430 0.6715036 [176] 0.6714641 0.6714243 0.6713845 0.6713444 0.6713043 0.6712640 0.6712235 [183] 0.6711828 0.6711421 0.6711011 0.6710601 0.6710188 0.6709775 0.6709359 [190] 0.6708942 0.6708524 0.6708104 0.6707683 0.6707260 0.6706836 0.6706410 [197] 0.6705983 0.6705554 0.6705123 0.6704692 0.6704258 0.6703824 0.6703387 [204] 0.6702949 0.6702510 0.6702069 0.6701627 0.6701183 0.6700738 0.6700291 [211] 0.6699843 0.6699393 0.6698942 0.6698489 0.6698035 0.6697580 0.6697122 [218] 0.6696664 0.6696204 0.6695742 0.6695279 0.6694814 0.6694348 0.6693881 [225] 0.6693412 0.6692941 0.6692469 0.6691996 0.6691521 0.6691045 0.6690567 [232] 0.6690087 0.6689607 0.6689124 0.6688641 0.6688155 0.6687669 0.6687181 [239] 0.6686691 0.6686200 0.6685707 0.6685213 0.6684718 0.6684221 0.6683723 [246] 0.6683223 0.6682722 0.6682219 0.6681715 0.6681209 0.6680702 0.6680193 [253] 0.6679683 0.6679172 0.6678659 0.6678144 0.6677628 0.6677111 0.6676592 [260] 0.6676072 0.6675550 0.6675027 0.6674503 0.6673977 0.6673449 0.6672920 [267] 0.6672390 0.6671858 0.6671325 0.6670790 0.6670254 0.6669717 0.6669178 [274] 0.6668637 0.6668096 0.6667552 0.6667008 0.6666461 0.6665914 0.6665365 [281] 0.6664814 0.6664262 0.6663709 0.6663154 0.6662598 0.6662041 0.6661482 [288] 0.6660921 0.6660359 0.6659796 0.6659231 0.6658665 0.6658098 0.6657529 [295] 0.6656958 0.6656387 0.6655813 0.6655239 0.6654663 0.6654085 0.6653506 [302] 0.6652926 0.6652344 0.6651761 0.6651177 0.6650591 0.6650003 0.6649415 [309] 0.6648824 0.6648233 0.6647640 0.6647046 0.6646450 0.6645853 0.6645254 [316] 0.6644654 0.6644053 0.6643450 0.6642846 0.6642240 0.6641633 0.6641025 [323] 0.6640415 0.6639804 0.6639192 0.6638578 0.6637962 0.6637346 0.6636728 [330] 0.6636108 0.6635487 0.6634865 0.6634242 0.6633617 0.6632990 0.6632362 [337] 0.6631733 0.6631103 0.6630471 0.6629838 0.6629203 0.6628567 0.6627930 [344] 0.6627291 0.6626651 0.6626009 0.6625366 0.6624722 0.6624076 0.6623429 [351] 0.6622781 0.6622131 0.6621480 0.6620828 0.6620174 0.6619519 0.6618862 [358] 0.6618205 0.6617545 0.6616885 0.6616223 0.6615559 0.6614895 0.6614229 [365] 0.6613561 0.6612893 0.6612223 0.6611551 0.6610878 0.6610204 0.6609529 [372] 0.6608852 0.6608174 0.6607494 0.6606814 0.6606131 0.6605448 0.6604763 [379] 0.6604077 0.6603389 0.6602700 0.6602010 0.6601319 0.6600626 0.6599932 [386] 0.6599236 0.6598539 0.6597841 0.6597142 0.6596441 0.6595739 0.6595035 [393] 0.6594330 0.6593624 0.6592917 0.6592208 0.6591498 0.6590786 0.6590074 [400] 0.6589360 0.6588644 > mx [1] 0.6760272 > 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/1pb2d1258125088.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/2lz901258125088.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/3b8rl1258125088.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/43xod1258125088.tab") > > system("convert tmp/1pb2d1258125088.ps tmp/1pb2d1258125088.png") > system("convert tmp/2lz901258125088.ps tmp/2lz901258125088.png") > system("convert tmp/3b8rl1258125088.ps tmp/3b8rl1258125088.png") > > > proc.time() user system elapsed 0.794 0.518 0.928