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(88.8,93.4,92.6,90.7,81.6,84.1,88.1,85.3,82.9,84.8,71.2,68.9,94.3,97.6,85.6,91.9,75.8,79.8,99,88.5,86.7,97.9,94.3,72.9,91.8,93.2,86.5,98.9,77.2,79.4,90.4,81.4,85.8,103.6,73.6,75.7,99.2,88.7,94.6,98.7,84.2,87.7,103.3,88.2,93.4,106.3,73.1,78.6,101.6,101.4,98.5,99,89.5,83.5,97.4,87.8,90.4,97.1,79.4,85) > #'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.1412352 0.1412931 0.1413511 0.1414092 0.1414672 0.1415254 0.1415836 [8] 0.1416418 0.1417001 0.1417585 0.1418169 0.1418753 0.1419338 0.1419924 [15] 0.1420510 0.1421096 0.1421683 0.1422271 0.1422859 0.1423448 0.1424037 [22] 0.1424627 0.1425217 0.1425807 0.1426399 0.1426990 0.1427582 0.1428175 [29] 0.1428768 0.1429362 0.1429956 0.1430551 0.1431146 0.1431741 0.1432338 [36] 0.1432934 0.1433531 0.1434129 0.1434727 0.1435326 0.1435925 0.1436524 [43] 0.1437124 0.1437725 0.1438326 0.1438927 0.1439529 0.1440131 0.1440734 [50] 0.1441337 0.1441941 0.1442545 0.1443150 0.1443755 0.1444361 0.1444967 [57] 0.1445574 0.1446181 0.1446788 0.1447396 0.1448005 0.1448613 0.1449223 [64] 0.1449832 0.1450443 0.1451053 0.1451664 0.1452276 0.1452888 0.1453500 [71] 0.1454113 0.1454727 0.1455340 0.1455955 0.1456569 0.1457184 0.1457800 [78] 0.1458416 0.1459032 0.1459649 0.1460266 0.1460884 0.1461502 0.1462120 [85] 0.1462739 0.1463359 0.1463979 0.1464599 0.1465219 0.1465840 0.1466462 [92] 0.1467084 0.1467706 0.1468329 0.1468952 0.1469575 0.1470199 0.1470823 [99] 0.1471448 0.1472073 0.1472699 0.1473324 0.1473951 0.1474577 0.1475205 [106] 0.1475832 0.1476460 0.1477088 0.1477717 0.1478346 0.1478975 0.1479605 [113] 0.1480235 0.1480866 0.1481497 0.1482128 0.1482760 0.1483392 0.1484024 [120] 0.1484657 0.1485290 0.1485924 0.1486558 0.1487192 0.1487827 0.1488462 [127] 0.1489097 0.1489733 0.1490369 0.1491005 0.1491642 0.1492279 0.1492917 [134] 0.1493555 0.1494193 0.1494832 0.1495470 0.1496110 0.1496749 0.1497389 [141] 0.1498030 0.1498670 0.1499311 0.1499953 0.1500594 0.1501236 0.1501878 [148] 0.1502521 0.1503164 0.1503807 0.1504451 0.1505095 0.1505739 0.1506384 [155] 0.1507029 0.1507674 0.1508320 0.1508965 0.1509612 0.1510258 0.1510905 [162] 0.1511552 0.1512199 0.1512847 0.1513495 0.1514144 0.1514792 0.1515441 [169] 0.1516090 0.1516740 0.1517390 0.1518040 0.1518690 0.1519341 0.1519992 [176] 0.1520643 0.1521295 0.1521947 0.1522599 0.1523251 0.1523904 0.1524557 [183] 0.1525210 0.1525864 0.1526518 0.1527172 0.1527826 0.1528481 0.1529136 [190] 0.1529791 0.1530446 0.1531102 0.1531758 0.1532414 0.1533070 0.1533727 [197] 0.1534384 0.1535041 0.1535699 0.1536357 0.1537015 0.1537673 0.1538331 [204] 0.1538990 0.1539649 0.1540308 0.1540968 0.1541628 0.1542287 0.1542948 [211] 0.1543608 0.1544269 0.1544930 0.1545591 0.1546252 0.1546914 0.1547575 [218] 0.1548237 0.1548900 0.1549562 0.1550225 0.1550888 0.1551551 0.1552214 [225] 0.1552878 0.1553541 0.1554205 0.1554869 0.1555534 0.1556198 0.1556863 [232] 0.1557528 0.1558193 0.1558859 0.1559524 0.1560190 0.1560856 0.1561522 [239] 0.1562188 0.1562855 0.1563522 0.1564188 0.1564856 0.1565523 0.1566190 [246] 0.1566858 0.1567526 0.1568194 0.1568862 0.1569530 0.1570199 0.1570867 [253] 0.1571536 0.1572205 0.1572874 0.1573544 0.1574213 0.1574883 0.1575553 [260] 0.1576223 0.1576893 0.1577563 0.1578234 0.1578904 0.1579575 0.1580246 [267] 0.1580917 0.1581588 0.1582259 0.1582931 0.1583602 0.1584274 0.1584946 [274] 0.1585618 0.1586290 0.1586963 0.1587635 0.1588308 0.1588980 0.1589653 [281] 0.1590326 0.1590999 0.1591672 0.1592345 0.1593019 0.1593692 0.1594366 [288] 0.1595040 0.1595714 0.1596388 0.1597062 0.1597736 0.1598410 0.1599085 [295] 0.1599759 0.1600434 0.1601109 0.1601783 0.1602458 0.1603133 0.1603808 [302] 0.1604484 0.1605159 0.1605834 0.1606510 0.1607185 0.1607861 0.1608537 [309] 0.1609212 0.1609888 0.1610564 0.1611240 0.1611916 0.1612592 0.1613269 [316] 0.1613945 0.1614621 0.1615298 0.1615974 0.1616651 0.1617328 0.1618004 [323] 0.1618681 0.1619358 0.1620035 0.1620712 0.1621389 0.1622066 0.1622743 [330] 0.1623420 0.1624097 0.1624774 0.1625452 0.1626129 0.1626806 0.1627484 [337] 0.1628161 0.1628839 0.1629516 0.1630194 0.1630871 0.1631549 0.1632227 [344] 0.1632904 0.1633582 0.1634260 0.1634937 0.1635615 0.1636293 0.1636971 [351] 0.1637648 0.1638326 0.1639004 0.1639682 0.1640360 0.1641038 0.1641715 [358] 0.1642393 0.1643071 0.1643749 0.1644427 0.1645105 0.1645783 0.1646461 [365] 0.1647139 0.1647816 0.1648494 0.1649172 0.1649850 0.1650528 0.1651206 [372] 0.1651883 0.1652561 0.1653239 0.1653917 0.1654594 0.1655272 0.1655950 [379] 0.1656627 0.1657305 0.1657983 0.1658660 0.1659338 0.1660015 0.1660693 [386] 0.1661370 0.1662047 0.1662725 0.1663402 0.1664079 0.1664757 0.1665434 [393] 0.1666111 0.1666788 0.1667465 0.1668142 0.1668819 0.1669496 0.1670172 [400] 0.1670849 0.1671526 > mx [1] 0.1671526 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/rcomp/tmp/1ptb11196503008.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/27zlq1196503008.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/3d8441196503008.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/474by1196503008.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/5k9u91196503008.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/6mk0z1196503008.tab") > > system("convert tmp/1ptb11196503008.ps tmp/1ptb11196503008.png") > system("convert tmp/27zlq1196503008.ps tmp/27zlq1196503008.png") > system("convert tmp/3d8441196503008.ps tmp/3d8441196503008.png") > system("convert tmp/474by1196503008.ps tmp/474by1196503008.png") > system("convert tmp/5k9u91196503008.ps tmp/5k9u91196503008.png") > > > proc.time() user system elapsed 1.354 0.803 1.648