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(110.9,115,118.4,121.4,128.8,131.7,141.7,142.9,139.4,134.7,125,113.6,111.5,108.5,112.3,116.6,115.5,120.1,132.9,128.1,129.3,132.5,131,124.9,120.8,122,122.1,127.4,135.2,137.3,135,136,138.4,134.7,138.4,133.9,133.6,141.2,151.8,155.4,156.6,161.6,160.7,156,159.5,168.7,169.9,169.9,185.9,190.8,195.8,211.9,227.1,251.3,256.7,251.9,251.2,270.3,267.2,243,229.9) > x <- c(1.8,1.6,1.9,1.7,1.6,1.3,1.1,1.9,2.6,2.3,2.4,2.2,2,2.9,2.6,2.3,2.3,2.6,3.1,2.8,2.5,2.9,3.1,3.1,3.2,2.5,2.6,2.9,2.6,2.4,1.7,2,2.2,1.9,1.6,1.6,1.2,1.2,1.5,1.6,1.7,1.8,1.8,1.8,1.3,1.3,1.4,1.1,1.5,2.2,2.9,3.1,3.5,3.6,4.4,4.2,5.2,5.8,5.9,5.4,5.5) > #'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.2883285 0.2894775 0.2906305 0.2917875 0.2929486 0.2941137 0.2952829 [8] 0.2964561 0.2976333 0.2988145 0.2999998 0.3011890 0.3023823 0.3035796 [15] 0.3047809 0.3059861 0.3071954 0.3084086 0.3096258 0.3108470 0.3120722 [22] 0.3133013 0.3145343 0.3157713 0.3170122 0.3182570 0.3195057 0.3207584 [29] 0.3220149 0.3232753 0.3245396 0.3258078 0.3270798 0.3283557 0.3296353 [36] 0.3309188 0.3322061 0.3334972 0.3347921 0.3360908 0.3373931 0.3386993 [43] 0.3400091 0.3413227 0.3426400 0.3439609 0.3452855 0.3466138 0.3479457 [50] 0.3492812 0.3506203 0.3519629 0.3533092 0.3546589 0.3560122 0.3573691 [57] 0.3587293 0.3600931 0.3614603 0.3628309 0.3642049 0.3655823 0.3669631 [64] 0.3683472 0.3697346 0.3711253 0.3725193 0.3739165 0.3753169 0.3767205 [71] 0.3781273 0.3795372 0.3809502 0.3823663 0.3837855 0.3852077 0.3866330 [78] 0.3880612 0.3894923 0.3909264 0.3923633 0.3938031 0.3952457 0.3966912 [85] 0.3981394 0.3995903 0.4010439 0.4025002 0.4039592 0.4054207 0.4068848 [92] 0.4083514 0.4098206 0.4112922 0.4127662 0.4142426 0.4157214 0.4172025 [99] 0.4186858 0.4201715 0.4216593 0.4231492 0.4246413 0.4261355 0.4276318 [106] 0.4291300 0.4306302 0.4321323 0.4336363 0.4351422 0.4366498 0.4381592 [113] 0.4396703 0.4411831 0.4426975 0.4442134 0.4457309 0.4472499 0.4487703 [120] 0.4502921 0.4518153 0.4533398 0.4548655 0.4563924 0.4579205 0.4594496 [127] 0.4609799 0.4625111 0.4640433 0.4655765 0.4671104 0.4686452 0.4701808 [134] 0.4717170 0.4732539 0.4747914 0.4763295 0.4778681 0.4794071 0.4809464 [141] 0.4824862 0.4840262 0.4855664 0.4871068 0.4886474 0.4901879 0.4917285 [148] 0.4932691 0.4948096 0.4963498 0.4978899 0.4994297 0.5009692 0.5025083 [155] 0.5040469 0.5055851 0.5071227 0.5086596 0.5101959 0.5117315 0.5132662 [162] 0.5148002 0.5163332 0.5178652 0.5193962 0.5209261 0.5224549 0.5239825 [169] 0.5255088 0.5270337 0.5285573 0.5300795 0.5316001 0.5331192 0.5346366 [176] 0.5361524 0.5376664 0.5391786 0.5406890 0.5421974 0.5437038 0.5452082 [183] 0.5467105 0.5482106 0.5497085 0.5512041 0.5526973 0.5541882 0.5556765 [190] 0.5571624 0.5586456 0.5601262 0.5616041 0.5630792 0.5645515 0.5660210 [197] 0.5674874 0.5689509 0.5704113 0.5718686 0.5733227 0.5747735 0.5762211 [204] 0.5776653 0.5791061 0.5805435 0.5819773 0.5834075 0.5848341 0.5862570 [211] 0.5876761 0.5890914 0.5905029 0.5919104 0.5933140 0.5947135 0.5961090 [218] 0.5975003 0.5988875 0.6002704 0.6016490 0.6030232 0.6043930 0.6057584 [225] 0.6071193 0.6084757 0.6098274 0.6111745 0.6125169 0.6138545 0.6151873 [232] 0.6165153 0.6178383 0.6191565 0.6204696 0.6217777 0.6230807 0.6243786 [239] 0.6256713 0.6269588 0.6282410 0.6295179 0.6307895 0.6320557 0.6333164 [246] 0.6345717 0.6358215 0.6370657 0.6383043 0.6395373 0.6407646 0.6419862 [253] 0.6432021 0.6444121 0.6456164 0.6468148 0.6480073 0.6491939 0.6503746 [260] 0.6515492 0.6527179 0.6538805 0.6550370 0.6561873 0.6573316 0.6584697 [267] 0.6596015 0.6607272 0.6618466 0.6629597 0.6640665 0.6651670 0.6662611 [274] 0.6673488 0.6684302 0.6695051 0.6705735 0.6716355 0.6726910 0.6737400 [281] 0.6747824 0.6758183 0.6768477 0.6778704 0.6788866 0.6798961 0.6808990 [288] 0.6818953 0.6828849 0.6838678 0.6848441 0.6858136 0.6867764 0.6877325 [295] 0.6886819 0.6896246 0.6905605 0.6914896 0.6924120 0.6933275 0.6942364 [302] 0.6951384 0.6960336 0.6969221 0.6978037 0.6986786 0.6995466 0.7004079 [309] 0.7012623 0.7021099 0.7029507 0.7037847 0.7046119 0.7054323 0.7062459 [316] 0.7070527 0.7078527 0.7086459 0.7094323 0.7102120 0.7109848 0.7117509 [323] 0.7125102 0.7132627 0.7140085 0.7147476 0.7154799 0.7162055 0.7169244 [330] 0.7176366 0.7183421 0.7190409 0.7197330 0.7204185 0.7210973 0.7217695 [337] 0.7224350 0.7230940 0.7237464 0.7243922 0.7250314 0.7256641 0.7262902 [344] 0.7269099 0.7275230 0.7281297 0.7287299 0.7293237 0.7299110 0.7304919 [351] 0.7310665 0.7316347 0.7321965 0.7327520 0.7333012 0.7338441 0.7343808 [358] 0.7349112 0.7354354 0.7359534 0.7364653 0.7369710 0.7374705 0.7379640 [365] 0.7384514 0.7389327 0.7394080 0.7398773 0.7403406 0.7407979 0.7412494 [372] 0.7416949 0.7421345 0.7425683 0.7429963 0.7434185 0.7438348 0.7442455 [379] 0.7446504 0.7450497 0.7454433 0.7458312 0.7462136 0.7465903 0.7469615 [386] 0.7473272 0.7476874 0.7480422 0.7483915 0.7487354 0.7490739 0.7494070 [393] 0.7497349 0.7500575 0.7503748 0.7506869 0.7509937 0.7512954 0.7515920 [400] 0.7518835 0.7521699 > mx [1] 0.7521699 > 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/1gkz01257942575.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/2297a1257942575.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/3el8z1257942575.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/4424u1257942575.tab") > > system("convert tmp/1gkz01257942575.ps tmp/1gkz01257942575.png") > system("convert tmp/2297a1257942575.ps tmp/2297a1257942575.png") > system("convert tmp/3el8z1257942575.ps tmp/3el8z1257942575.png") > > > proc.time() user system elapsed 0.761 0.479 1.250