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(136.49,142.62,141.71,149.51,147.39,131.96,136.38,127.34,133.85,125.14,141.25,149.32,120.92,134.85,131.93,134.22,143.07,145.37,134.32,126.31,162.21,124.09,153.91,154.34,138.70,150.98,146.39,178.30,168.23,162.52,158.86,152.17,171.01,171.49,189.62,177.46,179.98,156.96,167.89,194.78,192.78,165.06,196.60,151.64,187.02,210.99,219.08,235.68,241.44,187.46,229.57,208.44,215.09,217.00,171.08,178.41,196.34,172.11,154.93,182.26,181.74) > x <- c(114.08,112.95,135.31,134.31,133.03,140.11,124.69,131.68,150.95,137.26,130.51,143.15,118.01,122.56,147.97,135.74,151.62,154.82,145.59,147.12,175.86,140.66,152.69,154.38,132.45,136.44,153.24,154.11,155.93,142.53,148.73,147.73,166.79,144.30,156.07,161.70,152.10,140.45,155.56,174.53,167.16,159.48,173.22,176.13,180.31,185.84,169.43,195.25,174.99,156.42,182.08,182.00,153.28,136.72,130.19,132.04,143.89,133.38,127.98,150.45,133.55) > #'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.6117105 0.6119272 0.6121436 0.6123597 0.6125756 0.6127912 0.6130064 [8] 0.6132215 0.6134362 0.6136506 0.6138648 0.6140787 0.6142923 0.6145056 [15] 0.6147186 0.6149313 0.6151438 0.6153559 0.6155678 0.6157794 0.6159906 [22] 0.6162016 0.6164124 0.6166228 0.6168329 0.6170427 0.6172523 0.6174615 [29] 0.6176704 0.6178791 0.6180875 0.6182955 0.6185033 0.6187108 0.6189179 [36] 0.6191248 0.6193314 0.6195376 0.6197436 0.6199493 0.6201547 0.6203597 [43] 0.6205645 0.6207690 0.6209731 0.6211770 0.6213806 0.6215838 0.6217868 [50] 0.6219894 0.6221917 0.6223938 0.6225955 0.6227969 0.6229980 0.6231988 [57] 0.6233993 0.6235995 0.6237994 0.6239989 0.6241982 0.6243971 0.6245957 [64] 0.6247940 0.6249920 0.6251897 0.6253871 0.6255842 0.6257809 0.6259773 [71] 0.6261734 0.6263692 0.6265647 0.6267599 0.6269547 0.6271492 0.6273434 [78] 0.6275373 0.6277309 0.6279241 0.6281171 0.6283097 0.6285020 0.6286939 [85] 0.6288856 0.6290769 0.6292679 0.6294586 0.6296489 0.6298389 0.6300286 [92] 0.6302180 0.6304071 0.6305958 0.6307842 0.6309722 0.6311600 0.6313474 [99] 0.6315345 0.6317212 0.6319077 0.6320938 0.6322795 0.6324650 0.6326501 [106] 0.6328348 0.6330193 0.6332034 0.6333872 0.6335706 0.6337537 0.6339365 [113] 0.6341190 0.6343011 0.6344829 0.6346643 0.6348454 0.6350262 0.6352066 [120] 0.6353867 0.6355665 0.6357459 0.6359250 0.6361038 0.6362822 0.6364603 [127] 0.6366380 0.6368154 0.6369924 0.6371692 0.6373455 0.6375216 0.6376973 [134] 0.6378726 0.6380476 0.6382223 0.6383966 0.6385706 0.6387443 0.6389176 [141] 0.6390905 0.6392631 0.6394354 0.6396073 0.6397789 0.6399501 0.6401210 [148] 0.6402916 0.6404617 0.6406316 0.6408011 0.6409702 0.6411391 0.6413075 [155] 0.6414756 0.6416434 0.6418108 0.6419779 0.6421446 0.6423109 0.6424770 [162] 0.6426426 0.6428079 0.6429729 0.6431375 0.6433018 0.6434657 0.6436293 [169] 0.6437925 0.6439553 0.6441178 0.6442800 0.6444418 0.6446032 0.6447643 [176] 0.6449251 0.6450855 0.6452455 0.6454052 0.6455645 0.6457234 0.6458821 [183] 0.6460403 0.6461982 0.6463558 0.6465129 0.6466698 0.6468263 0.6469824 [190] 0.6471381 0.6472935 0.6474486 0.6476033 0.6477576 0.6479116 0.6480652 [197] 0.6482185 0.6483714 0.6485239 0.6486761 0.6488279 0.6489794 0.6491305 [204] 0.6492812 0.6494316 0.6495816 0.6497313 0.6498806 0.6500295 0.6501781 [211] 0.6503263 0.6504742 0.6506217 0.6507688 0.6509156 0.6510620 0.6512081 [218] 0.6513537 0.6514991 0.6516440 0.6517886 0.6519329 0.6520767 0.6522203 [225] 0.6523634 0.6525062 0.6526486 0.6527907 0.6529324 0.6530737 0.6532147 [232] 0.6533553 0.6534955 0.6536354 0.6537749 0.6539140 0.6540528 0.6541912 [239] 0.6543293 0.6544669 0.6546043 0.6547412 0.6548778 0.6550140 0.6551499 [246] 0.6552854 0.6554205 0.6555552 0.6556896 0.6558237 0.6559573 0.6560906 [253] 0.6562235 0.6563561 0.6564883 0.6566201 0.6567516 0.6568827 0.6570134 [260] 0.6571438 0.6572737 0.6574034 0.6575326 0.6576615 0.6577900 0.6579182 [267] 0.6580460 0.6581734 0.6583005 0.6584271 0.6585535 0.6586794 0.6588050 [274] 0.6589302 0.6590550 0.6591795 0.6593036 0.6594274 0.6595507 0.6596738 [281] 0.6597964 0.6599187 0.6600406 0.6601621 0.6602833 0.6604041 0.6605245 [288] 0.6606445 0.6607642 0.6608836 0.6610025 0.6611211 0.6612393 0.6613572 [295] 0.6614746 0.6615918 0.6617085 0.6618249 0.6619409 0.6620565 0.6621718 [302] 0.6622867 0.6624012 0.6625154 0.6626292 0.6627426 0.6628557 0.6629684 [309] 0.6630807 0.6631927 0.6633042 0.6634155 0.6635263 0.6636368 0.6637469 [316] 0.6638567 0.6639660 0.6640751 0.6641837 0.6642920 0.6643999 0.6645074 [323] 0.6646146 0.6647214 0.6648278 0.6649339 0.6650396 0.6651449 0.6652499 [330] 0.6653545 0.6654587 0.6655626 0.6656661 0.6657692 0.6658720 0.6659744 [337] 0.6660764 0.6661781 0.6662794 0.6663803 0.6664809 0.6665811 0.6666809 [344] 0.6667804 0.6668795 0.6669782 0.6670766 0.6671746 0.6672722 0.6673695 [351] 0.6674664 0.6675629 0.6676591 0.6677549 0.6678503 0.6679454 0.6680401 [358] 0.6681344 0.6682284 0.6683220 0.6684153 0.6685082 0.6686007 0.6686928 [365] 0.6687846 0.6688761 0.6689671 0.6690578 0.6691482 0.6692381 0.6693277 [372] 0.6694170 0.6695059 0.6695944 0.6696825 0.6697703 0.6698578 0.6699448 [379] 0.6700315 0.6701179 0.6702039 0.6702895 0.6703747 0.6704596 0.6705442 [386] 0.6706283 0.6707121 0.6707956 0.6708787 0.6709614 0.6710438 0.6711258 [393] 0.6712074 0.6712887 0.6713696 0.6714502 0.6715304 0.6716103 0.6716898 [400] 0.6717689 0.6718477 > mx [1] 0.6718477 > 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/1ilxw1258726701.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/2yfsb1258726701.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/3zffv1258726701.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/4fq0s1258726701.tab") > > system("convert tmp/1ilxw1258726701.ps tmp/1ilxw1258726701.png") > system("convert tmp/2yfsb1258726701.ps tmp/2yfsb1258726701.png") > system("convert tmp/3zffv1258726701.ps tmp/3zffv1258726701.png") > > > proc.time() user system elapsed 0.812 0.525 1.893