/usr/share/gretl/genrgui.hlp is in gretl-common 1.9.6-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 | ## Accessors
# $ahat access
Output: series
Must follow the estimation of a fixed-effect panel data model. Returns a series containing the estimates of the individual fixed effects (per-unit intercepts).
# $aic access
Output: scalar
Returns the Akaike Information Criterion for the last estimated model, if available. See <@pdf="the Gretl User's Guide"> for details of the calculation.
# $bic access
Output: scalar
Returns Schwarz's Bayesian Information Criterion for the last estimated model, if available. See <@pdf="the Gretl User's Guide"> for details of the calculation.
# $chisq access
Output: scalar
Returns the overall chi-square statistic from the last estimated model, if available.
# $coeff access
Output: matrix or scalar
Argument: <@var="s"> (name of coefficient, optional)
With no arguments, <@lit="$coeff"> returns a column vector containing the estimated coefficients for the last model. With the optional string argument it returns a scalar, namely the estimated parameter named <@var="s">. See also <@ref="$stderr">, <@ref="$vcv">.
Example:
<code>
open bjg
arima 0 1 1 ; 0 1 1 ; lg
b = $coeff # gets a vector
macoef = $coeff(theta_1) # gets a scalar
</code>
If the "model" in question is actually a system, the result depends on the characteristics of the system: for VARs and VECMs the value returned is a matrix with one column per equation, otherwise it is a column vector containing the coefficients from the first equation followed by those from the second equation, and so on.
# $command access
Output: string
Must follow the estimation of a model; returns the command word, for example <@lit="ols"> or <@lit="probit">.
# $compan access
Output: matrix
Must follow the estimation of a VAR or a VECM; returns the companion matrix.
# $datatype access
Output: scalar
Returns an integer value representing the sort of dataset that is currently loaded: 0 = no data; 1 = cross-sectional (undated) data; 2 = time-series data; 3 = panel data.
# $depvar access
Output: string
Must follow the estimation of a single-equation model; returns the name of the dependent variable.
# $df access
Output: scalar
Returns the degrees of freedom of the last estimated model. If the last model was in fact a system of equations, the value returned is the degrees of freedom per equation; if this differs across the equations then the value given is the number of observations minus the mean number of coefficients per equation (rounded up to the nearest integer).
# $dwpval access
Output: scalar
Returns the p-value for the Durbin–Watson statistic for the model last estimated, if available. This is computed using the Imhof procedure.
# $ec access
Output: matrix
Must follow the estimation of a VECM; returns a matrix containing the error correction terms. The number of rows equals the number of observations used and the number of columns equals the cointegration rank of the system.
# $error access
Output: scalar
Returns the program's internal error code, which will be non-zero in case an error has occurred but has been trapped using <@xrf="catch">. Note that using this accessor causes the internal error code to be reset to zero. See also <@ref="errmsg">. If you want to get the error message associated with a given <@lit="$error"> you need to store the value in a temporary variable, as in
<code>
errval = $error
if (errval)
printf "Got error %d (%s)\n", errval, errmsg(errval);
endif
</code>
# $ess access
Output: scalar
Returns the error sum of squares of the last estimated model, if available.
# $evals access
Output: matrix
Must follow the estimation of a VECM; returns a vector containing the eigenvalues that are used in computing the trace test for cointegration.
# $fcast access
Output: matrix
Must follow the <@xrf="fcast"> forecasting command; returns the forecast values as a matrix. If the model on which the forecast was based is a system of equations the returned matrix will have one column per equation, otherwise it is a column vector.
# $fcerr access
Output: matrix
Must follow the <@xrf="fcast"> forecasting command; returns the standard errors of the forecasts, if available, as a matrix. If the model on which the forecast was based is a system of equations the returned matrix will have one column per equation, otherwise it is a column vector.
# $fevd access
Output: matrix
Must follow estimation of a VAR. Returns a matrix containing the forecast error decomposition. This matrix has <@itl="h"> rows where <@itl="h"> is the forecast horizon, which can be chosen using <@lit="set horizon"> or otherwise is set automatically based on the frequency of the data. For a VAR with <@itl="p"> variables, the matrix has <@itl="p"><@sup="2"> columns. The fraction of the forecast error for variable <@itl="i"> attributable to innovation in variable <@itl="j"> is found in column (<@itl="i"> – 1)<@itl="p"> + <@itl="j">.
# $Fstat access
Output: scalar
Returns the overall F-statistic from the last estimated model, if available.
# $gmmcrit access
Output: scalar
Must follow a <@lit="gmm"> block. Returns the value of the objective function at its minimum.
# $h access
Output: series
Must follow a <@lit="garch"> command. Returns the estimated conditional variance series.
# $hausman access
Output: row vector
Must follow estimation of a model via either <@lit="tsls"> or <@lit="panel"> with the random effects option. Returns a 1×3 vector containing the value of the Hausman test statistic, the corresponding degrees of freedom and the p-value for the test, in that order.
# $hqc access
Output: scalar
Returns the Hannan-Quinn Information Criterion for the last estimated model, if available. See <@pdf="the Gretl User's Guide"> for details of the calculation.
# $jalpha access
Output: matrix
Must follow the estimation of a VECM, and returns the loadings matrix. It has as many rows as variables in the VECM and as many columns as the cointegration rank.
# $jbeta access
Output: matrix
Must follow the estimation of a VECM, and returns the cointegration matrix. It has as many rows as variables in the VECM (plus the number of exogenous variables that are restricted to the cointegration space, if any), and as many columns as the cointegration rank.
# $jvbeta access
Output: square matrix
Must follow the estimation of a VECM, and returns the estimated covariance matrix for the elements of the cointegration vectors.
In the case of unrestricted estimation, this matrix has a number of rows equal to the unrestricted elements of the cointegration space after the Phillips normalization. If, however, a restricted system is estimated via the <@lit="restrict"> command with the <@lit="--full"> option, a singular matrix with <@itl="(n+m)r"> rows will be returned (<@itl="n"> being the number of endogenous variables, <@itl="m"> the number of exogenous variables that are restricted to the cointegration space, and <@itl="r"> the cointegration rank).
Example: the code
<code>
open denmark.gdt
vecm 2 1 LRM LRY IBO IDE --rc --seasonals -q
s0 = $jvbeta
restrict --full
b[1,1] = 1
b[1,2] = -1
b[1,3] + b[1,4] = 0
end restrict
s1 = $jvbeta
print s0
print s1
</code>
produces the following output.
<code>
s0 (4 x 4)
0.019751 0.029816 -0.00044837 -0.12227
0.029816 0.31005 -0.45823 -0.18526
-0.00044837 -0.45823 1.2169 -0.035437
-0.12227 -0.18526 -0.035437 0.76062
s1 (5 x 5)
0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.27398 -0.27398 -0.019059
0.0000 0.0000 -0.27398 0.27398 0.019059
0.0000 0.0000 -0.019059 0.019059 0.0014180
</code>
# $llt access
Output: series
For selected models estimated via Maximum Likelihood, returns the series of per-observation log-likelihood values. At present this is supported only for binary logit and probit, tobit and heckit.
# $lnl access
Output: scalar
Returns the log-likelihood for the last estimated model (where applicable).
# $mnlprobs access
Output: matrix
Following estimation of a multinomial logit model (only), retrieves a matrix holding the estimated probabilities of each possible outcome at each observation in the model's sample range. Each row represents an observation and each column an outcome.
# $ncoeff access
Output: scalar
Returns the total number of coefficients estimated in the last model.
# $nobs access
Output: scalar
Returns the number of observations in the currently selected sample.
# $nvars access
Output: scalar
Returns the number of variables in the dataset (including the constant).
# $pd access
Output: scalar
Returns the frequency or periodicity of the data (e.g. 4 for quarterly data). In the case of panel data the value returned is the time-series length.
# $pvalue access
Output: scalar or matrix
Returns the p-value of the test statistic that was generated by the last explicit hypothesis-testing command, if any (e.g. <@lit="chow">). See <@pdf="the Gretl User's Guide"> for details.
In most cases the return value is a scalar but sometimes it is a matrix (for example, the trace and lambda-max p-values from the Johansen cointegration test); in that case the values in the matrix are laid out in the same pattern as the printed results.
See also <@ref="$test">.
# $rho access
Output: scalar
Argument: <@var="n"> (scalar, optional)
Without arguments, returns the first-order autoregressive coefficient for the residuals of the last model. After estimating a model via the <@lit="ar"> command, the syntax <@lit="$rho(n)"> returns the corresponding estimate of ρ(<@itl="n">).
# $rsq access
Output: scalar
Returns the unadjusted <@itl="R"><@sup="2"> from the last estimated model, if available.
# $sample access
Output: series
Must follow estimation of a single-equation model. Returns a dummy series with value 1 for observations used in estimation, 0 for observations within the currently defined sample range but not used (presumably because of missing values), and NA for observations outside of the current range.
If you wish to compute statistics based on the sample that was used for a given model, you can do, for example:
<code>
ols y 0 xlist
genr sdum = $sample
smpl sdum --dummy
</code>
# $sargan access
Output: row vector
Must follow a <@lit="tsls"> command. Returns a 1×3 vector, containing the value of the Sargan over-identification test statistic, the corresponding degrees of freedom and p-value, in that order.
# $sigma access
Output: scalar or matrix
Requires that a model has been estimated. If the last model was a single equation, returns the (scalar) Standard Error of the Regression (or in other words, the standard deviation of the residuals, with an appropriate degrees of freedom correction). If the last model was a system of equations, returns the cross-equation covariance matrix of the residuals.
# $stderr access
Output: matrix or scalar
Argument: <@var="s"> (name of coefficient, optional)
With no arguments, <@lit="$stderr"> returns a column vector containing the standard error of the coefficients for the last model. With the optional string argument it returns a scalar, namely the standard error of the parameter named <@var="s">.
If the "model" in question is actually a system, the result depends on the characteristics of the system: for VARs and VECMs the value returned is a matrix with one column per equation, otherwise it is a column vector containing the coefficients from the first equation followed by those from the second equation, and so on.
See also <@ref="$coeff">, <@ref="$vcv">.
# $stopwatch access
Output: scalar
Must be preceded by <@lit="set stopwatch">, which activates the measurement of CPU time. The first use of this accessor yields the seconds of CPU time that have elapsed since the <@lit="set stopwatch"> command. At each access the clock is reset, so subsequent uses of <@lit="$stopwatch"> yield the seconds of CPU time since the previous access.
# $sysA access
Output: matrix
Must follow estimation of a simultaneous equations system. Returns the matrix of coefficients on the lagged endogenous variables, if any, in the structural form of the system. See the <@xrf="system"> command.
# $sysB access
Output: matrix
Must follow estimation of a simultaneous equations system. Returns the matrix of coefficients on the exogenous variables in the structural form of the system. See the <@xrf="system"> command.
# $sysGamma access
Output: matrix
Must follow estimation of a simultaneous equations system. Returns the matrix of coefficients on the contemporaneous endogenous variables in the structural form of the system. See the <@xrf="system"> command.
# $T access
Output: scalar
Returns the number of observations used in estimating the last model.
# $t1 access
Output: scalar
Returns the 1-based index of the first observation in the currently selected sample.
# $t2 access
Output: scalar
Returns the 1-based index of the last observation in the currently selected sample.
# $test access
Output: scalar or matrix
Returns the value of the test statistic that was generated by the last explicit hypothesis-testing command, if any (e.g. <@lit="chow">). See <@pdf="the Gretl User's Guide"> for details.
In most cases the return value is a scalar but sometimes it is a matrix (for example, the trace and lambda-max statistics from the Johansen cointegration test); in that case the values in the matrix are laid out in the same pattern as the printed results.
See also <@ref="$pvalue">.
# $trsq access
Output: scalar
Returns <@itl="TR"><@sup="2"> (sample size times R-squared) from the last model, if available.
# $uhat access
Output: series
Returns the residuals from the last model. This may have different meanings for different estimators. For example, after an ARMA estimation <@lit="$uhat"> will contain the one-step-ahead forecast error; after a probit model, it will contain the generalized residuals.
If the "model" in question is actually a system (a VAR or VECM, or system of simultaneous equations), <@lit="$uhat"> with no parameters retrieves the matrix of residuals, one column per equation.
# $unit access
Output: series
Valid for panel datasets only. Returns a series with value 1 for all observations on the first unit or group, 2 for observations on the second unit, and so on.
# $vcv access
Output: matrix or scalar
Arguments: <@var="s1"> (name of coefficient, optional)
<@var="s2"> (name of coefficient, optional)
With no arguments, <@lit="$vcv"> returns a square matrix containing the estimated covariance matrix for the coefficients of the last model. If the last model was a single equation, then you may supply the names of two parameters in parentheses to retrieve the estimated covariance between the parameters named <@var="s1"> and <@var="s2">. See also <@ref="$coeff">, <@ref="$stderr">.
This accessor is not available for VARs or VECMs; for models of that sort see <@ref="$sigma"> and <@ref="$xtxinv">.
# $vecGamma access
Output: matrix
Must follow the estimation of a VECM; returns a matrix in which the Gamma matrices (coefficients on the lagged differences of the cointegrated variables) are stacked side by side. Each row represents an equation; for a VECM of lag order <@itl="p"> there are <@itl="p"> – 1 sub-matrices.
# $version access
Output: scalar
Returns an integer value that codes for the program version. The gretl version string takes the form <@lit="x.y.z"> (for example, 1.7.6). The return value from this accessor is formed as <@lit="10000*x + 100*y + z">, so that 1.7.6 translates as 10706.
# $vma access
Output: matrix
Must follow the estimation of a VAR or a VECM; returns a matrix containing the VMA representation up to the order specified via the <@lit="set horizon"> command. See <@pdf="the Gretl User's Guide"> for details.
# $windows access
Output: scalar
Returns 1 if gretl is running on MS Windows, otherwise 0. By conditioning on the value of this variable you can write shell calls that are portable across different operating systems.
Also see the <@xrf="shell"> command.
# $xlist access
Output: list
Returns the list of regressors from the last model (for single-equation models only).
# $xtxinv access
Output: matrix
Following estimation of a VAR or VECM (only), returns <@itl="X'X"><@sup="-1">, where <@itl="X"> is the common matrix of regressors used in each of the equations. This accessor is not available for a VECM estimated with a restriction imposed on α, the "loadings" matrix.
# $yhat access
Output: series
Returns the fitted values from the last regression.
## Functions proper
# abs math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the absolute value of <@var="x">.
# acos math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the arc cosine of <@var="x">, that is, the value whose cosine is <@var="x">. The result is in radians; the input should be in the range –1 to 1.
# acosh math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the inverse hyperbolic cosine of <@var="x"> (positive solution). <@var="x"> should be greater than 1; otherwise, NA is returned. See also <@ref="cosh">.
# argname strings
Output: string
Argument: <@var="s"> (string)
For <@var="s"> the name of a parameter to a user-defined function, returns the name of the corresponding argument, or an empty string if the argument was anonymous.
# asin math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the arc sine of <@var="x">, that is, the value whose sine is <@var="x">. The result is in radians; the input should be in the range –1 to 1.
# asinh math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the inverse hyperbolic sine of <@var="x">. See also <@ref="sinh">.
# atan math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the arc tangent of <@var="x">, that is, the value whose tangent is <@var="x">. The result is in radians.
# atanh math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the inverse hyperbolic tangent of <@var="x">. See also <@ref="tanh">.
# bessel math
Output: same type as input
Arguments: <@var="type"> (character)
<@var="v"> (scalar)
<@var="x"> (scalar, series or matrix)
Computes one of the Bessel function variants for order <@var="v"> and argument <@var="x">. The return value is of the same type as <@var="x">. The specific function is selected by the first argument, which must be <@lit="J">, <@lit="Y">, <@lit="I">, or <@lit="K">. A good discussion of the Bessel functions can be found on Wikipedia; here we give a brief account.
case <@lit="J">: Bessel function of the first kind. Resembles a damped sine wave. Defined for real <@var="v"> and <@var="x">, but if <@var="x"> is negative then <@var="v"> must be an integer.
case <@lit="Y">: Bessel function of the second kind. Defined for real <@var="v"> and <@var="x"> but has a singularity at <@var="x"> = 0.
case <@lit="I">: Modified Bessel function of the first kind. An exponentially growing function. Acceptable arguments are as for case <@lit="J">.
case <@lit="K">: Modified Bessel function of the second kind. An exponentially decaying function. Diverges at <@var="x"> = 0 and is not defined for negative <@var="x">. Symmetric around <@var="v"> = 0.
# BFGSmax numerical
Output: scalar
Arguments: <@var="b"> (vector)
<@var="f"> (function call)
<@var="g"> (function call, optional)
Numerical maximization via the method of Broyden, Fletcher, Goldfarb and Shanno. The vector <@var="b"> should hold the initial values of a set of parameters, and the argument <@var="f"> should specify a call to a function that calculates the (scalar) criterion to be maximized, given the current parameter values and any other relevant data. If the object is in fact minimization, this function should return the negative of the criterion. On successful completion, <@lit="BFGSmax"> returns the maximized value of the criterion, and <@var="b"> holds the parameter values which produce the maximum.
The optional third argument provides a means of supplying analytical derivatives (otherwise the gradient is computed numerically). The gradient function call <@var="g"> must have as its first argument a pre-defined matrix that is of the correct size to contain the gradient, given in pointer form. It also must take the parameter vector as an argument (in pointer form or otherwise). Other arguments are optional.
For more details and examples see the chapter on special functions in <@lit="genr"> in <@pdf="the Gretl User's Guide">. See also <@ref="NRmax">, <@ref="fdjac">.
# bkfilt filters
Output: series
Arguments: <@var="y"> (series)
<@var="f1"> (scalar, optional)
<@var="f2"> (scalar, optional)
<@var="k"> (scalar, optional)
Returns the result from application of the Baxter–King bandpass filter to the series <@var="y">. The optional parameters <@var="f1"> and <@var="f2"> represent, respectively, the lower and upper bounds of the range of frequencies to extract, while <@var="k"> is the approximation order to be used. If these arguments are not supplied then the following default values are used: <@var="f1"> = 8, <@var="f1"> = 32, <@var="k"> = 8. See also <@ref="hpfilt">.
# boxcox filters
Output: series
Arguments: <@var="y"> (series)
<@var="d"> (scalar)
Returns the Box–Cox transformation with parameter <@var="d"> for the positive series <@var="y">.
The transformed series is (<@itl="y"><@sup="d"> - 1)/<@itl="d"> for <@itl="d"> not equal to zero, or log(<@itl="y">) for <@itl="d"> = 0.
# bwfilt filters
Output: series
Arguments: <@var="y"> (series)
<@var="n"> (scalar)
<@var="omega"> (scalar)
Returns the result from application of a low-pass Butterworth filter with order <@var="n"> and frequency cutoff <@var="omega"> to the series <@var="y">. The cutoff is expressed in degrees and must be greater than 0 and less than 180. Smaller cutoff values restrict the pass-band to lower frequencies and hence produce a smoother trend. Higher values of <@var="n"> produce a sharper cutoff, at the cost of possible numerical instability.
Inspecting the periodogram of the target series is a useful preliminary when you wish to apply this function. See <@pdf="the Gretl User's Guide"> for details. See also <@ref="bkfilt">, <@ref="hpfilt">.
# cdemean stats
Output: matrix
Argument: <@var="X"> (matrix)
Centers the columns of matrix <@var="X"> around their means.
# cdf probdist
Output: same type as input
Arguments: <@var="c"> (character)
<@var="…"> (see below)
<@var="x"> (scalar, series or matrix)
Examples: <@lit="p1 = cdf(N, -2.5)">
<@lit="p2 = cdf(X, 3, 5.67)">
<@lit="p3 = cdf(D, 0.25, -1, 1)">
Cumulative distribution function calculator. Returns <@itl="P(X ≤ x)">, where the distribution <@itl="X"> is determined by the character <@var="c">. Between the arguments <@var="c"> and <@var="x">, zero or more additional scalar arguments are required to specify the parameters of the distribution, as follows.
<indent>
• Standard normal (c = z, n, or N): no extra arguments
</indent>
<indent>
• Bivariate normal (D): correlation coefficient
</indent>
<indent>
• Student's t (t): degrees of freedom
</indent>
<indent>
• Chi square (c, x, or X): degrees of freedom
</indent>
<indent>
• Snedecor's F (f or F): df (num.); df (den.)
</indent>
<indent>
• Gamma (g or G): shape; scale
</indent>
<indent>
• Binomial (b or B): probability; number of trials
</indent>
<indent>
• Poisson (p or P): Mean
</indent>
<indent>
• Weibull (w or W): shape; scale
</indent>
<indent>
• Generalized Error (E): shape
</indent>
Note that most cases have aliases to help memorizing the codes. The bivariate normal case is special: the syntax is <@lit="x = cdf(D, rho, z1, z2)"> where <@lit="rho"> is the correlation between the variables <@lit="z1"> and <@lit="z2">.
See also <@ref="pdf">, <@ref="critical">, <@ref="invcdf">, <@ref="pvalue">.
# cdiv linalg
Output: matrix
Arguments: <@var="X"> (matrix)
<@var="Y"> (matrix)
Complex division. The two arguments must have the same number of rows, <@itl="n">, and either one or two columns. The first column contains the real part and the second (if present) the imaginary part. The return value is an <@itl="n">×<@itl="2"> matrix or, if the result has no imaginary part, an <@itl="n">-vector. See also <@ref="cmult">.
# ceil math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Ceiling function: returns the smallest integer greater than or equal to <@var="x">. See also <@ref="floor">, <@ref="int">.
# cholesky linalg
Output: square matrix
Argument: <@var="A"> (symmetric matrix)
Peforms a Cholesky decomposition of the matrix <@var="A">, which is assumed to be symmetric and positive definite. The result is a lower-triangular matrix <@itl="L"> which satisfies <@itl="A = LL'">. The function will fail if <@var="A"> is not symmetric or not positive definite. See also <@ref="psdroot">.
# chowlin transforms
Output: matrix
Arguments: <@var="Y"> (matrix)
<@var="xfac"> (scalar)
<@var="X"> (matrix, optional)
Expands the input data, <@var="Y">, to a higher frequency, using the interpolation method of <@bib="Chow and Lin (1971);chowlin71">. It is assumed that the columns of <@var="Y"> represent data series; the returned matrix has as many columns as <@var="Y"> and <@var="xfac"> times as many rows.
The second argument represents the expansion factor: it should be 3 for expansion from quarterly to monthly or 4 for expansion from annual to quarterly, these being the only supported factors. The optional third argument may be used to provide a matrix of covariates at the higher (target) frequency.
The regressors used by default are a constant and quadratic trend. If <@var="X"> is provided, its columns are used as additional regressors; it is an error if the number of rows in <@var="X"> does not equal <@var="xfac"> times the number of rows in <@var="Y">.
# cmult linalg
Output: matrix
Arguments: <@var="X"> (matrix)
<@var="Y"> (matrix)
Complex multiplication. The two arguments must have the same number of rows, <@itl="n">, and either one or two columns. The first column contains the real part and the second (if present) the imaginary part. The return value is an <@itl="n">×<@itl="2"> matrix, or, if the result has no imaginary part, an <@itl="n">-vector. See also <@ref="cdiv">.
# cnorm probdist
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the cumulative distribution function for a standard normal. See also <@ref="dnorm">, <@ref="qnorm">.
# colname strings
Output: string
Arguments: <@var="M"> (matrix)
<@var="col"> (scalar)
Retrieves the name for column <@var="col"> of matrix <@var="M">. If <@var="M"> has no column names attached the value returned is an empty string; if <@var="col"> is out of bounds for the given matrix an error is flagged. See also <@ref="colnames">.
# colnames matbuild
Output: scalar
Arguments: <@var="M"> (matrix)
<@var="s"> (named list or string)
Attaches names to the columns of the <@itl="T">×<@itl="k"> matrix <@var="M">. If <@var="s"> is a named list, the column names are copied from the names of the variables; the list must have <@itl="k"> members. If <@var="s"> is a string, it should contain <@itl="k"> space-separated sub-strings. The return value is 0 on successful completion, non-zero on error. See also <@ref="rownames">.
# cols matshape
Output: scalar
Argument: <@var="X"> (matrix)
The number of columns of <@var="X">. See also <@ref="mshape">, <@ref="rows">, <@ref="unvech">, <@ref="vec">, <@ref="vech">.
# corr stats
Output: scalar
Arguments: <@var="y1"> (series or vector)
<@var="y2"> (series or vector)
Computes the correlation coefficient between <@var="y1"> and <@var="y2">. The arguments should be either two series, or two vectors of the same length. See also <@ref="cov">, <@ref="mcov">, <@ref="mcorr">.
# corrgm stats
Output: matrix
Arguments: <@var="x"> (series, matrix or list)
<@var="p"> (scalar)
<@var="y"> (series or vector, optional)
If only the first two arguments are given, computes the correlogram for <@var="x"> for lags 1 to <@var="p">. Let <@itl="k"> represent the number of elements in <@var="x"> (1 if <@var="x"> is a series, the number of columns if <@var="x"> is a matrix, or the number of list-members is <@var="x"> is a list). The return value is a matrix with <@var="p"> rows and 2<@itl="k"> columns, the first <@itl="k"> columns holding the respective autocorrelations and the remainder the respective partial autocorrelations.
If a third argument is given, this function computes the cross-correlogram for each of the <@itl="k"> elements in <@var="x"> and <@var="y">, from lead <@var="p"> to lag <@var="p">. The returned matrix has 2<@itl="p"> + 1 rows and <@itl="k"> columns. If <@var="x"> is series or list and <@var="y"> is a vector, the vector must have just as many rows as there are observations in the current sample range.
# cos math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the cosine of <@var="x">.
# cosh math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the hyperbolic cosine of <@var="x">.
See also <@ref="acosh">, <@ref="sinh">, <@ref="tanh">.
# cov stats
Output: scalar
Arguments: <@var="y1"> (series or vector)
<@var="y2"> (series or vector)
Returns the covariance between <@var="y1"> and <@var="y2">. The arguments should be either two series, or two vectors of the same length. See also <@ref="corr">, <@ref="mcov">, <@ref="mcorr">.
# critical probdist
Output: same type as input
Arguments: <@var="c"> (character)
<@var="…"> (see below)
<@var="p"> (scalar, series or matrix)
Examples: <@lit="c1 = critical(t, 20, 0.025)">
<@lit="c2 = critical(F, 4, 48, 0.05)">
Critical value calculator. Returns <@itl="x"> such that <@itl="P(X > x) = p">, where the distribution <@itl="X"> is determined by the character <@var="c">. Between the arguments <@var="c"> and <@var="p">, zero or more additional scalar arguments are required to specify the parameters of the distribution, as follows.
<indent>
• Standard normal (c = z, n, or N): no extra arguments
</indent>
<indent>
• Student's t (t): degrees of freedom
</indent>
<indent>
• Chi square (c, x, or X): degrees of freedom
</indent>
<indent>
• Snedecor's F (f or F): df (num.); df (den.)
</indent>
<indent>
• Binomial (b or B): probability; trials
</indent>
<indent>
• Poisson (p or P): mean
</indent>
See also <@ref="cdf">, <@ref="invcdf">, <@ref="pvalue">.
# cum stats
Output: same type as input
Argument: <@var="x"> (series or matrix)
Cumulates <@var="x">. When <@var="x"> is a series, produces a series <@itl="y"> each of whose elements is the sum of the values of <@var="x"> to date; the starting point of the summation is the first non-missing observation in the currently selected sample. When <@var="x"> is a matrix, its elements are cumulated by columns.
See also <@ref="diff">.
# deseas filters
Output: series
Arguments: <@var="x"> (series)
<@var="c"> (character, optional)
Depends on having TRAMO/SEATS or X-12-ARIMA installed. Returns a deseasonalized (seasonally adjusted) version of the input series <@var="x">, which must be a quarterly or monthly time series. To use X-12-ARIMA give <@lit="X"> as the second argument; to use TRAMO give <@lit="T">. If the second argument is omitted then X-12-ARIMA is used.
Note that if the input series has no detectable seasonal component this function will fail. Also note that both TRAMO/SEATS and X-12-ARIMA offer numerous options; <@lit="deseas"> calls them with all options at their default settings. For both programs, the seasonal factors are calculated on the basis of an automatically selected ARIMA model. One difference between the programs which can sometimes make a substantial difference to the results is that by default TRAMO performs a prior adjustment for outliers while X-12-ARIMA does not.
# det linalg
Output: scalar
Argument: <@var="A"> (square matrix)
Returns the determinant of <@var="A">, computed via the LU factorization. See also <@ref="ldet">, <@ref="rcond">.
# diag matbuild
Output: matrix
Argument: <@var="X"> (matrix)
Returns the principal diagonal of <@var="X"> in a column vector. Note: if <@var="X"> is an <@itl="m">×<@itl="n"> marix, the number of elements of the output vector is min(<@itl="m">, <@itl="n">). See also <@ref="tr">.
# diagcat matbuild
Output: matrix
Arguments: <@var="A"> (matrix)
<@var="B"> (matrix)
Returns the direct sum of <@var="A"> and <@var="B">, that is a block-diagonal matrix holding <@var="A"> in its north-west corner and <@var="B"> in its south-east corner.
# diff transforms
Output: same type as input
Argument: <@var="y"> (series, matrix or list)
Computes first differences. If <@var="y"> is a series, or a list of series, starting values are set to <@lit="NA">. If <@var="y"> is a matrix, differencing is done by columns and starting values are set to 0.
When a list is returned, the individual variables are automatically named according to the template <@lit="d_"><@var="varname"> where <@var="varname"> is the name of the original series. The name is truncated if necessary, and may be adjusted in case of non-uniqueness in the set of names thus constructed.
See also <@ref="cum">, <@ref="ldiff">, <@ref="sdiff">.
# digamma math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the digamma (or Psi) function of <@var="x">, that is the derivative of the log of the Gamma function.
# dnorm probdist
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the density of the standard normal distribution at <@var="x">. To get the density for a non-standard normal distribution at <@itl="x">, pass the <@itl="z">-score of <@itl="x"> to the <@lit="dnorm"> function and multiply the result by the Jacobian of the <@itl="z"> transformation, namely 1 over σ, as illustrated below:
<code>
mu = 100
sigma = 5
x = 109
fx = (1/sigma) * dnorm((x-mu)/sigma)
</code>
See also <@ref="cnorm">, <@ref="qnorm">.
# dsort matshape
Output: same type as input
Argument: <@var="x"> (series or vector)
Sorts <@var="x"> in descending order, skipping observations with missing values when <@var="x"> is a series. See also <@ref="sort">, <@ref="values">.
# dummify transforms
Output: list
Arguments: <@var="x"> (series)
<@var="omitval"> (scalar, optional)
The argument <@var="x"> should be a discrete series. This function creates a set of dummy variables coding for the distinct values in the series. By default the smallest value is taken as the omitted category and is not explicitly represented.
The optional second argument represents the value of <@var="x"> which should be treated as the omitted category. The effect when a single argument is given is equivalent to <@lit="dummify(x, min(x))">. To produce a full set of dummies, with no omitted category, use <@lit="dummify(x, NA)">.
The generated variables are automatically named according to the template <@lit="D"><@var="varname"><@lit="_"><@var="i"> where <@var="varname"> is the name of the original series and <@var="i"> is a 1-based index. The original portion of the name is truncated if necessary, and may be adjusted in case of non-uniqueness in the set of names thus constructed.
# eigengen linalg
Output: matrix
Arguments: <@var="A"> (square matrix)
<@var="&U"> (reference to matrix, or <@lit="null">)
Computes the eigenvalues, and optionally the right eigenvectors, of the <@itl="n">×<@itl="n"> matrix <@var="A">. If all the eigenvalues are real, an <@itl="n">×<@itl="1"> matrix is returned; otherwise, the result is an <@itl="n">×<@itl="2"> matrix, the first column holding the real components and the second column the imaginary components.
The second argument must be either the name of an existing matrix preceded by <@lit="&"> (to indicate the "address" of the matrix in question), in which case an auxiliary result is written to that matrix, or the keyword <@lit="null">, in which case the auxiliary result is not produced.
If a non-null second argument is given, the specified matrix will be over-written with the auxiliary result. (It is not required that the existing matrix be of the right dimensions to receive the result.) It will be organized as follows:
<indent>
• If the <@itl="i">-th eigenvalue is real, the <@itl="i">-th column of <@itl="U"> will contain the corresponding eigenvector;
</indent>
<indent>
• If the <@itl="i">-th eigenvalue is complex, the <@itl="i">-th column of <@var="U"> will contain the real part of the corresponding eigenvector and the next column the imaginary part. The eigenvector for the conjugate eigenvalue is the conjugate of the eigenvector.
</indent>
In other words, the eigenvectors are stored in the same order as the eigenvalues, but the real eigenvectors occupy one column, whereas complex eigenvectors take two (the real part comes first); the total number of columns is still <@itl="n">, because the conjugate eigenvector is skipped.
See also <@ref="eigensym">, <@ref="qrdecomp">, <@ref="svd">.
# eigensym linalg
Output: matrix
Arguments: <@var="A"> (symmetric matrix)
<@var="&U"> (reference to matrix, or <@lit="null">)
Works just as <@ref="eigengen">, but the argument <@var="A"> must be symmetric (in which case the calculations can be reduced).
# eigsolve linalg
Output: matrix
Arguments: <@var="A"> (symmetric matrix)
<@var="B"> (symmetric matrix)
<@var="&U"> (reference to matrix, or <@lit="null">)
Solves the generalized eigenvalue problem |<@itl="A"> – λ<@itl="B">| = 0, where both <@itl="A"> and <@itl="B"> are symmetric and <@itl="B"> is positive definite. The eigenvalues are returned directly. If the optional third argument is given it should be the name of an existing matrix preceded by <@lit="&">; in that case the generalized eigenvectors are written to the named matrix.
# epochday data-utils
Output: scalar
Arguments: <@var="year"> (scalar)
<@var="month"> (scalar)
<@var="day"> (scalar)
Returns the number of the day in the current epoch specified by year, month and day (which equals 1 for the first of January in the year 1 AD).
# errmsg strings
Output: string
Argument: <@var="errno"> (scalar)
Retrieves the gretl error message associated with <@var="errno">. See also <@ref="$error">.
# exp math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns <@itl="e"><@sup="x">. Note that in case of matrices the function acts element by element. For the matrix exponential function, see <@ref="mexp">.
# fcstats stats
Output: matrix
Arguments: <@var="y"> (series or vector)
<@var="f"> (series or vector)
Produces a column vector holding several statistics which may be used for evaluating the series <@var="f"> as a forecast of the series <@var="y"> over the current sample range. Two vectors of the same length may be given in place of two series arguments.
The layout of the returned vector is as follows:
<code>
1 Mean Error (ME)
2 Mean Squared Error (MSE)
3 Mean Absolute Error (MAE)
4 Mean Percentage Error (MPE)
5 Mean Absolute Percentage Error (MAPE)
6 Theil's U
7 Bias proportion, UM
8 Regression proportion, UR
9 Disturbance proportion, UD
</code>
For details on the calculation of these statistics, and the interpretation of the <@itl="U"> values, please see <@pdf="the Gretl User's Guide">.
# fdjac numerical
Output: matrix
Arguments: <@var="b"> (column vector)
<@var="f"> (function call)
Calculates the (forward-difference approximation to the) Jacobian associated with the vector <@var="b"> and the transformation function specified by the argument <@var="f">. For more details and examples see the chapter on special functions in <@lit="genr"> in <@pdf="the Gretl User's Guide">.
See also <@ref="BFGSmax">.
# fft linalg
Output: matrix
Argument: <@var="X"> (matrix)
Discrete real Fourier transform. If the input matrix <@var="X"> has <@itl="n"> columns, the output has 2<@itl="n"> columns, where the real parts are stored in the odd columns and the complex parts in the even ones.
Should it be necessary to compute the Fourier transform on several vectors with the same number of elements, it is numerically more efficient to group them into a matrix rather than invoking <@lit="fft"> for each vector separately. See also <@ref="ffti">.
# ffti linalg
Output: matrix
Argument: <@var="X"> (matrix)
Inverse discrete real Fourier transform. It is assumed that <@var="X"> contains <@itl="n"> complex column vectors, with the real part in the odd columns and the imaginary part in the even ones, so the total number of columns should be 2<@itl="n">. A matrix with <@itl="n"> columns is returned.
Should it be necessary to compute the inverse Fourier transform on several vectors with the same number of elements, it is numerically more efficient to group them into a matrix rather than invoking <@lit="ffti"> for each vector separately. See also <@ref="fft">.
# filter filters
Output: series
Arguments: <@var="x"> (series)
<@var="a"> (scalar or vector, optional)
<@var="b"> (scalar or vector, optional)
<@var="y0"> (scalar, optional)
Computes an ARMA-like filtering of the series <@var="x">. The transformation can be written as
<@itl="y"><@sub="t"> = <@itl="a"><@sub="0"> <@itl="x"><@sub="t"> + <@itl="a"><@sub="1"> <@itl="x"><@sub="t-1"> + ... <@itl="a"><@sub="q"> <@itl="x"><@sub="t-q"> + <@itl="b"><@sub="1"> <@itl="y"><@sub="t-1"> + ... <@itl="b"><@sub="p"> <@itl="y"><@sub="t-p">
The two arguments <@var="a"> and <@var="b"> are optional. They may be scalars, vectors or the keyword <@lit="null">.
If <@var="a"> is a scalar, this is used as <@itl="a"><@sub="0"> and implies <@itl="q=0">; if it is a vector of <@itl="q+1"> elements, they contain the coefficients from <@itl="a"><@sub="0"> to <@itl="a"><@sub="q">. If <@var="a"> is <@lit="null"> or omitted, this is equivalent to setting <@itl="a"><@sub="0"><@itl="=1"> and <@itl="q=0">.
If <@var="b"> is a scalar, this is used as <@itl="b"><@sub="1"> and implies <@itl="p=1">; if it is a vector of <@itl="p"> elements, they contain the coefficients from <@itl="b"><@sub="1"> to <@itl="b"><@sub="p">. If <@var="b"> is <@lit="null"> or omitted, this is equivalent to setting <@itl="B(L)=1">.
The optional scalar argument <@var="y0"> is taken to represent all values of <@itl="y"> prior to the beginning of sample (used only when <@itl="p>0">). If omitted, it is understood to be 0. Pre-sample values of <@var="x"> are always assumed zero.
See also <@ref="bkfilt">, <@ref="fracdiff">, <@ref="hpfilt">, <@ref="movavg">.
Example:
<code>
nulldata 5
y = filter(index, 0.5, -0.9, 1)
print index y --byobs
</code>
produces
<code>
index y
1 1 -0.40000
2 2 1.36000
3 3 0.27600
4 4 1.75160
5 5 0.92356
</code>
# firstobs data-utils
Output: scalar
Argument: <@var="y"> (series)
First non-missing observation for the variable <@var="y">. Note that if some form of subsampling is in effect, the value returned may be smaller than the dollar variable <@ref="$t1">. See also <@ref="lastobs">.
# floor math
Output: same type as input
Argument: <@var="y"> (scalar, series or matrix)
Floor function: returns the greatest integer less than or equal to <@var="x">. Note: <@ref="int"> and <@lit="floor"> differ in their effect for negative arguments: <@lit="int(-3.5)"> gives –3, while <@lit="floor(-3.5)"> gives –4.
# fracdiff filters
Output: series
Arguments: <@var="y"> (series)
<@var="d"> (scalar)
Returns the fractional difference of order <@var="d"> for the series <@var="y">.
Note that in theory fractional differentiation is an infinitely long filter. In practice, presample values of <@itl="y"><@sub="t"> are assumed to be zero.
# gammafun math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the gamma function of <@var="x">.
# getenv strings
Output: string
Argument: <@var="s"> (string)
If an environment variable by the name of <@var="s"> is defined, returns the string value of that variable, otherwise returns an empty string. See also <@ref="ngetenv">.
# gini stats
Output: scalar
Argument: <@var="y"> (series)
Returns Gini's inequality index for the series <@var="y">.
# ginv linalg
Output: matrix
Argument: <@var="A"> (matrix)
Returns <@itl="A"><@sup="+">, the Moore–Penrose or generalized inverse of <@var="A">, computed via the singular value decomposition.
This matrix has the properties <@itl="A"> <@itl="A"><@sup="+"> <@itl="A"> = <@itl="A"> and <@itl="A"><@sup="+"> <@itl="A"> <@itl="A"><@sup="+"> = <@itl="A"><@sup="+"> . Moreover, the products <@itl="A"> <@itl="A"><@sup="+"> and <@itl="A"><@sup="+"> <@itl="A"> are symmetric by construction.
See also <@ref="inv">, <@ref="svd">.
# hdprod linalg
Output: matrix
Arguments: <@var="X"> (matrix)
<@var="Y"> (matrix)
Horizontal direct product. The two arguments must have the same number of rows, <@itl="r">. The return value is a matrix with <@itl="r"> rows, in which the <@itl="i">-th row is the Kronecker product of the corresponding rows of <@var="X"> and <@var="Y">.
As far as we know, there isn't an established name for this operation in matrix algebra. "Horizontal direct product" is the way this operation is called in the GAUSS programming language.
Example: the code
<code>
A = {1,2,3; 4,5,6}
B = {0,1; -1,1}
C = hdprod(A, B)
</code>
produces the following matrix:
<code>
0 1 0 2 0 3
-4 4 -5 5 -6 6
</code>
# hpfilt filters
Output: series
Arguments: <@var="y"> (series)
<@var="lambda"> (scalar, optional)
Returns the cycle component from application of the Hodrick–Prescott filter to series <@var="y">. If the smoothing parameter, <@var="lambda">, is not supplied then a data-based default is used, namely 100 times the square of the periodicity (100 for annual data, 1600 for quarterly data, and so on). See also <@ref="bkfilt">.
# I matbuild
Output: square matrix
Argument: <@var="n"> (scalar)
Returns an identity matrix with <@var="n"> rows and columns.
# imaxc stats
Output: row vector
Argument: <@var="X"> (matrix)
Returns the row indices of the maxima of the columns of <@var="X">.
See also <@ref="imaxr">, <@ref="iminc">, <@ref="maxc">.
# imaxr stats
Output: column vector
Argument: <@var="X"> (matrix)
Returns the column indices of the maxima of the rows of <@var="X">.
See also <@ref="imaxc">, <@ref="iminr">, <@ref="maxr">.
# imhof probdist
Output: scalar
Arguments: <@var="M"> (matrix)
<@var="x"> (scalar)
Computes Prob(<@itl="u'Au"> < <@itl="x">) for a quadratic form in standard normal variates, <@itl="u">, using the procedure developed by <@bib="Imhof (1961);imhof61">.
If the first argument, <@var="M">, is a square matrix it is taken to specify <@itl="A">, otherwise if it's a column vector it is taken to be the precomputed eigenvalues of <@itl="A">, otherwise an error is flagged.
See also <@ref="pvalue">.
# iminc stats
Output: row vector
Argument: <@var="X"> (matrix)
Returns the row indices of the minima of the columns of <@itl="X">.
See also <@ref="iminr">, <@ref="imaxc">, <@ref="minc">.
# iminr stats
Output: column vector
Argument: <@var="X"> (matrix)
Returns the column indices of the mimima of the rows of <@itl="X">.
See also <@ref="iminc">, <@ref="imaxr">, <@ref="minr">.
# inbundle data-utils
Output: scalar
Arguments: <@var="b"> (bundle)
<@var="key"> (string)
Returns 1 if bundle <@var="b"> contains a data-item with name <@var="key">, otherwise 0.
# infnorm linalg
Output: scalar
Argument: <@var="X"> (matrix)
Returns the infinity-norm of <@var="X">, that is, the maximum across the rows of <@var="X"> of the sum of absolute values of the row elements.
See also <@ref="onenorm">.
# inlist data-utils
Output: scalar
Arguments: <@var="L"> (list)
<@var="y"> (series)
Returns the (1-based) position of <@var="y"> in list <@var="L">, or 0 if <@var="y"> is not present in <@var="L">. The second argument may be given as the name of a series or alternatively as an integer ID number.
# int math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the integer part of <@var="x">, truncating the fractional part. Note: <@lit="int"> and <@ref="floor"> differ in their effect for negative arguments: <@lit="int(-3.5)"> gives –3, while <@lit="floor(-3.5)"> gives –4. See also <@ref="ceil">.
# inv linalg
Output: matrix
Argument: <@var="A"> (square matrix)
Returns the inverse of <@var="A">. If <@var="A"> is singular or not square, an error message is produced and nothing is returned. Note that gretl checks automatically the structure of <@var="A"> and uses the most efficient numerical procedure to perform the inversion.
The matrix types gretl checks for are: identity; diagonal; symmetric and positive definite; symmetric but not positive definite; and triangular.
See also <@ref="ginv">, <@ref="invpd">.
# invcdf probdist
Output: same type as input
Arguments: <@var="c"> (character)
<@var="…"> (see below)
<@var="p"> (scalar, series or matrix)
Inverse cumulative distribution function calculator. Returns <@itl="x"> such that <@itl="P(X ≤ x) = p">, where the distribution <@itl="X"> is determined by the character <@var="c">; Between the arguments <@var="c"> and <@var="p">, zero or more additional scalar arguments are required to specify the parameters of the distribution, as follows.
<indent>
• Standard normal (c = z, n, or N): no extra arguments
</indent>
<indent>
• Gamma (g or G): shape; scale
</indent>
<indent>
• Student's t (t): degrees of freedom
</indent>
<indent>
• Chi square (c, x, or X): degrees of freedom
</indent>
<indent>
• Snedecor's F (f or F): df (num.); df (den.)
</indent>
<indent>
• Binomial (b or B): probability; trials
</indent>
<indent>
• Poisson (p or P): mean
</indent>
<indent>
• Standardized GED (E): shape
</indent>
See also <@ref="cdf">, <@ref="critical">, <@ref="pvalue">.
# invmills probdist
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the inverse Mills ratio at <@var="x">, that is the ratio between the standard normal density and the complement to the standard normal distribution function, both evaluated at <@var="x">.
This function uses a dedicated algorithm which yields greater accuracy compared to calculation using <@ref="dnorm"> and <@ref="cnorm">, but the difference between the two methods is appreciable only for very large negative values of <@var="x">.
See also <@ref="cdf">, <@ref="cnorm">, <@ref="dnorm">.
# invpd linalg
Output: square matrix
Argument: <@var="A"> (symmetric matrix)
Returns the inverse of the symmetric, positive definite matrix <@var="A">. This function is slightly faster than <@ref="inv"> for large matrices, since no check for symmetry is performed; for that reason it should be used with care.
# irf stats
Output: matrix
Arguments: <@var="target"> (scalar)
<@var="shock"> (scalar)
<@var="alpha"> (scalar between 0 and 1, optional)
This function is available only when the last model estimated was a VAR. It returns a matrix containing the estimated response of the <@var="target"> variable to an impulse of one standard deviation in the <@var="shock"> variable. These variables are identified by their position in the VAR specification: for example, if <@var="target"> and <@var="shock"> are given as 1 and 3 respectively, the returned matrix gives the response of the first variable in the VAR for a shock to the third variable.
If the optional <@var="alpha"> argument is given, the returned matrix has three columns: the point estimate of the responses, followed by the lower and upper limits of a 1 – α confidence interval obtained via bootstrapping. (So <@var="alpha"> = 0.1 corresponds to 90 percent confidence.) If <@var="alpha"> is omitted or set to zero, only the point estimate is provided.
The number of periods (rows) over which the response is traced is determined automatically based on the frequency of the data, but this can be overridden via the <@xrf="set"> command, as in <@lit="set horizon 10">.
# irr math
Output: scalar
Argument: <@var="x"> (series or vector)
Returns the Internal Rate of Return for <@var="x">, considered as a sequence of payments (negative) and receipts (positive). See also <@ref="npv">.
# isconst data-utils
Output: scalar
Arguments: <@var="y"> (series or vector)
<@var="panel-code"> (scalar, optional)
Without the optional second argument, returns 1 if <@var="y"> has a constant value over the current sample range (or over its entire length if <@var="y"> is a vector), otherwise 0.
The second argument is accepted only if the current dataset is a panel and <@var="y"> is a series. In that case a <@var="panel-code"> value of 0 calls for a check for time-invariance, while a value of 1 means check for cross-sectional invariance (that is, in each time period the value of <@var="y"> is the same for all groups).
If <@var="y"> is a series, missing values are ignored in checking for constancy.
# islist data-utils
Output: scalar
Argument: <@var="s"> (string)
Returns 1 if <@var="s"> is the identifier for a currently defined list, otherwise 0. See also <@ref="isnull">, <@ref="isseries">, <@ref="isstring">.
# isnull data-utils
Output: scalar
Argument: <@var="s"> (string)
Returns 0 if <@var="s"> is the identifier for a currently defined object, be it a scalar, a series, a matrix, list or string; otherwise returns 1. See also <@ref="islist">, <@ref="isseries">, <@ref="isstring">.
# kdensity stats
Output: matrix
Arguments: <@var="x"> (series)
<@var="scale"> (scalar, optional)
<@var="control"> (scalar, optional)
Computes a kernel density estimate for the series <@var="x">. The returned matrix has two columns, the first holding a set of evenly spaced abscissae and the second the estimated density at each of these points.
The optional <@var="scale"> parameter can be used to adjust the degree of smoothing relative to the default of 1.0 (higher values produce a smoother result). The <@var="control"> parameter acts as a boolean: 0 (the default) means that the Gaussian kernel is used; a non-zero value switches to the Epanechnikov kernel.
A plot of the results may be obtained using the <@xrf="gnuplot"> command, as in
<code>
matrix d = kdensity(x)
gnuplot 2 1 --matrix=d --with-lines
</code>
# kfilter filters
Output: scalar
Arguments: <@var="&E"> (reference to matrix, or <@lit="null">)
<@var="&V"> (reference to matrix, or <@lit="null">)
<@var="&S"> (reference to matrix, or <@lit="null">)
<@var="&P"> (reference to matrix, or <@lit="null">)
<@var="&G"> (reference to matrix, or <@lit="null">)
Requires that a Kalman filter be set up. Performs a forward, filtering pass and returns 0 on successful completion or 1 if numerical problems are encountered.
The optional matrix arguments can be used to retrieve the following information: <@var="E"> gets the matrix of one-step ahead prediction errors and <@var="V"> gets the variance matrix for these errors; <@var="S"> gets the matrix of estimated values of the state vector and <@var="P"> the variance matrix of these estimates; <@var="G"> gets the Kalman gain. All of these matrices have <@itl="T"> rows, corresponding to <@itl="T"> observations. For the column dimensions and further details see <@pdf="the Gretl User's Guide">.
See also <@xrf="kalman">, <@ref="ksmooth">, <@ref="ksimul">.
# ksimul filters
Output: matrix
Arguments: <@var="v"> (matrix)
<@var="w"> (matrix)
<@var="&S"> (reference to matrix, or <@lit="null">)
Requires that a Kalman filter be set up. Performs a simulation and returns a matrix holding simulated values of the observable variables.
The argument <@var="v"> supplies artificial disturbances for the state transition equation and <@var="w"> supplies disturbances for the observation equation, if applicable. The optional argument <@var="S"> may be used to retrieve the simulated state vector. For details see <@pdf="the Gretl User's Guide">.
See also <@xrf="kalman">, <@ref="kfilter">, <@ref="ksmooth">.
# ksmooth filters
Output: matrix
Argument: <@var="&P"> (reference to matrix, or <@lit="null">)
Requires that a Kalman filter be set up. Performs a backward, smoothing pass and returns a matrix holding smoothed estimates of the state vector. The optional argument <@var="P"> may be used to retrieve the MSE of the smoothed state. For details see <@pdf="the Gretl User's Guide">.
See also <@xrf="kalman">, <@ref="kfilter">, <@ref="ksimul">.
# kurtosis stats
Output: scalar
Argument: <@var="x"> (series)
Returns the excess kurtosis of the series <@var="x">, skipping any missing observations.
# isseries data-utils
Output: scalar
Argument: <@var="s"> (string)
Returns 1 if <@var="s"> is the identifier for a currently defined series, otherwise 0. See also <@ref="islist">, <@ref="isnull">, <@ref="isstring">.
# isstring data-utils
Output: scalar
Argument: <@var="s"> (string)
Returns 1 if <@itl="s"> is the identifier for a currently defined string, otherwise 0. See also <@ref="islist">, <@ref="isnull">, <@ref="isseries">.
# lags transforms
Output: list
Arguments: <@var="p"> (scalar)
<@var="y"> (series or list)
Generates lags 1 to <@var="p"> of the series <@var="y">, or if <@var="y"> is a list, of all variables in the list. If <@var="p"> = 0, the maximum lag defaults to the periodicity of the data; otherwise <@var="p"> must be positive.
The generated variables are automatically named according to the template <@var="varname"><@lit="_"><@var="i"> where <@var="varname"> is the name of the original series and <@var="i"> is the specific lag. The original portion of the name is truncated if necessary, and may be adjusted in case of non-uniqueness in the set of names thus constructed.
# lastobs data-utils
Output: scalar
Argument: <@var="y"> (series)
Last non-missing observation for the variable <@var="y">. Note that if some form of subsampling is in effect, the value returned may be larger than the dollar variable <@ref="$t2">. See also <@ref="firstobs">.
# ldet linalg
Output: scalar
Argument: <@var="A"> (square matrix)
Returns the natural log of the determinant of <@itl="A">, computed via the LU factorization. See also <@ref="det">, <@ref="rcond">.
# ldiff transforms
Output: same type as input
Argument: <@var="y"> (series or list)
Computes log differences; starting values are set to <@lit="NA">.
When a list is returned, the individual variables are automatically named according to the template <@lit="ld_"><@var="varname"> where <@var="varname"> is the name of the original series. The name is truncated if necessary, and may be adjusted in case of non-uniqueness in the set of names thus constructed.
See also <@ref="diff">, <@ref="sdiff">.
# lincomb transforms
Output: series
Arguments: <@var="L"> (list)
<@var="b"> (vector)
Computes a new series as a linear combination of the series in the list <@var="L">. The coefficients are given by the vector <@var="b">, which must have length equal to the number of series in <@var="L">.
See also <@ref="wmean">.
# ljungbox stats
Output: scalar
Arguments: <@var="y"> (series)
<@var="p"> (scalar)
Computes the Ljung–Box Q' statistic for the series <@var="y"> using lag order <@var="p">. The currently defined sample range is used. The lag order must be greater than or equal to 1 and less than the number of available observations.
This statistic may be referred to the chi-square distribution with <@var="p"> degrees of freedom as a test of the null hypothesis that the series <@var="y"> is serially independent. See also <@ref="pvalue">.
# lngamma math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the log of the gamma function of <@var="x">.
# log math
Output: same type as input
Argument: <@var="x"> (scalar, series, matrix or list)
Returns the natural logarithm of <@var="x">; produces <@lit="NA"> for non-positive values. Note: <@lit="ln"> is an acceptable alias for <@lit="log">.
When a list is returned, the individual variables are automatically named according to the template <@lit="l_"><@var="varname"> where <@var="varname"> is the name of the original series. The name is truncated if necessary, and may be adjusted in case of non-uniqueness in the set of names thus constructed.
# log10 math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the base-10 logarithm of <@var="x">; produces <@lit="NA"> for non-positive values.
# log2 math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the base-2 logarithm of <@var="x">; produces <@lit="NA"> for non-positive values.
# logistic math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the logistic function of the argument <@var="x">, that is, <@itl="e"><@sup="x">/(1 + <@itl="e"><@sup="x">). If <@var="x"> is a matrix, the function is applied element by element.
# lower matbuild
Output: square matrix
Argument: <@var="A"> (matrix)
Returns an <@itl="n">×<@itl="n"> lower triangular matrix: the elements on and below the diagonal are equal to the corresponding elements of <@var="A">; the remaining elements are zero.
See also <@ref="upper">.
# lrvar filters
Output: scalar
Arguments: <@var="y"> (series or vector)
<@var="k"> (scalar)
Returns the long-run variance of <@var="y">, calculated using a Bartlett kernel with window size <@var="k">. If <@var="k"> is negative, <@lit="int(T^(1/3))"> is used.
# max stats
Output: scalar or series
Argument: <@var="y"> (series or list)
If the argument <@var="y"> is a series, returns the (scalar) maximum of the non-missing observations in the series. If the argument is a list, returns a series each of whose elements is the maximum of the values of the listed variables at the given observation.
See also <@ref="min">, <@ref="xmax">, <@ref="xmin">.
# maxc stats
Output: row vector
Argument: <@var="X"> (matrix)
Returns a row vector containing the maxima of the columns of <@var="X">.
See also <@ref="imaxc">, <@ref="maxr">, <@ref="minc">.
# maxr stats
Output: column vector
Argument: <@var="X"> (matrix)
Returns a column vector containing the maxima of the rows of <@var="X">.
See also <@ref="imaxc">, <@ref="maxc">, <@ref="minr">.
# mcorr stats
Output: matrix
Argument: <@var="X"> (matrix)
Computes a correlation matrix treating each column of <@var="X"> as a variable. See also <@ref="corr">, <@ref="cov">, <@ref="mcov">.
# mcov stats
Output: matrix
Argument: <@var="X"> (matrix)
Computes a covariance matrix treating each column of <@var="X"> as a variable. See also <@ref="corr">, <@ref="cov">, <@ref="mcorr">.
# mcovg stats
Output: matrix
Arguments: <@var="X"> (matrix)
<@var="u"> (vector, optional)
<@var="w"> (vector, optional)
<@var="p"> (scalar)
Returns the matrix covariogram for a <@itl="T">×<@itl="k"> matrix <@var="X"> (typically containing regressors), an (optional) <@itl="T">-vector <@var="u"> (typically containing residuals), an (optional) (<@itl="p">+1)-vector of weights <@var="w">, and a scalar lag order <@var="p">, which must be greater than or equal to 0.
The returned matrix is given by sum_{j=-p}^{p} sum_j w_{|j|} (X_t' u_t u_{t-j} X_{t-j})
If <@var="u"> is given as <@lit="null"> the <@itl="u"> terms are omitted, and if <@var="w"> is given as <@lit="null"> all the weights are taken to be 1.0.
# mean stats
Output: scalar or series
Argument: <@var="x"> (series or list)
If <@var="x"> is a series, returns the (scalar) sample mean, skipping any missing observations.
If <@var="x"> is a list, returns a series <@itl="y"> such that <@itl="y"><@sub="t"> is the mean of the values of the variables in the list at observation <@itl="t">, or <@lit="NA"> if there are any missing values at <@itl="t">.
# meanc stats
Output: row vector
Argument: <@var="X"> (matrix)
Returns the means of the columns of <@var="X">. See also <@ref="meanr">, <@ref="sumc">, <@ref="sdc">.
# meanr stats
Output: column vector
Argument: <@var="X"> (matrix)
Returns the means of the rows of <@var="X">. See also <@ref="meanc">, <@ref="sumr">.
# median stats
Output: scalar
Argument: <@var="y"> (series)
The median of the non-missing observations in series <@var="y">. See also <@ref="quantile">.
# mexp linalg
Output: square matrix
Argument: <@var="A"> (square matrix)
Computes the matrix exponential of <@var="A">, using algorithm 11.3.1 from <@bib="Golub and Van Loan (1996);golub96">.
# min stats
Output: scalar or series
Argument: <@var="y"> (series or list)
If the argument <@var="y"> is a series, returns the (scalar) minimum of the non-missing observations in the series. If the argument is a list, returns a series each of whose elements is the minimum of the values of the listed variables at the given observation.
See also <@ref="max">, <@ref="xmax">, <@ref="xmin">.
# minc stats
Output: row vector
Argument: <@var="X"> (matrix)
Returns the minima of the columns of <@var="X">.
See also <@ref="iminc">, <@ref="maxc">, <@ref="minr">.
# minr stats
Output: column vector
Argument: <@var="X"> (matrix)
Returns the minima of the rows of <@var="X">.
See also <@ref="iminr">, <@ref="maxr">, <@ref="minc">.
# missing data-utils
Output: same type as input
Argument: <@var="x"> (scalar, series or list)
Returns a binary variable holding 1 if <@var="x"> is <@lit="NA">. If <@var="x"> is a series, the comparison is done element by element; if <@var="x"> is a list of series, the output is a series with 1 at observations for which at least one series in the list has a missing value, and 0 otherwise.
See also <@ref="misszero">, <@ref="ok">, <@ref="zeromiss">.
# misszero data-utils
Output: same type as input
Argument: <@var="x"> (scalar or series)
Converts <@lit="NA">s to zeros. If <@var="x"> is a series, the conversion is done element by element. See also <@ref="missing">, <@ref="ok">, <@ref="zeromiss">.
# mlag stats
Output: matrix
Arguments: <@var="X"> (matrix)
<@var="p"> (scalar or vector)
<@var="m"> (scalar, optional)
Shifts up or down the rows of <@var="X">. If <@var="p"> is a positive scalar, returns a matrix in which the columns of <@var="X"> are shifted down by <@var="p"> rows and the first <@var="p"> rows are filled with the value <@var="m">. If <@var="p"> is a negative number, <@var="X"> is shifted up and the last rows are filled with the value <@var="m">. If <@var="m"> is omitted, it is understood to be zero.
If <@var="p"> is a vector, the above operation is carried out for each element in <@var="p">, joining the resulting matrices horizontally.
# mnormal matbuild
Output: matrix
Arguments: <@var="r"> (scalar)
<@var="c"> (scalar)
Returns a matrix with <@var="r"> rows and <@var="c"> columns, filled with standard normal pseudo-random variates. See also <@ref="normal">, <@ref="muniform">.
# mols stats
Output: matrix
Arguments: <@var="Y"> (matrix)
<@var="X"> (matrix)
<@var="&U"> (reference to matrix, or <@lit="null">)
<@var="&V"> (reference to matrix, or <@lit="null">)
Returns a <@itl="k">×<@itl="n"> matrix of parameter estimates obtained by OLS regression of the <@itl="T">×<@itl="n"> matrix <@var="Y"> on the <@itl="T">×<@itl="k"> matrix <@var="X">.
If the third argument is not <@lit="null">, the <@itl="T">×<@itl="n"> matrix <@var="U"> will contain the residuals. If the final argument is given and is not <@lit="null"> then the <@itl="k">×<@itl="k"> matrix <@var="V"> will contain (a) the covariance matrix of the parameter estimates, if <@var="Y"> has just one column, or (b) <@itl="X'X"><@sup="-1"> if <@var="Y"> has multiple columns.
By default, estimates are obtained via Cholesky decomposition, with a fallback to QR decomposition if the columns of <@var="X"> are highly collinear. The use of SVD can be forced via the command <@lit="set svd on">.
See also <@ref="mpols">, <@ref="mrls">.
# monthlen data-utils
Output: scalar
Arguments: <@var="month"> (scalar)
<@var="year"> (scalar)
<@var="weeklen"> (scalar)
Returns the number of (relevant) days in the specified month in the specified year; <@var="weeklen">, which must equal 5, 6 or 7, gives the number of days in the week that should be counted (a value of 6 omits Sundays, and a value of 5 omits both Saturdays and Sundays).
# movavg filters
Output: series
Arguments: <@var="x"> (series)
<@var="p"> (scalar)
<@var="control"> (scalar, optional)
Depending on the value of the parameter <@var="p">, returns either a simple or an exponentially weighted moving average of the input series <@var="x">.
If <@var="p"> > 1, a simple <@var="p">-term moving average is computed, that is, the arithmetic mean of x(t) to x(t-p+1). If a non-zero value is supplied for the optional <@var="control"> parameter the MA is centered, otherwise it is "trailing".
If <@var="p"> is a positive fraction, an exponential moving average is computed: y(t) = p*x(t) + (1-p)*y(t-1). By default the output series, y, is initialized using the first valid value of <@var="x">, but the <@var="control"> parameter may be used to specify the number of initial observations that should be averaged to produce y(0). A zero value for <@var="control"> indicates that all the observations should be used.
# mpols stats
Output: matrix
Arguments: <@var="Y"> (matrix)
<@var="X"> (matrix)
<@var="&U"> (reference to matrix, or <@lit="null">)
Works exactly as <@ref="mols">, except that the calculations are done in multiple precision using the GMP library (assuming this is available).
By default GMP uses 256 bits for each floating point number, but you can adjust this using the environment variable <@lit="GRETL_MP_BITS">, e.g. <@lit="GRETL_MP_BITS=1024">.
# mrandgen probdist
Output: matrix
Arguments: <@var="c"> (character)
<@var="a"> (scalar)
<@var="b"> (scalar)
Examples: <@lit="matrix mx = mrandgen(u, 0, 100, 50, 1)">
<@lit="matrix mt14 = mrandgen(t, 14, 20, 20)">
Works like <@ref="randgen"> except that the return value is a matrix rather than a series. The initial arguments to this function are as described for <@lit="randgen">, but they must be followed by two integers to specify the number of rows and columns of the desired random matrix.
The first example above calls for a uniform random column vector of length 50, while the second example specifies a 20×20 random matrix with drawings from the the <@itl="t"> distribution with 14 degrees of freedom.
See also <@ref="mnormal">, <@ref="muniform">.
# mread matbuild
Output: matrix
Argument: <@var="s"> (string)
Reads a matrix from a text file. The string <@var="s"> must contain the name of the (plain text) file from which the matrix is to be read. The file in question must conform to the following rules:
<indent>
• The columns must be separated by spaces or tab characters.
</indent>
<indent>
• The decimal separator must be the dot character, "<@lit=".">".
</indent>
<indent>
• The first line in the file must contain two integers, separated by a space or a tab, indicating the number of rows and columns, respectively.
</indent>
Should an error occur (such as the file being badly formatted or inaccessible), an empty matrix is returned.
See also <@ref="mwrite">.
# mreverse matshape
Output: matrix
Argument: <@var="X"> (matrix)
Returns a matrix containing the rows of <@var="X"> in reverse order. If you wish to obtain a matrix in which the columns of <@var="X"> appear in reverse order you can do:
<code>
matrix Y = mreverse(X')'
</code>
# mrls stats
Output: matrix
Arguments: <@var="Y"> (matrix)
<@var="X"> (matrix)
<@var="R"> (matrix)
<@var="q"> (column vector)
<@var="&U"> (reference to matrix, or <@lit="null">)
<@var="&V"> (reference to matrix, or <@lit="null">)
Restricted least squares: returns a <@itl="k">×<@itl="n"> matrix of parameter estimates obtained by least-squares regression of the <@itl="T">×<@itl="n"> matrix <@var="Y"> on the <@itl="T">×<@itl="k"> matrix <@var="X"> subject to the linear restriction <@itl="RB"> = <@itl="q">, where <@itl="B"> denotes the stacked coefficient vector. <@var="R"> must have <@itl="k"> * <@itl="n"> columns; each row of this matrix represents a linear restriction. The number of rows in <@var="q"> must match the number of rows in <@var="R">.
If the fifth argument is not <@lit="null">, the <@itl="T">×<@itl="n"> matrix <@var="U"> will contain the residuals. If the final argument is given and is not <@lit="null"> then the <@itl="k">×<@itl="k"> matrix <@var="V"> will hold the restricted counterpart to the matrix <@itl="X'X"><@sup="-1">. The variance matrix of the estimates for equation <@itl="i"> can be constructed by multiplying the appropriate sub-matrix of <@var="V"> by an estimate of the error variance for that equation.
# mshape matshape
Output: matrix
Arguments: <@var="X"> (matrix)
<@var="r"> (scalar)
<@var="c"> (scalar)
Rearranges the elements of <@var="X"> into a matrix with <@var="r"> rows and <@var="c"> columns. Elements are read from <@var="X"> and written to the target in column-major order. If <@var="X"> contains fewer than <@itl="k"> = <@itl="rc"> elements, the elements are repeated cyclically; otherwise, if <@var="X"> has more elements, only the first <@itl="k"> are used.
See also <@ref="cols">, <@ref="rows">, <@ref="unvech">, <@ref="vec">, <@ref="vech">.
# msortby matshape
Output: matrix
Arguments: <@var="X"> (matrix)
<@var="j"> (scalar)
Returns a matrix in which the rows of <@var="X"> are reordered by increasing value of the elements in column <@var="j">.
# muniform matbuild
Output: matrix
Arguments: <@var="r"> (scalar)
<@var="c"> (scalar)
Returns a matrix with <@var="r"> rows and <@var="c"> columns, filled with uniform (0,1) pseudo-random variates. Note: the preferred method for generating a scalar uniform r.v. is recasting the output of <@lit="muniform"> to a scalar, as in
<code>
scalar x = muniform(1,1)
</code>
See also <@ref="mnormal">, <@ref="uniform">.
# mwrite matbuild
Output: scalar
Arguments: <@var="X"> (matrix)
<@var="s"> (string)
Writes the matrix <@var="X"> to a plain text file named <@var="s">. The file will contain on the first line two integers, separated by a tab character, with the number of rows and columns; on the next lines, the matrix elements in scientific notation, separated by tabs (one line per row).
If file <@var="s"> already exists, it will be overwritten. The return value is 0 on successful completion; if an error occurs, such as the file being unwritable, the return value will be non-zero.
Matrices stored via the <@lit="mwrite"> command can be easily read by other programs; see <@pdf="the Gretl User's Guide"> for details.
See also <@ref="mread">.
# mxtab stats
Output: matrix
Arguments: <@var="x"> (series or vector)
<@var="y"> (series or vector)
Returns a matrix holding the cross tabulation of the values contained in <@var="x"> (by row) and <@var="y"> (by column). The two arguments should be of the same type (both series or both column vectors), and because of the typical usage of this function, are assumed to contain integer values only.
See also <@ref="values">.
# nelem data-utils
Output: scalar
Argument: <@var="L"> (list)
Returns the number of members in list <@var="L">.
# ngetenv strings
Output: scalar
Argument: <@var="s"> (string)
If an environment variable by the name of <@var="s"> is defined and has a numerical value, returns that value; otherwise returns NA. See also <@ref="getenv">.
# nobs stats
Output: scalar
Argument: <@var="y"> (series)
Returns the number of non-missing observations for the variable <@var="y"> in the currently selected sample.
# normal probdist
Output: series
Arguments: <@var="μ"> (scalar)
<@var="σ"> (scalar)
Generates a series of Gaussian pseudo-random variates with mean μ and standard deviation σ. If no arguments are supplied, standard normal variates <@itl="N">(0,1) are produced. The values are produced using the Ziggurat method <@bib="(Marsaglia and Tsang, 2000);marsaglia00">.
See also <@ref="randgen">, <@ref="mnormal">, <@ref="muniform">.
# npv math
Output: scalar
Arguments: <@var="x"> (series or vector)
<@var="r"> (scalar)
Returns the Net Present Value of <@var="x">, considered as a sequence of payments (negative) and receipts (positive), evaluated at annual discount rate <@var="r">. The first value is taken as dated "now" and is not discounted. To emulate an NPV function in which the first value is discounted, prepend zero to the input sequence.
Supported data frequencies are annual, quarterly, monthly, and undated (undated data are treated as if annual).
See also <@ref="irr">.
# NRmax numerical
Output: scalar
Arguments: <@var="b"> (vector)
<@var="f"> (function call)
<@var="g"> (function call, optional)
<@var="h"> (function call, optional)
Numerical maximization via the Newton–Raphson method. The vector <@var="b"> should hold the initial values of a set of parameters, and the argument <@var="f"> should specify a call to a function that calculates the (scalar) criterion to be maximized, given the current parameter values and any other relevant data. If the object is in fact minimization, this function should return the negative of the criterion. On successful completion, <@lit="NRmax"> returns the maximized value of the criterion, and <@var="b"> holds the parameter values which produce the maximum.
The optional third and fourth arguments provide means of supplying analytical derivatives and an analytical (negative) Hessian, respectively. The functions referenced by <@var="g"> and <@var="h"> must take as their first argument a pre-defined matrix that is of the correct size to contain the gradient or Hessian, respectively, given in pointer form. They also must take the parameter vector as an argument (in pointer form or otherwise). Other arguments are optional. If either or both of the optional arguments are omitted, a numerical approximation is used.
For more details and examples see the chapter on special functions in <@lit="genr"> in <@pdf="the Gretl User's Guide">. See also <@ref="BFGSmax">, <@ref="fdjac">.
# nullspace linalg
Output: matrix
Argument: <@var="A"> (matrix)
Computes the right nullspace of <@var="A">, via the singular value decomposition: the result is a matrix <@itl="B"> such that the product <@itl="AB"> is a zero matrix, except when <@var="A"> has full column rank, in which case an empty matrix is returned. Otherwise, if <@var="A"> is <@itl="m">×<@itl="n">, <@itl="B"> will be <@itl="n"> by (<@itl="n"> – <@itl="r">), where <@itl="r"> is the rank of <@var="A">.
See also <@ref="rank">, <@ref="svd">.
# obs data-utils
Output: series
Returns a series of consecutive integers, setting 1 at the start of the dataset. Note that the result is invariant to subsampling. This function is especially useful with time-series datasets. Note: you can write <@lit="t"> instead of <@lit="obs"> with the same effect.
See also <@ref="obsnum">.
# obslabel data-utils
Output: string
Argument: <@var="t"> (scalar)
Returns the observation label for observation <@var="t">, where <@var="t"> is a 1-based index. The inverse function is provided by <@ref="obsnum">.
# obsnum data-utils
Output: scalar
Argument: <@var="s"> (string)
Returns an integer corresponding to the observation specified by the string <@itl="s">. Note that the result is invariant to subsampling. This function is especially useful with time-series datasets. For example, the following code
<code>
open denmark
k = obsnum(1980:1)
</code>
yields <@lit="k = 25">, indicating that the first quarter of 1980 is the 25th observation in the <@lit="denmark"> dataset.
See also <@ref="obs">, <@ref="obslabel">.
# ok data-utils
Output: same type as input
Argument: <@var="x"> (scalar, series or list)
Returns a binary variable holding 1 if <@var="x"> is not <@lit="NA">. If <@var="x"> is a series, the comparison is done element by element. If <@var="x"> is a list of series, the output is a series with 0 at observations for which at least one series in the list has a missing value, and 1 otherwise.
See also <@ref="missing">, <@ref="misszero">, <@ref="zeromiss">.
# onenorm linalg
Output: scalar
Argument: <@var="X"> (matrix)
Returns the 1-norm of the matrix <@var="X">, that is, the maximum across the columns of <@var="X"> of the sum of absolute values of the column elements.
See also <@ref="infnorm">, <@ref="rcond">.
# ones matbuild
Output: matrix
Arguments: <@var="r"> (scalar)
<@var="c"> (scalar)
Outputs a matrix with <@itl="r"> rows and <@itl="c"> columns, filled with ones.
See also <@ref="seq">, <@ref="zeros">.
# orthdev transforms
Output: series
Argument: <@var="y"> (series)
Only applicable if the currently open dataset has a panel structure. Computes the forward orthogonal deviations for variable <@var="y">.
This transformation is sometimes used instead of differencing to remove individual effects from panel data. For compatibility with first differences, the deviations are stored one step ahead of their true temporal location (that is, the value at observation <@itl="t"> is the deviation that, strictly speaking, belongs at <@itl="t"> – 1). That way one loses the first observation in each time series, not the last.
See also <@ref="diff">.
# pdf probdist
Output: same type as input
Arguments: <@var="c"> (character)
<@var="…"> (see below)
<@var="x"> (scalar, series or matrix)
Examples: <@lit="f1 = pdf(N, -2.5)">
<@lit="f2 = pdf(X, 3, y)">
<@lit="f3 = pdf(W, shape, scale, y)">
Probability density function calculator. Returns the density at <@var="x"> of the distribution identified by the code <@var="c">. See <@ref="cdf"> for details of the required (scalar) arguments. The distributions supported by the <@lit="pdf"> function are the normal, Student's <@itl="t">, chi-square, <@itl="F">, Gamma, Weibull, Generalized Error, Binomial and Poisson. Note that for the Binomial and the Poisson what's calculated is in fact the probability mass at the specified point.
For the normal distribution, see also <@ref="dnorm">.
# pergm stats
Output: matrix
Arguments: <@var="x"> (series or vector)
<@var="bandwidth"> (scalar, optional)
If only the first argument is given, computes the sample periodogram for the given series or vector. If the second argument is given, computes an estimate of the spectrum of <@var="x"> using a Bartlett lag window of the given bandwidth, up to a maximum of half the number of observations (<@itl="T">/2).
Returns a matrix with two columns and <@itl="T">/2 rows: the first column holds the frequency, ω, from 2π/<@itl="T"> to π, and the second the corresponding spectral density.
# pmax stats
Output: series
Arguments: <@var="y"> (series)
<@var="mask"> (series, optional)
Only applicable if the currently open dataset has a panel structure. Returns the per-unit maximum for variable <@var="y">.
If the optional second argument is provided then observations for which the value of <@var="mask"> is zero are ignored.
See also <@ref="pmin">, <@ref="pmean">, <@ref="pnobs">, <@ref="psd">.
# pmean stats
Output: series
Arguments: <@var="y"> (series)
<@var="mask"> (series, optional)
Only applicable if the currently open dataset has a panel structure. Computes the per-unit mean for variable <@var="y">; that is, the sum of the valid observations for each unit divided by the number of valid observations for each unit.
If the optional second argument is provided then observations for which the value of <@var="mask"> is zero are ignored.
See also <@ref="pmax">, <@ref="pmin">, <@ref="pnobs">, <@ref="psd">, <@ref="pshrink">.
# pmin stats
Output: series
Arguments: <@var="y"> (series)
<@var="mask"> (series, optional)
Only applicable if the currently open dataset has a panel structure. Returns the per-unit mimimum for variable <@var="y">.
If the optional second argument is provided then observations for which the value of <@var="mask"> is zero are ignored.
See also <@ref="pmax">, <@ref="pmean">, <@ref="pnobs">, <@ref="psd">.
# pnobs stats
Output: series
Arguments: <@var="y"> (series)
<@var="mask"> (series, optional)
Only applicable if the currently open dataset has a panel structure. Returns for each unit the number of non-missing cases for the variable <@var="y">.
If the optional second argument is provided then observations for which the value of <@var="mask"> is zero are ignored.
See also <@ref="pmax">, <@ref="pmin">, <@ref="pmean">, <@ref="psd">.
# polroots linalg
Output: matrix
Argument: <@var="a"> (vector)
Finds the roots of a polynomial. If the polynomial is of degree <@itl="p">, the vector <@var="a"> should contain <@itl="p"> + 1 coefficients in ascending order, i.e. starting with the constant and ending with the coefficient on <@itl="x"><@sup="p">.
If all the roots are real they are returned in a column vector of length <@itl="p">, otherwise a <@itl="p">×<@itl="2"> matrix is returned, the real parts in the first column and the imaginary parts in the second.
# polyfit filters
Output: series
Arguments: <@var="y"> (series)
<@var="q"> (scalar)
Fits a polynomial trend of order <@var="q"> to the input series <@var="y"> using the method of orthogonal polynomials. The series returned holds the fitted values.
# princomp stats
Output: matrix
Arguments: <@var="X"> (matrix)
<@var="p"> (scalar)
Let the matrix <@var="X"> be <@itl="T">×<@itl="k">, containing <@itl="T"> observations on <@itl="k"> variables. The argument <@var="p"> must be a positive integer less than or equal to <@itl="k">. This function returns a <@itl="T">×<@itl="p"> matrix, <@itl="P">, holding the first <@itl="p"> principal components of <@var="X">.
The elements of <@itl="P"> are computed as the sum from <@itl="i"> to <@itl="k"> of <@itl="Z"><@sub="ti"> times <@itl="v"><@sub="ji">, where <@itl="Z"><@sub="ti"> is the standardized value of variable <@itl="i"> at observation <@itl="t"> and <@itl="v"><@sub="ji"> is the <@itl="j">th eigenvector of the correlation matrix of the <@itl="X"><@sub="i">s, with the eigenvectors ordered by decreasing value of the corresponding eigenvalues.
See also <@ref="eigensym">.
# psd stats
Output: series
Arguments: <@var="y"> (series)
<@var="mask"> (series, optional)
Only applicable if the currently open dataset has a panel structure. Computes the per-unit sample standard deviation for variable <@itl="y">. The denominator used is the sample size for each unit minus 1, unless the number of valid observations for the given unit is 1 (in which case 0 is returned) or 0 (in which case <@lit="NA"> is returned).
If the optional second argument is provided then observations for which the value of <@var="mask"> is zero are ignored.
Note: this function makes it possible to check whether a given variable (say, <@lit="X">) is time-invariant via the condition <@lit="max(psd(X)) = 0">.
See also <@ref="pmax">, <@ref="pmin">, <@ref="pmean">, <@ref="pnobs">.
# psdroot linalg
Output: square matrix
Argument: <@var="A"> (symmetric matrix)
Performs a generalized variant of the Cholesky decomposition of the matrix <@var="A">, which must be positive semidefinite (but which may be singular). If the input matrix is not square an error is flagged, but symmetry is assumed and not tested; only the lower triangle of <@var="A"> is read. The result is a lower-triangular matrix <@itl="L"> which satisfies <@itl="A = LL'">. Indeterminate elements in the solution are set to zero.
For the case where <@var="A"> is positive definite, see <@ref="cholesky">.
# pshrink data-utils
Output: matrix
Argument: <@var="y"> (series)
Only applicable if the currently open dataset has a panel structure. Returns a column vector holding the first valid observation for the series <@var="y"> for each unit or individual in the panel, over the current sample range. If a unit has no valid observations for the input series it is skipped. This function provides a means of compacting the information provided by functions such as <@ref="pmean">.
# pvalue probdist
Output: same type as input
Arguments: <@var="c"> (character)
<@var="…"> (see below)
<@var="x"> (scalar, series or matrix)
Examples: <@lit="p1 = pvalue(z, 2.2)">
<@lit="p2 = pvalue(X, 3, 5.67)">
<@lit="p2 = pvalue(F, 3, 30, 5.67)">
<@itl="P">-value calculator. Returns <@itl="P(X > x)">, where the distribution <@itl="X"> is determined by the character <@var="c">. Between the arguments <@var="c"> and <@var="x">, zero or more additional arguments are required to specify the parameters of the distribution; see <@ref="cdf"> for details. The distributions supported by the <@lit="pval"> function are the standard normal, <@itl="t">, Chi square, <@itl="F">, gamma, binomial, Poisson, Weibull and Generalized Error.
See also <@ref="critical">, <@ref="invcdf">, <@ref="urcpval">, <@ref="imhof">.
# qform linalg
Output: matrix
Arguments: <@var="x"> (matrix)
<@var="A"> (symmetric matrix)
Computes the quadratic form <@itl="Y = xAx'">. Using this function instead of ordinary matrix multiplication guarantees more speed and better accuracy. If <@var="x"> and <@var="A"> are not conformable, or <@var="A"> is not symmetric, an error is returned.
# qnorm probdist
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns quantiles for the standard normal distribution. If <@var="x"> is not between 0 and 1, <@lit="NA"> is returned. See also <@ref="cnorm">, <@ref="dnorm">.
# qrdecomp linalg
Output: matrix
Arguments: <@var="X"> (matrix)
<@var="&R"> (reference to matrix, or <@lit="null">)
Computes the QR decomposition of an <@itl="m">×<@itl="n"> matrix <@var="X">, that is <@itl="X = QR"> where <@itl="Q"> is an <@itl="m">×<@itl="n"> orthogonal matrix and <@itl="R"> is an <@itl="n">×<@itl="n"> upper triangular matrix. The matrix <@itl="Q"> is returned directly, while <@itl="R"> can be retrieved via the optional second argument.
See also <@ref="eigengen">, <@ref="eigensym">, <@ref="svd">.
# quantile stats
Output: scalar or matrix
Arguments: <@var="y"> (series or matrix)
<@var="p"> (scalar between 0 and 1)
If <@var="y"> is a series, returns the <@var="p">-quantile for the series. For example, when <@itl="p"> = 0.5, the median is returned.
If <@var="y"> is a matrix, returns a row vector containing the <@var="p">-quantiles for the columns of <@var="y">; that is, each column is treated as a series.
In addition, for matrix <@var="y"> an alternate form of the second argument is supported: <@var="p"> may be given as a vector. In that case the return value is an <@itl="m">×<@itl="n"> matrix, where <@var="m"> is the number of elements in <@var="p"> and <@var="n"> is the number of columns in <@var="y">.
# randgen probdist
Output: series
Arguments: <@var="c"> (character)
<@var="a"> (scalar or series)
<@var="b"> (scalar or series)
Examples: <@lit="series x = randgen(u, 0, 100)">
<@lit="series t14 = randgen(t, 14)">
<@lit="series y = randgen(B, 0.6, 30)">
<@lit="series g = randgen(G, 1, 1)">
<@lit="series P = randgen(P, mu)">
All-purpose random number generator. The parameter <@var="c"> is a character, which specifies from which distribution the pseudo-random numbers should be drawn. The arguments <@var="a"> and (in some cases) <@var="b"> provide the parameters of the selected distribution. If these are given as scalars the output series is identically distributed; if a series is given for <@var="a"> or <@var="b"> the distribution is conditional on the parameter value at each observation.
Specifics are given below: the character codes for each distribution are shown in parentheses, followed by the interpretation of the argument <@var="a"> and, where applicable, <@var="b">.
<indent>
• Uniform (continuous) (c = u or U): minimum; maximum
</indent>
<indent>
• Uniform (discrete) (c = i): minimum; maximum
</indent>
<indent>
• Standard normal (c = z, n, or N): mean; standard deviation
</indent>
<indent>
• Student's t (t): degrees of freedom
</indent>
<indent>
• Chi square (c, x, or X): degrees of freedom
</indent>
<indent>
• Snedecor's F (f or F): df (num.); df (den.)
</indent>
<indent>
• Gamma (g or G): shape; scale
</indent>
<indent>
• Binomial (b or B): probability; number of trials
</indent>
<indent>
• Poisson (p or P): Mean
</indent>
<indent>
• Weibull (w or W): shape; scale
</indent>
<indent>
• Generalized Error (E): shape
</indent>
See also <@ref="normal">, <@ref="uniform">, <@ref="mrandgen">.
# randint probdist
Output: scalar
Arguments: <@var="min"> (scalar)
<@var="max"> (scalar)
Returns a pseudo-random integer in the closed interval [<@var="min">, <@var="max">]. See also <@ref="randgen">.
# rank linalg
Output: scalar
Argument: <@var="X"> (matrix)
Returns the rank of <@var="X">, numerically computed via the singular value decomposition. See also <@ref="svd">.
# ranking stats
Output: same type as input
Argument: <@var="y"> (series or vector)
Returns a series or vector with the ranks of <@itl="y">. The rank for observation <@itl="i"> is the number of elements that are less than <@itl="y"><@sub="i"> plus one half the number of elements that are equal to <@itl="y"><@sub="i">. (Intuitively, you may think of chess points, where victory gives you one point and a draw gives you half a point.) One is added so the lowest rank is 1 instead of 0.
See also <@ref="sort">, <@ref="sortby">.
# rcond linalg
Output: scalar
Argument: <@var="A"> (square matrix)
Returns the reciprocal condition number for <@var="A"> with respect to the 1-norm. In many circumstances, this is a better measure of the sensitivity of <@var="A"> to numerical operations such as inversion than the determinant.
The value is computed as the reciprocal of the product, 1-norm of <@var="A"> times 1-norm of <@var="A">-inverse.
See also <@ref="det">, <@ref="ldet">, <@ref="onenorm">.
# readfile strings
Output: string
Argument: <@var="fname"> (string)
If a file by the name of <@var="fname"> exists and is readable, returns a string containing the content of this file, otherwise flags an error.
Also see the <@ref="sscanf"> function.
# replace data-utils
Output: same type as input
Arguments: <@var="x"> (series or matrix)
<@var="find"> (scalar or vector)
<@var="subst"> (scalar or vector)
Replaces each element of <@var="x"> equal to the <@itl="i">-th element of <@var="find"> with the corresponding element of <@var="subst">.
If <@var="find"> is a scalar, <@var="subst"> must also be a scalar. If <@var="find"> and <@var="subst"> are both vectors, they must have the same number of elements. But if <@var="find"> is a vector and <@var="subst"> a scalar, then all matches will be replaced by <@var="subst">.
Example:
<code>
a = {1,2,3;3,4,5}
find = {1,3,4}
subst = {-1,-8, 0}
b = replace(a, find, subst)
print a b
</code>
produces
<code>
a (2 x 3)
1 2 3
3 4 5
b (2 x 3)
-1 2 -8
-8 0 5
</code>
# resample stats
Output: same type as input
Arguments: <@var="x"> (series or matrix)
<@var="b"> (scalar, optional)
Resamples from <@var="x"> with replacement. In the case of a series argument, each value of the returned series, <@itl="y"><@sub="t">, is drawn from among all the values of <@itl="x"><@sub="t"> with equal probability. When a matrix argument is given, each row of the returned matrix is drawn from the rows of <@var="x"> with equal probability.
The optional argument <@var="b"> represents the block length for resampling by moving blocks. If this argument is given it should be a positive integer greater than or equal to 2. The effect is that the output is composed by random selection with replacement from among all the possible contiguous sequences of length <@var="b"> in the input. (In the case of matrix input, this means contiguous rows.) If the length of the data is not an integer multiple of the block length, the last selected block is truncated to fit.
# round math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Rounds to the nearest integer. Note that when <@itl="x"> lies halfway between two integers, rounding is done "away from zero", so for example 2.5 rounds to 3, but <@lit="round(-3.5)"> gives –4. This is a common convention in spreadsheet programs, but other software may yield different results. See also <@ref="ceil">, <@ref="floor">, <@ref="int">.
# rownames matbuild
Output: scalar
Arguments: <@var="M"> (matrix)
<@var="s"> (named list or string)
Attaches names to the rows of the <@itl="m">×<@itl="n"> matrix <@var="M">. If <@var="s"> is a named list, the row names are copied from the names of the variables; the list must have <@itl="m"> members. If <@var="s"> is a string, it should contain <@itl="m"> space-separated sub-strings. The return value is 0 on successful completion, non-zero on error. See also <@ref="colnames">.
# rows matshape
Output: scalar
Argument: <@var="X"> (matrix)
Number of rows of the matrix <@var="X">. See also <@ref="cols">, <@ref="mshape">, <@ref="unvech">, <@ref="vec">, <@ref="vech">.
# sd stats
Output: scalar or series
Argument: <@var="x"> (series or list)
If <@var="x"> is a series, returns the (scalar) sample standard deviation, skipping any missing observations.
If <@var="x"> is a list, returns a series <@itl="y"> such that <@itl="y"><@sub="t"> is the sample standard deviation of the values of the variables in the list at observation <@itl="t">, or <@lit="NA"> if there are any missing values at <@itl="t">.
See also <@ref="var">.
# sdc stats
Output: row vector
Arguments: <@var="X"> (matrix)
<@var="df"> (scalar, optional)
Returns the standard deviations of the columns of <@var="X">. If <@var="df"> is positive it is used as the divisor for the column variances, otherwise the divisor is the number of rows in <@var="X"> (that is, no degrees of freedom correction is applied). See also <@ref="meanc">, <@ref="sumc">.
# sdiff transforms
Output: same type as input
Argument: <@var="y"> (series or list)
Computes seasonal differences: <@itl="y(t) - y(t-k)">, where <@itl="k"> is the periodicity of the current dataset (see <@ref="$pd">). Starting values are set to <@lit="NA">.
When a list is returned, the individual variables are automatically named according to the template <@lit="sd_"><@var="varname"> where <@var="varname"> is the name of the original series. The name is truncated if necessary, and may be adjusted in case of non-uniqueness in the set of names thus constructed.
See also <@ref="diff">, <@ref="ldiff">.
# selifc matshape
Output: matrix
Arguments: <@var="A"> (matrix)
<@var="b"> (row vector)
Selects from <@var="A"> only the columns for which the corresponding element of <@var="b"> is non-zero. <@var="b"> must be a row vector with the same number of columns as <@var="A">.
See also <@ref="selifr">.
# selifr matshape
Output: matrix
Arguments: <@var="A"> (matrix)
<@var="b"> (column vector)
Selects from <@var="A"> only the rows for which the corresponding element of <@var="b"> is non-zero. <@var="b"> must be a column vector with the same number of rows as <@var="A">.
See also <@ref="selifc">, <@ref="trimr">.
# seq matbuild
Output: row vector
Arguments: <@var="a"> (scalar)
<@var="b"> (scalar)
<@var="k"> (scalar, optional)
Given only two arguments, returns a row vector filled with consecutive integers, with <@var="a"> as first element and <@var="b"> last. If <@var="a"> is greater than <@var="b"> the sequence will be decreasing. If either argument is not integral its fractional part is discarded.
If the third argument is given, returns a row vector containing a sequence of integers starting with <@var="a"> and incremented (or decremented, if <@var="a"> is greater than <@var="b">) by <@var="k"> at each step. The final value is the largest member of the sequence that is less than or equal to <@var="b"> (or mutatis mutandis for <@var="a"> greater than <@var="b">). The argument <@var="k"> must be positive; if it is not integral its fractional part is discarded.
See also <@ref="ones">, <@ref="zeros">.
# sin math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the sine of <@var="x">. See also <@ref="cos">, <@ref="tan">, <@ref="atan">.
# sinh math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the hyperbolic sine of <@var="x">.
See also <@ref="asinh">, <@ref="cosh">, <@ref="tanh">.
# skewness stats
Output: scalar
Argument: <@var="x"> (series)
Returns the skewness value for the series <@var="x">, skipping any missing observations.
# sort matshape
Output: same type as input
Argument: <@var="x"> (series or vector)
Sorts <@var="x"> in ascending order, skipping observations with missing values when <@itl="x"> is a series. See also <@ref="dsort">, <@ref="values">. For matrices specifically, see <@ref="msortby">.
# sortby stats
Output: series
Arguments: <@var="y1"> (series)
<@var="y2"> (series)
Returns a series containing the elements of <@var="y2"> sorted by increasing value of the first argument, <@var="y1">. See also <@ref="sort">, <@ref="ranking">.
# sqrt math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the positive square root of <@var="x">; produces <@lit="NA"> for negative values.
Note that if the argument is a matrix the operation is performed element by element and, since matrices cannot contain <@lit="NA">, negative values generate an error. For the "matrix square root" see <@ref="cholesky">.
# sscanf strings
Output: scalar
Arguments: <@var="src"> (string)
<@var="format"> (string)
... (see below)
Reads values from <@var="src"> under the control of <@var="format"> and assigns these values to one or more trailing arguments, indicated by the dots above. Returns the number of values assigned. This is a simplifed version of the <@lit="sscanf"> function in the C programming language.
<@var="src"> may be either a literal string, enclosed in double quotes, or the name of a predefined string variable. <@var="format"> is defined similarly to the format string in <@xrf="printf"> (more on this below). <@var="args"> should be a comma-separated list containing the names of pre-defined variables: these are the targets of conversion from <@var="src">. (For those used to C: one can prefix the names of numerical variables with <@lit="&"> but this is not required.)
Literal text in <@var="format"> is matched against <@var="src">. Conversion specifiers start with <@lit="%">, and recognized conversions include <@lit="%f">, <@lit="%g"> or <@lit="%lf"> for floating-point numbers; <@lit="%d"> for integers; <@lit="%s"> for strings; and <@lit="%m"> for matrices. You may insert a positive integer after the percent sign: this sets the maximum number of characters to read for the given conversion (or the maximum number of rows in the case of matrix conversion). Alternatively, you can insert a literal <@lit="*"> after the percent to suppress the conversion (thereby skipping any characters that would otherwise have been converted for the given type). For example, <@lit="%3d"> converts the next 3 characters in <@var="source"> to an integer, if possible; <@lit="%*g"> skips as many characters in <@var="source"> as could be converted to a single floating-point number.
Matrix conversion works thus: the scanner reads a line of input and counts the (space- or tab-separated) number of numeric fields. This defines the number of columns in the matrix. By default, reading then proceeds for as many lines (rows) as contain the same number of numeric columns, but the maximum number of rows to read can be limited as described above.
In addition to <@lit="%s"> conversion for strings, a simplified version of the C format <@lit="%"><@var="N"><@lit="["><@var="chars"><@lit="]"> is available. In this format <@var="N"> is the maximum number of characters to read and <@var="chars"> is a set of acceptable characters, enclosed in square brackets: reading stops if <@var="N"> is reached or if a character not in <@var="chars"> is encountered. The function of <@var="chars"> can be reversed by giving a circumflex, <@lit="^">, as the first character; in that case reading stops if a character in the given set is found. (Unlike C, the hyphen does not play a special role in the <@var="chars"> set.)
If the source string does not (fully) match the format, the number of conversions may fall short of the number of arguments given. This is not in itself an error so far as gretl is concerned. However, you may wish to check the number of conversions performed; this is given by the return value.
Some examples follow:
<code>
scalar x
scalar y
sscanf("123456", "%3d%3d", x, y)
sprintf S, "1 2 3 4\n5 6 7 8"
S
matrix m
sscanf(S, "%m", m)
print m
</code>
# sst stats
Output: scalar
Argument: <@var="y"> (series)
Returns the sum of squared deviations from the mean for the non-missing observations in series <@var="y">. See also <@ref="var">.
# strlen strings
Output: scalar
Argument: <@var="s"> (string)
Returns the number of characters in <@var="s">.
# strncmp strings
Output: scalar
Arguments: <@var="s1"> (string)
<@var="s2"> (string)
<@var="n"> (scalar, optional)
Compares the two string arguments and returns an integer less than, equal to, or greater than zero if <@var="s1"> is found, respectively, to be less than, to match, or be greater than <@var="s2">, up to the first <@var="n"> characters. If <@var="n"> is omitted the comparison proceeds as far as possible.
Note that if you just want to compare two strings for equality, that can be done without using a function, as in <@lit="if (s1 == s2) ...">
# strsplit strings
Output: string
Arguments: <@var="s"> (string)
<@var="i"> (scalar)
Returns space-separated element <@var="i"> from the string <@var="s">. The index <@var="i"> is 1-based, and it is an error if <@var="i"> is less than 1. In case <@var="s"> contains no spaces and <@var="i"> equals 1, a copy of the entire input string is returned; otherwise, in case <@var="i"> exceeds the number of space-separated elements an empty string is returned.
# strstr strings
Output: string
Arguments: <@var="s1"> (string)
<@var="s2"> (string)
Searches <@var="s1"> for an occurrence of the string <@var="s2">. If a match is found, returns a copy of the portion of <@var="s1"> that starts with <@var="s2">, otherwise returns an empty string.
# strsub strings
Output: string
Arguments: <@var="s"> (string)
<@var="find"> (string)
<@var="subst"> (string)
Returns a copy of <@var="s"> in which all occurrences of <@var="find"> are replaced by <@var="subst">.
# sum stats
Output: scalar or series
Argument: <@var="x"> (series or list)
If <@var="x"> is a series, returns the (scalar) sum of the non-missing observations in <@var="x">.
If <@var="x"> is a list, returns a series <@itl="y"> such that <@itl="y"><@sub="t"> is the sum of the values of the variables in the list at observation <@itl="t">, or <@lit="NA"> if there are any missing values at <@itl="t">.
# sumc stats
Output: row vector
Argument: <@var="X"> (matrix)
Returns the sums of the columns of <@var="X">. See also <@ref="meanc">, <@ref="sumr">.
# sumr stats
Output: column vector
Argument: <@var="X"> (matrix)
Returns the sums of the rows of <@var="X">. See also <@ref="meanr">, <@ref="sumc">.
# svd linalg
Output: row vector
Arguments: <@var="X"> (matrix)
<@var="&U"> (reference to matrix, or <@lit="null">)
<@var="&V"> (reference to matrix, or <@lit="null">)
Performs the singular values decomposition of the matrix <@var="X">.
The singular values are returned in a row vector. The left and/or right singular vectors <@itl="U"> and <@itl="V"> may be obtained by supplying non-null values for arguments 2 and 3, respectively. For any matrix <@lit="A">, the code
<code>
s = svd(A, &U, &V)
B = (U .* s) * V
</code>
should yield <@lit="B"> identical to <@lit="A"> (apart from machine precision).
See also <@ref="eigengen">, <@ref="eigensym">, <@ref="qrdecomp">.
# tan math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the tangent of <@var="x">.
# tanh math
Output: same type as input
Argument: <@var="x"> (scalar, series or matrix)
Returns the hyperbolic tangent of <@var="x">.
See also <@ref="atanh">, <@ref="cosh">, <@ref="sinh">.
# toepsolv linalg
Output: column vector
Arguments: <@var="c"> (vector)
<@var="r"> (vector)
<@var="b"> (vector)
Solves a Toeplitz system of linear equations, that is <@itl="Tx = b"> where <@itl="T"> is a square matrix whose element <@itl="T"><@sub="i,j"> equals <@itl="c"><@sub="i-j"> for <@itl="i>=j"> and <@itl="r"><@sub="j-i"> for <@itl="i<=j">. Note that the first elements of <@itl="c"> and <@itl="r"> must be equal, otherwise an error is returned. Upon successful completion, the function returns the vector <@itl="x">.
The algorithm used here takes advantage of the special structure of the matrix <@itl="T">, which makes it much more efficient than other unspecialized algorithms, especially for large problems. Warning: in certain cases, the function may spuriously issue a singularity error when in fact the matrix <@itl="T"> is nonsingular; this problem, however, cannot arise when <@itl="T"> is positive definite.
# tolower strings
Output: string
Argument: <@var="s"> (string)
Returns a copy of <@var="s"> in which any upper-case characters are converted to lower case.
# tr linalg
Output: scalar
Argument: <@var="A"> (square matrix)
Returns the trace of the square matrix <@var="A">, that is, the sum of its diagonal elements. See also <@ref="diag">.
# transp linalg
Output: matrix
Argument: <@var="X"> (matrix)
Returns the transpose of <@var="X">. Note: this is rarely used; in order to get the transpose of a matrix, in most cases you can just use the prime operator: <@lit="X'">.
# trimr matshape
Output: matrix
Arguments: <@var="X"> (matrix)
<@var="ttop"> (scalar)
<@var="tbot"> (scalar)
Returns a matrix that is a copy of <@var="X"> with <@var="ttop"> rows trimmed at the top and <@var="tbot"> rows trimmed at the bottom. The latter two arguments must be non-negative, and must sum to less than the total rows of <@var="X">.
See also <@ref="selifr">.
# uniform probdist
Output: series
Arguments: <@var="a"> (scalar)
<@var="b"> (scalar)
Generates a series of uniform pseudo-random variates in the interval (<@var="a">, <@var="b">), or, if no arguments are supplied, in the interval (0,1). The algorithm used by default is the SIMD-oriented Fast Mersenne Twister developed by <@bib="Saito and Matsumoto (2008);saito_matsumoto08">.
See also <@ref="randgen">, <@ref="normal">, <@ref="mnormal">, <@ref="muniform">.
# uniq stats
Output: column vector
Argument: <@var="x"> (series or vector)
Returns a vector containing the distinct elements of <@var="x">, not sorted but in their order of appearance. See <@ref="values"> for a variant that sorts the elements.
# unvech matbuild
Output: square matrix
Argument: <@var="v"> (vector)
Returns an <@itl="n">×<@itl="n"> symmetric matrix obtained by rearranging the elements of <@itl="v">. The number of elements in <@itl="v"> must be a triangular integer — i.e., a number <@itl="k"> such that an integer <@itl="n"> exists with the property <@itl="k = n(n+1)/2">. This is the inverse of the function <@ref="vech">.
See also <@ref="mshape">, <@ref="vech">.
# upper matbuild
Output: square matrix
Argument: <@var="A"> (square matrix)
Returns an <@itl="n">×<@itl="n"> upper triangular matrix: the elements on and above the diagonal are equal to the corresponding elements of <@var="A">; the remaining elements are zero.
See also <@ref="lower">.
# urcpval probdist
Output: scalar
Arguments: <@var="tau"> (scalar)
<@var="n"> (scalar)
<@var="niv"> (scalar)
<@var="itv"> (scalar)
<@itl="P">-values for the test statistic from the Dickey–Fuller unit-root test and the Engle–Granger cointegration test, as per <@bib="James MacKinnon (1996);mackinnon96">.
The arguments are as follows: <@var="tau"> denotes the test statistic; <@var="n"> is the number of observations (or 0 for an asymptotic result); <@var="niv"> is the number of potentially cointegrated variables when testing for cointegration (or 1 for a univariate unit-root test); and <@var="itv"> is a code for the model specification: 1 for no constant, 2 for constant included, 3 for constant and linear trend, 4 for constant and quadratic trend.
Note that if the test regression is "augmented" with lags of the dependent variable, then you should give an <@var="n"> value of 0 to get an asymptotic result.
See also <@ref="pvalue">.
# values stats
Output: column vector
Argument: <@var="x"> (series or vector)
Returns a vector containing the distinct elements of <@var="x"> sorted in ascending order. If you wish to truncate the values to integers before applying this function, use the expression <@lit="values(int(x))">.
See also <@ref="uniq">, <@ref="dsort">, <@ref="sort">.
# var stats
Output: scalar or series
Argument: <@var="x"> (series or list)
If <@var="x"> is a series, returns the (scalar) sample variance, skipping any missing observations.
If <@var="x"> is a list, returns a series <@itl="y"> such that <@itl="y"><@sub="t"> is the sample variance of the values of the variables in the list at observation <@itl="t">, or <@lit="NA"> if there are any missing values at <@itl="t">.
In each case the sum of squared deviations from the mean is divided by (<@itl="n"> – 1) for <@itl="n"> > 1. Otherwise the variance is given as zero if <@itl="n"> = 1, or as <@lit="NA"> if <@itl="n"> = 0.
See also <@ref="sd">.
# varname strings
Output: string
Argument: <@var="v"> (scalar or list)
If given a scalar argument, returns the name of the variable with ID number <@var="v">, or generates an error if there is no such variable.
If given a list argument, returns a string containing the names of the variables in the list, separated by commas. If the supplied list is empty, so is the returned string.
# varnum data-utils
Output: scalar
Argument: <@var="varname"> (string)
Returns the ID number of the variable called <@var="varname">, or NA is there is no such variable.
# varsimul linalg
Output: matrix
Arguments: <@var="A"> (matrix)
<@var="U"> (matrix)
<@var="y0"> (matrix)
Simulates a <@itl="p">-order <@itl="n">-variable VAR, that is <@itl="y(t) = A1 y(t-1) + ... + Ap y(t-p) + u(t)."> The coefficient matrix <@var="A"> is composed by horizontal stacking of the <@itl="A"><@sub="i"> matrices; it is <@itl="n">×<@itl="np">, with one row per equation. This corresponds to the first <@itl="n"> rows of the matrix <@lit="$compan"> provided by gretl's <@lit="var"> and <@lit="vecm"> commands.
The <@itl="u_t"> vectors are contained (as rows) in <@var="U"> (<@itl="T">×<@itl="n">). Initial values are in <@var="y0"> (<@itl="p">×<@itl="n">).
If the VAR contains deterministic terms and/or exogenous regressors, these can be handled by folding them into the <@var="U"> matrix: each row of <@var="U"> then becomes <@itl="u(t) = B' x(t) + e(t).">
The output matrix has <@itl="T"> + <@itl="p"> rows and <@itl="n"> columns; it holds the initial <@itl="p"> values of the endogenous variables plus <@itl="T"> simulated values.
See also <@ref="$compan">, <@xrf="var">, <@xrf="vecm">.
# vec matbuild
Output: column vector
Argument: <@var="X"> (matrix)
Stacks the columns of <@var="X"> as a column vector. See also <@ref="mshape">, <@ref="unvech">, <@ref="vech">.
# vech matbuild
Output: column vector
Argument: <@var="A"> (square matrix)
Returns in a column vector the elements of <@var="A"> on and above the diagonal. Typically, this function is used on symmetric matrices; in this case, it can be undone by the function <@ref="unvech">. See also <@ref="vec">.
# weekday data-utils
Output: scalar
Arguments: <@var="year"> (scalar)
<@var="month"> (scalar)
<@var="day"> (scalar)
Returns the day of the week (Sunday = 0, Monday = 1, etc.) for the date specified by the three arguments, or <@lit="NA"> if the date is invalid.
# wmean stats
Output: series
Arguments: <@var="Y"> (list)
<@var="W"> (list)
Returns a series <@itl="y"> such that <@itl="y"><@sub="t"> is the weighted mean of the values of the variables in list <@var="Y"> at observation <@itl="t">, the respective weights given by the values of the variables in list <@var="W"> at <@itl="t">. The weights can therefore be time-varying. The lists <@var="Y"> and <@var="W"> must be of the same length and the weights must be non-negative.
See also <@ref="wsd">, <@ref="wvar">.
# wsd stats
Output: series
Arguments: <@var="Y"> (list)
<@var="W"> (list)
Returns a series <@itl="y"> such that <@itl="y"><@sub="t"> is the weighted sample standard deviation of the values of the variables in list <@var="Y"> at observation <@itl="t">, the respective weights given by the values of the variables in list <@var="W"> at <@itl="t">. The weights can therefore be time-varying. The lists <@var="Y"> and <@var="W"> must be of the same length and the weights must be non-negative.
See also <@ref="wmean">, <@ref="wvar">.
# wvar stats
Output: series
Arguments: <@var="X"> (list)
<@var="W"> (list)
Returns a series <@itl="y"> such that <@itl="y"><@sub="t"> is the weighted sample variance of the values of the variables in list <@var="X"> at observation <@itl="t">, the respective weights given by the values of the variables in list <@var="W"> at <@itl="t">. The weights can therefore be time-varying. The lists <@var="Y"> and <@var="W"> must be of the same length and the weights must be non-negative.
See also <@ref="wmean">, <@ref="wsd">.
# xmax math
Output: scalar
Arguments: <@var="x"> (scalar)
<@var="y"> (scalar)
Returns the greater of <@var="x"> and <@var="y">, or <@lit="NA"> if either value is missing.
See also <@ref="xmin">, <@ref="max">, <@ref="min">.
# xmin math
Output: scalar
Arguments: <@var="x"> (scalar)
<@var="y"> (scalar)
Returns the lesser of <@var="x"> and <@var="y">, or <@lit="NA"> if either value is missing.
See also <@ref="xmax">, <@ref="max">, <@ref="min">.
# xpx transforms
Output: list
Argument: <@var="L"> (list)
Returns a list that references the squares and cross-products of the variables in list <@var="L">. Squares are named on the pattern <@lit="sq_"><@var="varname"> and cross-products on the pattern <@var="var1"><@lit="_"><@var="var2">. The input variable names are truncated if need be, and the output names may be adjusted in case of duplication of names in the returned list.
# zeromiss data-utils
Output: same type as input
Argument: <@var="x"> (scalar or series)
Converts zeros to <@lit="NA">s. If <@var="x"> is a series, the conversion is done element by element. See also <@ref="missing">, <@ref="misszero">, <@ref="ok">.
# zeros matbuild
Output: matrix
Arguments: <@var="r"> (scalar)
<@var="c"> (scalar)
Outputs a zero matrix with <@itl="r"> rows and <@itl="c"> columns. See also <@ref="ones">, <@ref="seq">.
|