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. > x <- c(110.40,96.40,101.90,106.20,81.00,94.70,101.00,109.40,102.30,90.70,96.20,96.10,106.00,103.10,102.00,104.70,86.00,92.10,106.90,112.60,101.70,92.00,97.40,97.00,105.40,102.70,98.10,104.50,87.40,89.90,109.80,111.70,98.60,96.90,95.10,97.00,112.70,102.90,97.40,111.40,87.40,96.80,114.10,110.30,103.90,101.60,94.60,95.90,104.70,102.80,98.10,113.90,80.90,95.70,113.20,105.90,108.80,102.30,99.00,100.70,115.50) > #'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 Normality Plot (v1.0.4) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_boxcoxnorm.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(qnorm(ppoints(x), mean=0, sd=1),x1) + if (mx < c[i]) + { + mx <- c[i] + mxli <- l[i] + } + } > c [1] 0.1472623 0.1473229 0.1473836 0.1474442 0.1475048 0.1475655 0.1476260 [8] 0.1476866 0.1477472 0.1478077 0.1478683 0.1479288 0.1479893 0.1480498 [15] 0.1481102 0.1481707 0.1482311 0.1482915 0.1483519 0.1484123 0.1484727 [22] 0.1485330 0.1485934 0.1486537 0.1487140 0.1487743 0.1488346 0.1488948 [29] 0.1489551 0.1490153 0.1490755 0.1491357 0.1491959 0.1492560 0.1493162 [36] 0.1493763 0.1494364 0.1494965 0.1495566 0.1496166 0.1496767 0.1497367 [43] 0.1497967 0.1498567 0.1499167 0.1499767 0.1500366 0.1500965 0.1501564 [50] 0.1502163 0.1502762 0.1503361 0.1503959 0.1504557 0.1505155 0.1505753 [57] 0.1506351 0.1506949 0.1507546 0.1508143 0.1508740 0.1509337 0.1509934 [64] 0.1510530 0.1511127 0.1511723 0.1512319 0.1512915 0.1513510 0.1514106 [71] 0.1514701 0.1515296 0.1515891 0.1516486 0.1517081 0.1517675 0.1518269 [78] 0.1518863 0.1519457 0.1520051 0.1520645 0.1521238 0.1521831 0.1522424 [85] 0.1523017 0.1523610 0.1524202 0.1524794 0.1525387 0.1525979 0.1526570 [92] 0.1527162 0.1527753 0.1528345 0.1528936 0.1529526 0.1530117 0.1530708 [99] 0.1531298 0.1531888 0.1532478 0.1533068 0.1533658 0.1534247 0.1534836 [106] 0.1535425 0.1536014 0.1536603 0.1537191 0.1537780 0.1538368 0.1538956 [113] 0.1539544 0.1540131 0.1540719 0.1541306 0.1541893 0.1542480 0.1543067 [120] 0.1543653 0.1544239 0.1544825 0.1545411 0.1545997 0.1546583 0.1547168 [127] 0.1547753 0.1548338 0.1548923 0.1549508 0.1550092 0.1550677 0.1551261 [134] 0.1551845 0.1552428 0.1553012 0.1553595 0.1554178 0.1554761 0.1555344 [141] 0.1555927 0.1556509 0.1557091 0.1557673 0.1558255 0.1558837 0.1559418 [148] 0.1560000 0.1560581 0.1561162 0.1561742 0.1562323 0.1562903 0.1563484 [155] 0.1564063 0.1564643 0.1565223 0.1565802 0.1566381 0.1566960 0.1567539 [162] 0.1568118 0.1568696 0.1569275 0.1569853 0.1570431 0.1571008 0.1571586 [169] 0.1572163 0.1572740 0.1573317 0.1573894 0.1574470 0.1575047 0.1575623 [176] 0.1576199 0.1576775 0.1577350 0.1577926 0.1578501 0.1579076 0.1579651 [183] 0.1580225 0.1580800 0.1581374 0.1581948 0.1582522 0.1583096 0.1583669 [190] 0.1584242 0.1584816 0.1585388 0.1585961 0.1586534 0.1587106 0.1587678 [197] 0.1588250 0.1588822 0.1589393 0.1589965 0.1590536 0.1591107 0.1591678 [204] 0.1592248 0.1592819 0.1593389 0.1593959 0.1594529 0.1595098 0.1595668 [211] 0.1596237 0.1596806 0.1597375 0.1597944 0.1598512 0.1599080 0.1599649 [218] 0.1600216 0.1600784 0.1601352 0.1601919 0.1602486 0.1603053 0.1603620 [225] 0.1604186 0.1604753 0.1605319 0.1605885 0.1606451 0.1607016 0.1607582 [232] 0.1608147 0.1608712 0.1609277 0.1609841 0.1610406 0.1610970 0.1611534 [239] 0.1612098 0.1612661 0.1613225 0.1613788 0.1614351 0.1614914 0.1615477 [246] 0.1616039 0.1616601 0.1617163 0.1617725 0.1618287 0.1618849 0.1619410 [253] 0.1619971 0.1620532 0.1621093 0.1621653 0.1622214 0.1622774 0.1623334 [260] 0.1623893 0.1624453 0.1625012 0.1625572 0.1626131 0.1626689 0.1627248 [267] 0.1627806 0.1628365 0.1628923 0.1629481 0.1630038 0.1630596 0.1631153 [274] 0.1631710 0.1632267 0.1632824 0.1633380 0.1633936 0.1634492 0.1635048 [281] 0.1635604 0.1636160 0.1636715 0.1637270 0.1637825 0.1638380 0.1638934 [288] 0.1639489 0.1640043 0.1640597 0.1641151 0.1641704 0.1642258 0.1642811 [295] 0.1643364 0.1643917 0.1644470 0.1645022 0.1645574 0.1646126 0.1646678 [302] 0.1647230 0.1647782 0.1648333 0.1648884 0.1649435 0.1649986 0.1650536 [309] 0.1651087 0.1651637 0.1652187 0.1652736 0.1653286 0.1653836 0.1654385 [316] 0.1654934 0.1655483 0.1656031 0.1656580 0.1657128 0.1657676 0.1658224 [323] 0.1658772 0.1659319 0.1659867 0.1660414 0.1660961 0.1661507 0.1662054 [330] 0.1662600 0.1663146 0.1663692 0.1664238 0.1664784 0.1665329 0.1665875 [337] 0.1666420 0.1666965 0.1667509 0.1668054 0.1668598 0.1669142 0.1669686 [344] 0.1670230 0.1670773 0.1671317 0.1671860 0.1672403 0.1672946 0.1673488 [351] 0.1674031 0.1674573 0.1675115 0.1675657 0.1676199 0.1676740 0.1677282 [358] 0.1677823 0.1678364 0.1678905 0.1679445 0.1679986 0.1680526 0.1681066 [365] 0.1681606 0.1682145 0.1682685 0.1683224 0.1683763 0.1684302 0.1684841 [372] 0.1685379 0.1685918 0.1686456 0.1686994 0.1687532 0.1688070 0.1688607 [379] 0.1689144 0.1689681 0.1690218 0.1690755 0.1691292 0.1691828 0.1692364 [386] 0.1692900 0.1693436 0.1693972 0.1694507 0.1695042 0.1695577 0.1696112 [393] 0.1696647 0.1697182 0.1697716 0.1698250 0.1698784 0.1699318 0.1699852 [400] 0.1700385 0.1700919 > mx [1] 0.1700919 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/13r0e1194285643.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(l,c,main='Box-Cox Normality Plot',xlab='Lambda',ylab='correlation') > mtext(paste('Optimal Lambda =',mxli)) > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/2qqp91194285643.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(x,main='Histogram of Original Data',xlab='X',ylab='frequency') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/3hhtz1194285643.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > hist(x1,main='Histogram of Transformed Data',xlab='X',ylab='frequency') > grid() > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/4uc991194285643.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x) > grid() > mtext('Original Data') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/5i1f51194285644.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x1) > grid() > mtext('Transformed Data') > 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 Normality 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',header=TRUE) > a<-table.element(a,mxli) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/69gpl1194285645.tab") > > system("convert tmp/13r0e1194285643.ps tmp/13r0e1194285643.png") > system("convert tmp/2qqp91194285643.ps tmp/2qqp91194285643.png") > system("convert tmp/3hhtz1194285643.ps tmp/3hhtz1194285643.png") > system("convert tmp/4uc991194285643.ps tmp/4uc991194285643.png") > system("convert tmp/5i1f51194285644.ps tmp/5i1f51194285644.png") > > > proc.time() user system elapsed 2.373 1.305 2.550