R version 2.8.0 (2008-10-20) 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. > x <- c(3900,4307,4631,4347,4287,3801,4916,4591,4433,4317,4316,4284,4512,4378,4869,4799,3771) > #'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(qnorm(ppoints(x), mean=0, sd=1),x1) + if (mx < c[i]) + { + mx <- c[i] + mxli <- l[i] + } + } > c [1] 0.1199669 0.1201000 0.1202330 0.1203660 0.1204989 0.1206318 0.1207647 [8] 0.1208975 0.1210303 0.1211630 0.1212958 0.1214284 0.1215610 0.1216936 [15] 0.1218262 0.1219587 0.1220911 0.1222236 0.1223559 0.1224883 0.1226206 [22] 0.1227528 0.1228850 0.1230172 0.1231493 0.1232814 0.1234135 0.1235455 [29] 0.1236774 0.1238093 0.1239412 0.1240730 0.1242048 0.1243366 0.1244683 [36] 0.1245999 0.1247315 0.1248631 0.1249946 0.1251261 0.1252575 0.1253889 [43] 0.1255202 0.1256515 0.1257828 0.1259140 0.1260452 0.1261763 0.1263073 [50] 0.1264384 0.1265693 0.1267003 0.1268312 0.1269620 0.1270928 0.1272235 [57] 0.1273542 0.1274849 0.1276155 0.1277460 0.1278765 0.1280070 0.1281374 [64] 0.1282678 0.1283981 0.1285283 0.1286586 0.1287887 0.1289189 0.1290489 [71] 0.1291789 0.1293089 0.1294388 0.1295687 0.1296985 0.1298283 0.1299580 [78] 0.1300877 0.1302173 0.1303469 0.1304764 0.1306059 0.1307353 0.1308647 [85] 0.1309940 0.1311233 0.1312525 0.1313817 0.1315108 0.1316399 0.1317689 [92] 0.1318978 0.1320267 0.1321556 0.1322844 0.1324131 0.1325418 0.1326705 [99] 0.1327991 0.1329276 0.1330561 0.1331845 0.1333129 0.1334412 0.1335695 [106] 0.1336977 0.1338258 0.1339539 0.1340820 0.1342100 0.1343379 0.1344658 [113] 0.1345936 0.1347214 0.1348491 0.1349768 0.1351044 0.1352319 0.1353594 [120] 0.1354869 0.1356143 0.1357416 0.1358689 0.1359961 0.1361232 0.1362503 [127] 0.1363774 0.1365044 0.1366313 0.1367581 0.1368850 0.1370117 0.1371384 [134] 0.1372650 0.1373916 0.1375181 0.1376446 0.1377710 0.1378974 0.1380236 [141] 0.1381499 0.1382760 0.1384021 0.1385282 0.1386542 0.1387801 0.1389060 [148] 0.1390318 0.1391575 0.1392832 0.1394089 0.1395344 0.1396599 0.1397854 [155] 0.1399108 0.1400361 0.1401613 0.1402865 0.1404117 0.1405368 0.1406618 [162] 0.1407867 0.1409116 0.1410364 0.1411612 0.1412859 0.1414106 0.1415351 [169] 0.1416596 0.1417841 0.1419085 0.1420328 0.1421571 0.1422813 0.1424054 [176] 0.1425295 0.1426535 0.1427774 0.1429013 0.1430251 0.1431488 0.1432725 [183] 0.1433961 0.1435197 0.1436432 0.1437666 0.1438900 0.1440133 0.1441365 [190] 0.1442596 0.1443827 0.1445058 0.1446287 0.1447516 0.1448744 0.1449972 [197] 0.1451199 0.1452425 0.1453651 0.1454876 0.1456100 0.1457324 0.1458547 [204] 0.1459769 0.1460990 0.1462211 0.1463432 0.1464651 0.1465870 0.1467088 [211] 0.1468305 0.1469522 0.1470738 0.1471954 0.1473168 0.1474382 0.1475596 [218] 0.1476808 0.1478020 0.1479232 0.1480442 0.1481652 0.1482861 0.1484069 [225] 0.1485277 0.1486484 0.1487690 0.1488896 0.1490101 0.1491305 0.1492509 [232] 0.1493711 0.1494913 0.1496115 0.1497315 0.1498515 0.1499714 0.1500913 [239] 0.1502111 0.1503308 0.1504504 0.1505699 0.1506894 0.1508088 0.1509282 [246] 0.1510474 0.1511666 0.1512857 0.1514048 0.1515237 0.1516426 0.1517615 [253] 0.1518802 0.1519989 0.1521175 0.1522360 0.1523545 0.1524728 0.1525912 [260] 0.1527094 0.1528275 0.1529456 0.1530636 0.1531815 0.1532994 0.1534172 [267] 0.1535349 0.1536525 0.1537700 0.1538875 0.1540049 0.1541222 0.1542395 [274] 0.1543567 0.1544737 0.1545908 0.1547077 0.1548246 0.1549413 0.1550581 [281] 0.1551747 0.1552912 0.1554077 0.1555241 0.1556404 0.1557567 0.1558728 [288] 0.1559889 0.1561049 0.1562209 0.1563367 0.1564525 0.1565682 0.1566838 [295] 0.1567993 0.1569148 0.1570302 0.1571455 0.1572607 0.1573758 0.1574909 [302] 0.1576059 0.1577208 0.1578356 0.1579503 0.1580650 0.1581796 0.1582941 [309] 0.1584085 0.1585229 0.1586371 0.1587513 0.1588654 0.1589794 0.1590933 [316] 0.1592072 0.1593210 0.1594347 0.1595483 0.1596618 0.1597753 0.1598886 [323] 0.1600019 0.1601151 0.1602282 0.1603413 0.1604542 0.1605671 0.1606799 [330] 0.1607926 0.1609052 0.1610178 0.1611302 0.1612426 0.1613549 0.1614671 [337] 0.1615792 0.1616913 0.1618032 0.1619151 0.1620269 0.1621386 0.1622502 [344] 0.1623618 0.1624732 0.1625846 0.1626959 0.1628071 0.1629182 0.1630292 [351] 0.1631402 0.1632511 0.1633618 0.1634725 0.1635831 0.1636937 0.1638041 [358] 0.1639145 0.1640247 0.1641349 0.1642450 0.1643550 0.1644649 0.1645748 [365] 0.1646845 0.1647942 0.1649038 0.1650133 0.1651227 0.1652320 0.1653412 [372] 0.1654504 0.1655594 0.1656684 0.1657773 0.1658861 0.1659948 0.1661034 [379] 0.1662120 0.1663204 0.1664288 0.1665370 0.1666452 0.1667533 0.1668613 [386] 0.1669693 0.1670771 0.1671848 0.1672925 0.1674001 0.1675075 0.1676149 [393] 0.1677222 0.1678294 0.1679366 0.1680436 0.1681506 0.1682574 0.1683642 [400] 0.1684709 0.1685774 > mx [1] 0.1685774 > mxli [1] 2 > if (mxli != 0) + { + x1 <- (x^mxli - 1) / mxli + } else { + x1 <- log(x) + } > postscript(file="/var/www/html/freestat/rcomp/tmp/1mbx91238342152.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/freestat/rcomp/tmp/2o4gs1238342152.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/freestat/rcomp/tmp/3jtbi1238342152.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/freestat/rcomp/tmp/4jlcw1238342152.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x) > qqline(x) > grid() > mtext('Original Data') > dev.off() null device 1 > postscript(file="/var/www/html/freestat/rcomp/tmp/50fzo1238342152.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > qqnorm(x1) > qqline(x1) > grid() > mtext('Transformed Data') > dev.off() null device 1 > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/6xjck1238342152.tab") > > system("convert tmp/1mbx91238342152.ps tmp/1mbx91238342152.png") > system("convert tmp/2o4gs1238342152.ps tmp/2o4gs1238342152.png") > system("convert tmp/3jtbi1238342152.ps tmp/3jtbi1238342152.png") > system("convert tmp/4jlcw1238342152.ps tmp/4jlcw1238342152.png") > system("convert tmp/50fzo1238342152.ps tmp/50fzo1238342152.png") > > > proc.time() user system elapsed 1.727 1.274 1.931