R version 2.7.2 (2008-08-25) 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(31/10/2007,30/11/2007,31/12/2007,31/01/2008,29/02/2008,31/03/2008,30/04/2008,31/05/2008,30/06/2008,31/07/2008,31/08/2008,30/09/2008,31/10/2008) > x <- c(114971,105531,104919,104782,101281,94545,93248,84031,87486,115867,120327,117008,108811) > #'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.1153393 -0.1155382 -0.1157399 -0.1159413 -0.1161400 -0.1163423 [7] -0.1165424 -0.1167427 -0.1169445 -0.1171452 -0.1173458 -0.1175461 [13] -0.1177473 -0.1179483 -0.1181489 -0.1183495 -0.1185509 -0.1187519 [19] -0.1189529 -0.1191540 -0.1193548 -0.1195557 -0.1197570 -0.1199581 [25] -0.1201591 -0.1203602 -0.1205613 -0.1207624 -0.1209636 -0.1211647 [31] -0.1213660 -0.1215672 -0.1217683 -0.1219696 -0.1221709 -0.1223721 [37] -0.1225734 -0.1227747 -0.1229760 -0.1231774 -0.1233787 -0.1235800 [43] -0.1237814 -0.1239827 -0.1241841 -0.1243855 -0.1245869 -0.1247883 [49] -0.1249898 -0.1251912 -0.1253926 -0.1255941 -0.1257955 -0.1259970 [55] -0.1261985 -0.1264000 -0.1266014 -0.1268029 -0.1270044 -0.1272059 [61] -0.1274074 -0.1276090 -0.1278105 -0.1280120 -0.1282135 -0.1284151 [67] -0.1286166 -0.1288181 -0.1290197 -0.1292212 -0.1294227 -0.1296243 [73] -0.1298258 -0.1300274 -0.1302289 -0.1304304 -0.1306320 -0.1308335 [79] -0.1310351 -0.1312366 -0.1314381 -0.1316397 -0.1318412 -0.1320427 [85] -0.1322442 -0.1324458 -0.1326473 -0.1328488 -0.1330503 -0.1332518 [91] -0.1334533 -0.1336547 -0.1338562 -0.1340577 -0.1342592 -0.1344606 [97] -0.1346621 -0.1348635 -0.1350649 -0.1352663 -0.1354677 -0.1356691 [103] -0.1358705 -0.1360719 -0.1362733 -0.1364746 -0.1366760 -0.1368773 [109] -0.1370786 -0.1372799 -0.1374812 -0.1376825 -0.1378838 -0.1380850 [115] -0.1382862 -0.1384874 -0.1386886 -0.1388898 -0.1390910 -0.1392921 [121] -0.1394933 -0.1396944 -0.1398955 -0.1400966 -0.1402976 -0.1404987 [127] -0.1406997 -0.1409007 -0.1411017 -0.1413026 -0.1415036 -0.1417045 [133] -0.1419054 -0.1421063 -0.1423071 -0.1425079 -0.1427088 -0.1429095 [139] -0.1431103 -0.1433110 -0.1435117 -0.1437124 -0.1439131 -0.1441137 [145] -0.1443143 -0.1445149 -0.1447154 -0.1449160 -0.1451165 -0.1453169 [151] -0.1455174 -0.1457178 -0.1459181 -0.1461185 -0.1463188 -0.1465191 [157] -0.1467194 -0.1469196 -0.1471198 -0.1473200 -0.1475201 -0.1477202 [163] -0.1479203 -0.1481203 -0.1483203 -0.1485203 -0.1487202 -0.1489201 [169] -0.1491199 -0.1493198 -0.1495195 -0.1497193 -0.1499190 -0.1501187 [175] -0.1503183 -0.1505179 -0.1507175 -0.1509170 -0.1511165 -0.1513160 [181] -0.1515154 -0.1517147 -0.1519141 -0.1521133 -0.1523126 -0.1525118 [187] -0.1527110 -0.1529101 -0.1531091 -0.1533082 -0.1535072 -0.1537061 [193] -0.1539050 -0.1541039 -0.1543027 -0.1545015 -0.1547002 -0.1548988 [199] -0.1550975 -0.1552961 -0.1554946 -0.1556931 -0.1558915 -0.1560899 [205] -0.1562883 -0.1564865 -0.1566848 -0.1568830 -0.1570811 -0.1572792 [211] -0.1574773 -0.1576753 -0.1578732 -0.1580711 -0.1582689 -0.1584667 [217] -0.1586644 -0.1588621 -0.1590597 -0.1592573 -0.1594548 -0.1596523 [223] -0.1598497 -0.1600471 -0.1602443 -0.1604416 -0.1606388 -0.1608359 [229] -0.1610330 -0.1612300 -0.1614269 -0.1616238 -0.1618207 -0.1620174 [235] -0.1622141 -0.1624108 -0.1626074 -0.1628039 -0.1630004 -0.1631968 [241] -0.1633932 -0.1635895 -0.1637857 -0.1639819 -0.1641780 -0.1643740 [247] -0.1645700 -0.1647659 -0.1649618 -0.1651575 -0.1653533 -0.1655489 [253] -0.1657445 -0.1659400 -0.1661355 -0.1663309 -0.1665262 -0.1667214 [259] -0.1669166 -0.1671118 -0.1673068 -0.1675018 -0.1676967 -0.1678915 [265] -0.1680863 -0.1682810 -0.1684756 -0.1686702 -0.1688647 -0.1690591 [271] -0.1692535 -0.1694477 -0.1696419 -0.1698361 -0.1700301 -0.1702241 [277] -0.1704180 -0.1706118 -0.1708056 -0.1709993 -0.1711929 -0.1713864 [283] -0.1715799 -0.1717732 -0.1719665 -0.1721598 -0.1723529 -0.1725460 [289] -0.1727390 -0.1729319 -0.1731247 -0.1733175 -0.1735102 -0.1737028 [295] -0.1738953 -0.1740877 -0.1742801 -0.1744723 -0.1746645 -0.1748566 [301] -0.1750487 -0.1752406 -0.1754325 -0.1756243 -0.1758160 -0.1760076 [307] -0.1761991 -0.1763906 -0.1765819 -0.1767732 -0.1769644 -0.1771555 [313] -0.1773465 -0.1775374 -0.1777283 -0.1779190 -0.1781097 -0.1783003 [319] -0.1784908 -0.1786812 -0.1788715 -0.1790618 -0.1792519 -0.1794419 [325] -0.1796319 -0.1798218 -0.1800116 -0.1802013 -0.1803909 -0.1805804 [331] -0.1807698 -0.1809591 -0.1811483 -0.1813375 -0.1815265 -0.1817155 [337] -0.1819043 -0.1820931 -0.1822818 -0.1824703 -0.1826588 -0.1828472 [343] -0.1830355 -0.1832237 -0.1834118 -0.1835998 -0.1837877 -0.1839755 [349] -0.1841632 -0.1843508 -0.1845384 -0.1847258 -0.1849131 -0.1851003 [355] -0.1852874 -0.1854745 -0.1856614 -0.1858482 -0.1860349 -0.1862216 [361] -0.1864081 -0.1865945 -0.1867808 -0.1869670 -0.1871531 -0.1873392 [367] -0.1875251 -0.1877109 -0.1878966 -0.1880822 -0.1882677 -0.1884531 [373] -0.1886383 -0.1888235 -0.1890086 -0.1891936 -0.1893784 -0.1895632 [379] -0.1897478 -0.1899324 -0.1901168 -0.1903012 -0.1904854 -0.1906695 [385] -0.1908535 -0.1910374 -0.1912212 -0.1914049 -0.1915885 -0.1917719 [391] -0.1919553 -0.1921385 -0.1923217 -0.1925047 -0.1926876 -0.1928704 [397] -0.1930531 -0.1932357 -0.1934182 -0.1936005 -0.1937828 > mx [1] 0.1937828 > 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/1a15a1226505919.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/2hcoi1226505919.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/3dre41226505919.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/428js1226505919.tab") > > system("convert tmp/1a15a1226505919.ps tmp/1a15a1226505919.png") > system("convert tmp/2hcoi1226505919.ps tmp/2hcoi1226505919.png") > system("convert tmp/3dre41226505919.ps tmp/3dre41226505919.png") > > > proc.time() user system elapsed 1.025 0.501 1.177