R version 2.8.1 (2008-12-22) 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(2465,1932,1993,2243,1758,1806,2063,1823,2137,2428,2139,2265,2615,2070,2794,2190,2434,2520,2063,2068,2537,1898,2139,2408,2725,2201,2311,2548,2276,2351,2280,2057,2479,2379,2295,2456,2546,2844,2260,2981,2678,3440,2842,2450,2669,2570,2540,2318,2930,2946,2799,2695,2498,2260,2160,2058,2533,2150,2172,2155,3016) > x <- c(1,1.09,1.31,1.66,2,2.31,2.75,3.42,3.97,4.25,4.25,4.18,4,4,4,4,4,4,4,4,4,4,4,4,3.9,3.75,3.75,3.65,3.5,3.5,3.39,3.25,3.17,3,2.93,2.75,2.64,2.5,2.5,2.45,2.25,2.25,2.21,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2) > #'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.0154659695 0.0148912923 0.0143144519 0.0137354644 0.0131543461 [6] 0.0125711136 0.0119857839 0.0113983739 0.0108089011 0.0102173832 [11] 0.0096238381 0.0090282839 0.0084307391 0.0078312225 0.0072297528 [16] 0.0066263494 0.0060210316 0.0054138192 0.0048047321 0.0041937906 [21] 0.0035810149 0.0029664259 0.0023500444 0.0017318915 0.0011119886 [26] 0.0004903573 -0.0001329805 -0.0007580027 -0.0013846873 -0.0020130115 [31] -0.0026429527 -0.0032744881 -0.0039075944 -0.0045422483 -0.0051784263 [36] -0.0058161047 -0.0064552595 -0.0070958665 -0.0077379016 -0.0083813400 [41] -0.0090261573 -0.0096723285 -0.0103198286 -0.0109686323 -0.0116187144 [46] -0.0122700492 -0.0129226111 -0.0135763742 -0.0142313126 -0.0148874000 [51] -0.0155446103 -0.0162029169 -0.0168622934 -0.0175227130 -0.0181841489 [56] -0.0188465742 -0.0195099619 -0.0201742848 -0.0208395156 -0.0215056270 [61] -0.0221725915 -0.0228403816 -0.0235089696 -0.0241783278 -0.0248484284 [66] -0.0255192435 -0.0261907452 -0.0268629055 -0.0275356963 -0.0282090895 [71] -0.0288830569 -0.0295575703 -0.0302326014 -0.0309081221 -0.0315841039 [76] -0.0322605185 -0.0329373375 -0.0336145326 -0.0342920754 -0.0349699375 [81] -0.0356480905 -0.0363265060 -0.0370051556 -0.0376840110 -0.0383630439 [86] -0.0390422258 -0.0397215285 -0.0404009238 -0.0410803835 -0.0417598793 [91] -0.0424393831 -0.0431188669 -0.0437983026 -0.0444776623 -0.0451569181 [96] -0.0458360421 -0.0465150067 -0.0471937841 -0.0478723468 -0.0485506673 [101] -0.0492287182 -0.0499064721 -0.0505839020 -0.0512609806 -0.0519376810 [106] -0.0526139764 -0.0532898400 -0.0539652452 -0.0546401654 -0.0553145743 [111] -0.0559884456 -0.0566617534 -0.0573344715 -0.0580065742 -0.0586780358 [116] -0.0593488309 -0.0600189340 -0.0606883200 -0.0613569639 -0.0620248407 [121] -0.0626919258 -0.0633581946 -0.0640236229 -0.0646881864 -0.0653518612 [126] -0.0660146234 -0.0666764494 -0.0673373159 -0.0679971995 -0.0686560773 [131] -0.0693139265 -0.0699707242 -0.0706264483 -0.0712810763 -0.0719345863 [136] -0.0725869565 -0.0732381653 -0.0738881913 -0.0745370133 -0.0751846103 [141] -0.0758309617 -0.0764760469 -0.0771198457 -0.0777623379 -0.0784035038 [146] -0.0790433236 -0.0796817781 -0.0803188481 -0.0809545147 -0.0815887591 [151] -0.0822215630 -0.0828529080 -0.0834827763 -0.0841111500 -0.0847380117 [156] -0.0853633441 -0.0859871301 -0.0866093529 -0.0872299961 -0.0878490432 [161] -0.0884664783 -0.0890822854 -0.0896964490 -0.0903089537 -0.0909197844 [166] -0.0915289263 -0.0921363648 -0.0927420853 -0.0933460739 -0.0939483165 [171] -0.0945487996 -0.0951475097 -0.0957444337 -0.0963395586 -0.0969328716 [176] -0.0975243604 -0.0981140128 -0.0987018166 -0.0992877603 -0.0998718323 [181] -0.1004540213 -0.1010343163 -0.1016127065 -0.1021891813 -0.1027637304 [186] -0.1033363437 -0.1039070113 -0.1044757236 -0.1050424711 -0.1056072447 [191] -0.1061700355 -0.1067308346 -0.1072896336 -0.1078464242 -0.1084011983 [196] -0.1089539482 -0.1095046660 -0.1100533446 -0.1105999765 -0.1111445550 [201] -0.1116870732 -0.1122275245 -0.1127659027 -0.1133022016 -0.1138364152 [206] -0.1143685378 -0.1148985640 -0.1154264884 -0.1159523059 -0.1164760115 [211] -0.1169976006 -0.1175170686 -0.1180344111 -0.1185496242 -0.1190627037 [216] -0.1195736460 -0.1200824474 -0.1205891046 -0.1210936143 -0.1215959736 [221] -0.1220961796 -0.1225942295 -0.1230901210 -0.1235838517 -0.1240754194 [226] -0.1245648221 -0.1250520581 -0.1255371256 -0.1260200233 -0.1265007497 [231] -0.1269793038 -0.1274556844 -0.1279298908 -0.1284019223 -0.1288717783 [236] -0.1293394584 -0.1298049624 -0.1302682902 -0.1307294419 -0.1311884175 [241] -0.1316452176 -0.1320998424 -0.1325522927 -0.1330025692 -0.1334506727 [246] -0.1338966043 -0.1343403651 -0.1347819563 -0.1352213794 -0.1356586359 [251] -0.1360937274 -0.1365266557 -0.1369574226 -0.1373860301 -0.1378124804 [256] -0.1382367756 -0.1386589182 -0.1390789104 -0.1394967550 -0.1399124545 [261] -0.1403260117 -0.1407374294 -0.1411467107 -0.1415538585 -0.1419588761 [266] -0.1423617666 -0.1427625335 -0.1431611802 -0.1435577101 -0.1439521270 [271] -0.1443444345 -0.1447346365 -0.1451227367 -0.1455087392 -0.1458926479 [276] -0.1462744671 -0.1466542008 -0.1470318535 -0.1474074293 -0.1477809328 [281] -0.1481523684 -0.1485217407 -0.1488890543 -0.1492543139 -0.1496175243 [286] -0.1499786903 -0.1503378167 -0.1506949086 -0.1510499710 -0.1514030089 [291] -0.1517540274 -0.1521030318 -0.1524500272 -0.1527950190 -0.1531380125 [296] -0.1534790131 -0.1538180263 -0.1541550575 -0.1544901122 -0.1548231961 [301] -0.1551543149 -0.1554834741 -0.1558106794 -0.1561359368 -0.1564592519 [306] -0.1567806305 -0.1571000786 -0.1574176021 -0.1577332069 -0.1580468990 [311] -0.1583586844 -0.1586685692 -0.1589765595 -0.1592826613 -0.1595868808 [316] -0.1598892242 -0.1601896976 -0.1604883073 -0.1607850596 -0.1610799607 [321] -0.1613730168 -0.1616642345 -0.1619536199 -0.1622411794 -0.1625269195 [326] -0.1628108465 -0.1630929668 -0.1633732869 -0.1636518133 -0.1639285524 [331] -0.1642035108 -0.1644766948 -0.1647481111 -0.1650177661 -0.1652856665 [336] -0.1655518187 -0.1658162294 -0.1660789051 -0.1663398524 -0.1665990778 [341] -0.1668565881 -0.1671123898 -0.1673664895 -0.1676188939 -0.1678696095 [346] -0.1681186431 -0.1683660012 -0.1686116906 -0.1688557178 -0.1690980895 [351] -0.1693388123 -0.1695778930 -0.1698153382 -0.1700511545 -0.1702853485 [356] -0.1705179270 -0.1707488966 -0.1709782640 -0.1712060357 -0.1714322186 [361] -0.1716568191 -0.1718798440 -0.1721012998 -0.1723211933 -0.1725395310 [366] -0.1727563197 -0.1729715658 -0.1731852761 -0.1733974571 -0.1736081154 [371] -0.1738172577 -0.1740248905 -0.1742310204 -0.1744356539 -0.1746387978 [376] -0.1748404584 -0.1750406424 -0.1752393563 -0.1754366066 -0.1756323998 [381] -0.1758267425 -0.1760196412 -0.1762111023 -0.1764011323 -0.1765897376 [386] -0.1767769249 -0.1769627004 -0.1771470706 -0.1773300419 -0.1775116207 [391] -0.1776918135 -0.1778706266 -0.1780480663 -0.1782241390 -0.1783988512 [396] -0.1785722089 -0.1787442187 -0.1789148868 -0.1790842194 -0.1792522228 [401] -0.1794189034 > mx [1] 0.1794189 > 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/rcomp/tmp/19i9b1258049998.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/rcomp/tmp/2t9dx1258049998.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/rcomp/tmp/3cucw1258049998.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/4t9oj1258049998.tab") > system("convert tmp/19i9b1258049998.ps tmp/19i9b1258049998.png") > system("convert tmp/2t9dx1258049998.ps tmp/2t9dx1258049998.png") > system("convert tmp/3cucw1258049998.ps tmp/3cucw1258049998.png") > > > proc.time() user system elapsed 0.920 0.710 1.375