R version 2.6.0 (2007-10-03) Copyright (C) 2007 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(2.90,2.63,2.67,1.81,1.33,0.88,1.28,1.26,1.26,1.29,1.10,1.37,1.21,1.74,1.76,1.48,1.04,1.62,1.49,1.79,1.80,1.58,1.86,1.74,1.59,1.26,1.13,1.92,2.61,2.26,2.41,2.26,2.03,2.86,2.55,2.27,2.26,2.57,3.07,2.76,2.51,2.87,3.14,3.11,3.16,2.47,2.57,2.89,2.63,2.38,1.69,1.96,2.19,1.87,1.60,1.63,1.22,1.21,1.49,1.64,1.66,1.77,1.82,1.78,1.28,1.29,1.37,1.12,1.51) > x <- c(95.90,96.06,96.31,96.34,96.49,96.22,96.53,96.50,96.77,96.66,96.58,96.63,97.06,97.73,98.01,97.76,97.49,97.77,97.96,98.23,98.51,98.19,98.37,98.31,98.60,98.97,99.11,99.64,100.03,99.98,100.32,100.44,100.51,101.00,100.88,100.55,100.83,101.51,102.16,102.39,102.54,102.85,103.47,103.57,103.69,103.50,103.47,103.45,103.48,103.93,103.89,104.40,104.79,104.77,105.13,105.26,104.96,104.75,105.01,105.15,105.20,105.77,105.78,106.26,106.13,106.12,106.57,106.44,106.54) > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2007), Box-Cox Linearity Plot (v1.0.3) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxlin.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description > 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.1680335 0.1679703 0.1679071 0.1678439 0.1677808 0.1677175 0.1676543 [8] 0.1675911 0.1675278 0.1674645 0.1674012 0.1673379 0.1672746 0.1672113 [15] 0.1671479 0.1670846 0.1670212 0.1669578 0.1668944 0.1668310 0.1667675 [22] 0.1667041 0.1666406 0.1665771 0.1665136 0.1664501 0.1663866 0.1663230 [29] 0.1662595 0.1661959 0.1661323 0.1660687 0.1660051 0.1659414 0.1658778 [36] 0.1658141 0.1657504 0.1656867 0.1656230 0.1655593 0.1654956 0.1654318 [43] 0.1653680 0.1653043 0.1652405 0.1651766 0.1651128 0.1650490 0.1649851 [50] 0.1649212 0.1648573 0.1647934 0.1647295 0.1646656 0.1646016 0.1645377 [57] 0.1644737 0.1644097 0.1643457 0.1642817 0.1642176 0.1641536 0.1640895 [64] 0.1640254 0.1639613 0.1638972 0.1638331 0.1637690 0.1637048 0.1636406 [71] 0.1635765 0.1635123 0.1634480 0.1633838 0.1633196 0.1632553 0.1631910 [78] 0.1631268 0.1630625 0.1629981 0.1629338 0.1628695 0.1628051 0.1627407 [85] 0.1626763 0.1626119 0.1625475 0.1624831 0.1624186 0.1623542 0.1622897 [92] 0.1622252 0.1621607 0.1620962 0.1620316 0.1619671 0.1619025 0.1618379 [99] 0.1617733 0.1617087 0.1616441 0.1615795 0.1615148 0.1614502 0.1613855 [106] 0.1613208 0.1612561 0.1611914 0.1611266 0.1610619 0.1609971 0.1609323 [113] 0.1608675 0.1608027 0.1607379 0.1606731 0.1606082 0.1605433 0.1604784 [120] 0.1604136 0.1603486 0.1602837 0.1602188 0.1601538 0.1600889 0.1600239 [127] 0.1599589 0.1598939 0.1598288 0.1597638 0.1596987 0.1596337 0.1595686 [134] 0.1595035 0.1594384 0.1593733 0.1593081 0.1592430 0.1591778 0.1591126 [141] 0.1590474 0.1589822 0.1589170 0.1588518 0.1587865 0.1587212 0.1586560 [148] 0.1585907 0.1585254 0.1584600 0.1583947 0.1583293 0.1582640 0.1581986 [155] 0.1581332 0.1580678 0.1580024 0.1579369 0.1578715 0.1578060 0.1577406 [162] 0.1576751 0.1576096 0.1575440 0.1574785 0.1574130 0.1573474 0.1572818 [169] 0.1572162 0.1571506 0.1570850 0.1570194 0.1569537 0.1568881 0.1568224 [176] 0.1567567 0.1566910 0.1566253 0.1565596 0.1564938 0.1564281 0.1563623 [183] 0.1562965 0.1562307 0.1561649 0.1560991 0.1560332 0.1559674 0.1559015 [190] 0.1558356 0.1557697 0.1557038 0.1556379 0.1555720 0.1555060 0.1554401 [197] 0.1553741 0.1553081 0.1552421 0.1551761 0.1551100 0.1550440 0.1549779 [204] 0.1549119 0.1548458 0.1547797 0.1547136 0.1546474 0.1545813 0.1545151 [211] 0.1544490 0.1543828 0.1543166 0.1542504 0.1541842 0.1541179 0.1540517 [218] 0.1539854 0.1539191 0.1538528 0.1537865 0.1537202 0.1536539 0.1535875 [225] 0.1535212 0.1534548 0.1533884 0.1533220 0.1532556 0.1531892 0.1531227 [232] 0.1530563 0.1529898 0.1529233 0.1528568 0.1527903 0.1527238 0.1526573 [239] 0.1525907 0.1525242 0.1524576 0.1523910 0.1523244 0.1522578 0.1521912 [246] 0.1521245 0.1520579 0.1519912 0.1519245 0.1518578 0.1517911 0.1517244 [253] 0.1516577 0.1515909 0.1515242 0.1514574 0.1513906 0.1513238 0.1512570 [260] 0.1511901 0.1511233 0.1510565 0.1509896 0.1509227 0.1508558 0.1507889 [267] 0.1507220 0.1506551 0.1505881 0.1505212 0.1504542 0.1503872 0.1503202 [274] 0.1502532 0.1501862 0.1501191 0.1500521 0.1499850 0.1499179 0.1498508 [281] 0.1497837 0.1497166 0.1496495 0.1495823 0.1495152 0.1494480 0.1493808 [288] 0.1493136 0.1492464 0.1491792 0.1491120 0.1490447 0.1489775 0.1489102 [295] 0.1488429 0.1487756 0.1487083 0.1486410 0.1485736 0.1485063 0.1484389 [302] 0.1483716 0.1483042 0.1482368 0.1481694 0.1481019 0.1480345 0.1479670 [309] 0.1478996 0.1478321 0.1477646 0.1476971 0.1476296 0.1475620 0.1474945 [316] 0.1474269 0.1473594 0.1472918 0.1472242 0.1471566 0.1470890 0.1470213 [323] 0.1469537 0.1468860 0.1468184 0.1467507 0.1466830 0.1466153 0.1465476 [330] 0.1464798 0.1464121 0.1463443 0.1462766 0.1462088 0.1461410 0.1460732 [337] 0.1460053 0.1459375 0.1458697 0.1458018 0.1457339 0.1456660 0.1455981 [344] 0.1455302 0.1454623 0.1453944 0.1453264 0.1452585 0.1451905 0.1451225 [351] 0.1450545 0.1449865 0.1449185 0.1448504 0.1447824 0.1447143 0.1446463 [358] 0.1445782 0.1445101 0.1444420 0.1443739 0.1443057 0.1442376 0.1441694 [365] 0.1441012 0.1440331 0.1439649 0.1438967 0.1438284 0.1437602 0.1436920 [372] 0.1436237 0.1435554 0.1434871 0.1434188 0.1433505 0.1432822 0.1432139 [379] 0.1431455 0.1430772 0.1430088 0.1429404 0.1428720 0.1428036 0.1427352 [386] 0.1426668 0.1425984 0.1425299 0.1424614 0.1423930 0.1423245 0.1422560 [393] 0.1421875 0.1421189 0.1420504 0.1419818 0.1419133 0.1418447 0.1417761 [400] 0.1417075 0.1416389 > mx [1] 0.1680335 > 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/1fbo31194256497.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/2aqt71194256497.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/3qdui1194256497.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 > 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/4sk5t1194256498.tab") > > system("convert tmp/1fbo31194256497.ps tmp/1fbo31194256497.png") > system("convert tmp/2aqt71194256497.ps tmp/2aqt71194256497.png") > system("convert tmp/3qdui1194256497.ps tmp/3qdui1194256497.png") > > > proc.time() user system elapsed 1.061 0.523 1.240