This file is indexed.

/usr/share/gretl/genrcli.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
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
## Accessors
# $ahat
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
Output:     scalar

Returns the Akaike Information Criterion for the last estimated model, if
available. See the Gretl User's Guide for details of the calculation.

# $bic
Output:     scalar

Returns Schwarz's Bayesian Information Criterion for the last estimated
model, if available. See the Gretl User's Guide for details of the
calculation.

# $chisq
Output:     scalar

Returns the overall chi-square statistic from the last estimated model, if
available.

# $coeff
Output:     matrix or scalar
Argument:   s (name of coefficient, optional)

With no arguments, $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 s. See also
"$stderr", "$vcv".

Example:

	  open bjg
	  arima 0 1 1 ; 0 1 1 ; lg 
	  b = $coeff               # gets a vector
	  macoef = $coeff(theta_1) # gets a scalar

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
Output:     string

Must follow the estimation of a model; returns the command word, for example
ols or probit.

# $compan
Output:     matrix

Must follow the estimation of a VAR or a VECM; returns the companion matrix.

# $datatype
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
Output:     string

Must follow the estimation of a single-equation model; returns the name of
the dependent variable.

# $df
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
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
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
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 "catch". Note that using this
accessor causes the internal error code to be reset to zero. See also
"errmsg". If you want to get the error message associated with a given
$error you need to store the value in a temporary variable, as in

	  errval = $error
	  if (errval) 
	    printf "Got error %d (%s)\n", errval, errmsg(errval);
	  endif

# $ess
Output:     scalar

Returns the error sum of squares of the last estimated model, if available.

# $evals
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
Output:     matrix

Must follow the "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
Output:     matrix

Must follow the "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
Output:     matrix

Must follow estimation of a VAR. Returns a matrix containing the forecast
error decomposition. This matrix has h rows where h is the forecast horizon,
which can be chosen using set horizon or otherwise is set automatically
based on the frequency of the data. For a VAR with p variables, the matrix
has p^2 columns. The fraction of the forecast error for variable i
attributable to innovation in variable j is found in column (i - 1)p + j.

# $Fstat
Output:     scalar

Returns the overall F-statistic from the last estimated model, if available.

# $gmmcrit
Output:     scalar

Must follow a gmm block. Returns the value of the objective function at its
minimum.

# $h
Output:     series

Must follow a garch command. Returns the estimated conditional variance
series.

# $hausman
Output:     row vector

Must follow estimation of a model via either tsls or panel with the random
effects option. Returns a 1 x 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
Output:     scalar

Returns the Hannan-Quinn Information Criterion for the last estimated model,
if available. See the Gretl User's Guide for details of the calculation.

# $jalpha
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
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
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 restrict command with the --full option, a singular matrix with (n+m)r
rows will be returned (n being the number of endogenous variables, m the
number of exogenous variables that are restricted to the cointegration
space, and r the cointegration rank).

Example: the 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

produces the following output.

	  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 

# $llt
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
Output:     scalar

Returns the log-likelihood for the last estimated model (where applicable).

# $mnlprobs
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
Output:     scalar

Returns the total number of coefficients estimated in the last model.

# $nobs
Output:     scalar

Returns the number of observations in the currently selected sample.

# $nvars
Output:     scalar

Returns the number of variables in the dataset (including the constant).

# $pd
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
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. chow). See 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 "$test".

# $rho
Output:     scalar
Argument:   n (scalar, optional)

Without arguments, returns the first-order autoregressive coefficient for
the residuals of the last model. After estimating a model via the ar
command, the syntax $rho(n) returns the corresponding estimate of rho(n).

# $rsq
Output:     scalar

Returns the unadjusted R^2 from the last estimated model, if available.

# $sample
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:

	  ols y 0 xlist
	  genr sdum = $sample
	  smpl sdum --dummy

# $sargan
Output:     row vector

Must follow a tsls command. Returns a 1 x 3 vector, containing the value of
the Sargan over-identification test statistic, the corresponding degrees of
freedom and p-value, in that order.

# $sigma
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
Output:     matrix or scalar
Argument:   s (name of coefficient, optional)

With no arguments, $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 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 "$coeff", "$vcv".

# $stopwatch
Output:     scalar

Must be preceded by 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 set stopwatch command. At each access the clock is
reset, so subsequent uses of $stopwatch yield the seconds of CPU time since
the previous access.

# $sysA
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 "system" command.

# $sysB
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 "system" command.

# $sysGamma
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 "system" command.

# $T
Output:     scalar

Returns the number of observations used in estimating the last model.

# $t1
Output:     scalar

Returns the 1-based index of the first observation in the currently selected
sample.

# $t2
Output:     scalar

Returns the 1-based index of the last observation in the currently selected
sample.

# $test
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. chow). See 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 "dpvalue".

# $trsq
Output:     scalar

Returns TR^2 (sample size times R-squared) from the last model, if
available.

# $uhat
Output:     series

Returns the residuals from the last model. This may have different meanings
for different estimators. For example, after an ARMA estimation $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), $uhat with no parameters retrieves the matrix of
residuals, one column per equation.

# $unit
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
Output:     matrix or scalar
Arguments:  s1 (name of coefficient, optional)
            s2 (name of coefficient, optional)

With no arguments, $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 s1 and s2. See also "$coeff", "$stderr".

This accessor is not available for VARs or VECMs; for models of that sort
see "$sigma" and "$xtxinv".

# $vecGamma
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 p there are p - 1 sub-matrices.

# $version
Output:     scalar

Returns an integer value that codes for the program version. The gretl
version string takes the form x.y.z (for example, 1.7.6). The return value
from this accessor is formed as 10000*x + 100*y + z, so that 1.7.6
translates as 10706.

# $vma
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 set horizon
command. See the Gretl User's Guide for details.

# $windows
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 "shell" command.

# $xlist
Output:     list

Returns the list of regressors from the last model (for single-equation
models only).

# $xtxinv
Output:     matrix

Following estimation of a VAR or VECM (only), returns X'X^-1, where 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
Output:     series

Returns the fitted values from the last regression.

## Functions proper
# abs
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the absolute value of x.

# acos
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the arc cosine of x, that is, the value whose cosine is x. The
result is in radians; the input should be in the range -1 to 1.

# acosh
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the inverse hyperbolic cosine of x (positive solution). x should be
greater than 1; otherwise, NA is returned. See also "cosh".

# argname
Output:     string
Argument:   s (string)

For 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
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the arc sine of x, that is, the value whose sine is x. The result is
in radians; the input should be in the range -1 to 1.

# asinh
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the inverse hyperbolic sine of x. See also "sinh".

# atan
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the arc tangent of x, that is, the value whose tangent is x. The
result is in radians.

# atanh
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the inverse hyperbolic tangent of x. See also "tanh".

# bessel
Output:     same type as input
Arguments:  type (character)
            v (scalar)
            x (scalar, series or matrix)

Computes one of the Bessel function variants for order v and argument x. The
return value is of the same type as x. The specific function is selected by
the first argument, which must be J, Y, I, or K. A good discussion of the
Bessel functions can be found on Wikipedia; here we give a brief account.

case J: Bessel function of the first kind. Resembles a damped sine wave.
Defined for real v and x, but if x is negative then v must be an integer.

case Y: Bessel function of the second kind. Defined for real v and x but has
a singularity at x = 0.

case I: Modified Bessel function of the first kind. An exponentially growing
function. Acceptable arguments are as for case J.

case K: Modified Bessel function of the second kind. An exponentially
decaying function. Diverges at x = 0 and is not defined for negative x.
Symmetric around v = 0.

# BFGSmax
Output:     scalar
Arguments:  b (vector)
            f (function call)
            g (function call, optional)

Numerical maximization via the method of Broyden, Fletcher, Goldfarb and
Shanno. The vector b should hold the initial values of a set of parameters,
and the argument 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, BFGSmax returns the maximized value of the criterion, and 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 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 genr
in the Gretl User's Guide. See also "NRmax", "fdjac".

# bkfilt
Output:     series
Arguments:  y (series)
            f1 (scalar, optional)
            f2 (scalar, optional)
            k (scalar, optional)

Returns the result from application of the Baxter-King bandpass filter to
the series y. The optional parameters f1 and f2 represent, respectively, the
lower and upper bounds of the range of frequencies to extract, while k is
the approximation order to be used. If these arguments are not supplied then
the following default values are used: f1 = 8, f1 = 32, k = 8. See also
"hpfilt".

# boxcox
Output:     series
Arguments:  y (series)
            d (scalar)

Returns the Box-Cox transformation with parameter d for the positive series
y.

The transformed series is (y^d - 1)/d for d not equal to zero, or log(y) for
d = 0.

# bwfilt
Output:     series
Arguments:  y (series)
            n (scalar)
            omega (scalar)

Returns the result from application of a low-pass Butterworth filter with
order n and frequency cutoff omega to the series 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 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 the Gretl User's Guide for details. See
also "bkfilt", "hpfilt".

# cdemean
Output:     matrix
Argument:   X (matrix)

Centers the columns of matrix X around their means.

# cdf
Output:     same type as input
Arguments:  c (character)
            ... (see below)
            x (scalar, series or matrix)
Examples:   p1 = cdf(N, -2.5)
            p2 = cdf(X, 3, 5.67)
            p3 = cdf(D, 0.25, -1, 1)

Cumulative distribution function calculator. Returns P(X <= x), where the
distribution X is determined by the character c. Between the arguments c and
x, zero or more additional scalar arguments are required to specify the
parameters of the distribution, as follows.

  Standard normal (c = z, n, or N): no extra arguments

  Bivariate normal (D): correlation coefficient

  Student's t (t): degrees of freedom

  Chi square (c, x, or X): degrees of freedom

  Snedecor's F (f or F): df (num.); df (den.)

  Gamma (g or G): shape; scale

  Binomial (b or B): probability; number of trials

  Poisson (p or P): Mean

  Weibull (w or W): shape; scale

  Generalized Error (E): shape

Note that most cases have aliases to help memorizing the codes. The
bivariate normal case is special: the syntax is x = cdf(D, rho, z1, z2)
where rho is the correlation between the variables z1 and z2.

See also "pdf", "critical", "invcdf", "pvalue".

# cdiv
Output:     matrix
Arguments:  X (matrix)
            Y (matrix)

Complex division. The two arguments must have the same number of rows, 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 n x 2
matrix or, if the result has no imaginary part, an n-vector. See also
"cmult".

# ceil
Output:     same type as input
Argument:   x (scalar, series or matrix)

Ceiling function: returns the smallest integer greater than or equal to x.
See also "floor", "int".

# cholesky
Output:     square matrix
Argument:   A (symmetric matrix)

Peforms a Cholesky decomposition of the matrix A, which is assumed to be
symmetric and positive definite. The result is a lower-triangular matrix L
which satisfies A = LL'. The function will fail if A is not symmetric or not
positive definite. See also "psdroot".

# chowlin
Output:     matrix
Arguments:  Y (matrix)
            xfac (scalar)
            X (matrix, optional)

Expands the input data, Y, to a higher frequency, using the interpolation
method of Chow and Lin (1971). It is assumed that the columns of Y represent
data series; the returned matrix has as many columns as Y and 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 X is
provided, its columns are used as additional regressors; it is an error if
the number of rows in X does not equal xfac times the number of rows in Y.

# cmult
Output:     matrix
Arguments:  X (matrix)
            Y (matrix)

Complex multiplication. The two arguments must have the same number of rows,
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 n x 2
matrix, or, if the result has no imaginary part, an n-vector. See also
"cdiv".

# cnorm
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the cumulative distribution function for a standard normal. See also
"dnorm", "qnorm".

# colname
Output:     string
Arguments:  M (matrix)
            col (scalar)

Retrieves the name for column col of matrix M. If M has no column names
attached the value returned is an empty string; if col is out of bounds for
the given matrix an error is flagged. See also "colnames".

# colnames
Output:     scalar
Arguments:  M (matrix)
            s (named list or string)

Attaches names to the columns of the T x k matrix M. If s is a named list,
the column names are copied from the names of the variables; the list must
have k members. If s is a string, it should contain k space-separated
sub-strings. The return value is 0 on successful completion, non-zero on
error. See also "rownames".

# cols
Output:     scalar
Argument:   X (matrix)

The number of columns of X. See also "mshape", "rows", "unvech", "vec",
"vech".

# corr
Output:     scalar
Arguments:  y1 (series or vector)
            y2 (series or vector)

Computes the correlation coefficient between y1 and y2. The arguments should
be either two series, or two vectors of the same length. See also "cov",
"mcov", "mcorr".

# corrgm
Output:     matrix
Arguments:  x (series, matrix or list)
            p (scalar)
            y (series or vector, optional)

If only the first two arguments are given, computes the correlogram for x
for lags 1 to p. Let k represent the number of elements in x (1 if x is a
series, the number of columns if x is a matrix, or the number of
list-members is x is a list). The return value is a matrix with p rows and
2k columns, the first 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 k elements in x and y, from lead p to lag p. The returned
matrix has 2p + 1 rows and k columns. If x is series or list and y is a
vector, the vector must have just as many rows as there are observations in
the current sample range.

# cos
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the cosine of x.

# cosh
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the hyperbolic cosine of x.

See also "acosh", "sinh", "tanh".

# cov
Output:     scalar
Arguments:  y1 (series or vector)
            y2 (series or vector)

Returns the covariance between y1 and y2. The arguments should be either two
series, or two vectors of the same length. See also "corr", "mcov", "mcorr".

# critical
Output:     same type as input
Arguments:  c (character)
            ... (see below)
            p (scalar, series or matrix)
Examples:   c1 = critical(t, 20, 0.025)
            c2 = critical(F, 4, 48, 0.05)

Critical value calculator. Returns x such that P(X > x) = p, where the
distribution X is determined by the character c. Between the arguments c and
p, zero or more additional scalar arguments are required to specify the
parameters of the distribution, as follows.

  Standard normal (c = z, n, or N): no extra arguments

  Student's t (t): degrees of freedom

  Chi square (c, x, or X): degrees of freedom

  Snedecor's F (f or F): df (num.); df (den.)

  Binomial (b or B): probability; trials

  Poisson (p or P): mean

See also "cdf", "invcdf", "pvalue".

# cum
Output:     same type as input
Argument:   x (series or matrix)

Cumulates x. When x is a series, produces a series y each of whose elements
is the sum of the values of x to date; the starting point of the summation
is the first non-missing observation in the currently selected sample. When
x is a matrix, its elements are cumulated by columns.

See also "diff".

# deseas
Output:     series
Arguments:  x (series)
            c (character, optional)

Depends on having TRAMO/SEATS or X-12-ARIMA installed. Returns a
deseasonalized (seasonally adjusted) version of the input series x, which
must be a quarterly or monthly time series. To use X-12-ARIMA give X as the
second argument; to use TRAMO give 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; 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
Output:     scalar
Argument:   A (square matrix)

Returns the determinant of A, computed via the LU factorization. See also
"ldet", "rcond".

# diag
Output:     matrix
Argument:   X (matrix)

Returns the principal diagonal of X in a column vector. Note: if X is an m x
n marix, the number of elements of the output vector is min(m, n). See also
"tr".

# diagcat
Output:     matrix
Arguments:  A (matrix)
            B (matrix)

Returns the direct sum of A and B, that is a block-diagonal matrix holding A
in its north-west corner and B in its south-east corner.

# diff
Output:     same type as input
Argument:   y (series, matrix or list)

Computes first differences. If y is a series, or a list of series, starting
values are set to NA. If 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 d_varname where 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 "cum", "ldiff", "sdiff".

# digamma
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the digamma (or Psi) function of x, that is the derivative of the
log of the Gamma function.

# dnorm
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the density of the standard normal distribution at x. To get the
density for a non-standard normal distribution at x, pass the z-score of x
to the dnorm function and multiply the result by the Jacobian of the z
transformation, namely 1 over sigma, as illustrated below:

	  mu = 100
	  sigma = 5
	  x = 109
	  fx = (1/sigma) * dnorm((x-mu)/sigma)

See also "cnorm", "qnorm".

# dsort
Output:     same type as input
Argument:   x (series or vector)

Sorts x in descending order, skipping observations with missing values when
x is a series. See also "sort", "values".

# dummify
Output:     list
Arguments:  x (series)
            omitval (scalar, optional)

The argument 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 x which should be
treated as the omitted category. The effect when a single argument is given
is equivalent to dummify(x, min(x)). To produce a full set of dummies, with
no omitted category, use dummify(x, NA).

The generated variables are automatically named according to the template
Dvarname_i where varname is the name of the original series and 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
Output:     matrix
Arguments:  A (square matrix)
            &U (reference to matrix, or null)

Computes the eigenvalues, and optionally the right eigenvectors, of the n x
n matrix A. If all the eigenvalues are real, an n x 1 matrix is returned;
otherwise, the result is an n x 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 & (to indicate the "address" of the matrix in question), in which case an
auxiliary result is written to that matrix, or the keyword 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:

  If the i-th eigenvalue is real, the i-th column of U will contain the
  corresponding eigenvector;

  If the i-th eigenvalue is complex, the i-th column of 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.

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 n, because the conjugate eigenvector is skipped.

See also "eigensym", "qrdecomp", "svd".

# eigensym
Output:     matrix
Arguments:  A (symmetric matrix)
            &U (reference to matrix, or null)

Works just as "eigengen", but the argument A must be symmetric (in which
case the calculations can be reduced).

# eigsolve
Output:     matrix
Arguments:  A (symmetric matrix)
            B (symmetric matrix)
            &U (reference to matrix, or null)

Solves the generalized eigenvalue problem |A - lambdaB| = 0, where both A
and B are symmetric and 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 &; in that case the generalized eigenvectors
are written to the named matrix.

# epochday
Output:     scalar
Arguments:  year (scalar)
            month (scalar)
            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
Output:     string
Argument:   errno (scalar)

Retrieves the gretl error message associated with errno. See also "$error".

# exp
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns e^x. Note that in case of matrices the function acts element by
element. For the matrix exponential function, see "mexp".

# fcstats
Output:     matrix
Arguments:  y (series or vector)
            f (series or vector)

Produces a column vector holding several statistics which may be used for
evaluating the series f as a forecast of the series 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:

	  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

For details on the calculation of these statistics, and the interpretation
of the U values, please see the Gretl User's Guide.

# fdjac
Output:     matrix
Arguments:  b (column vector)
            f (function call)

Calculates the (forward-difference approximation to the) Jacobian associated
with the vector b and the transformation function specified by the argument
f. For more details and examples see the chapter on special functions in
genr in the Gretl User's Guide.

See also "BFGSmax".

# fft
Output:     matrix
Argument:   X (matrix)

Discrete real Fourier transform. If the input matrix X has n columns, the
output has 2n 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 fft for each vector separately. See
also "ffti".

# ffti
Output:     matrix
Argument:   X (matrix)

Inverse discrete real Fourier transform. It is assumed that X contains 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
2n. A matrix with 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 ffti for each vector
separately. See also "fft".

# filter
Output:     series
Arguments:  x (series)
            a (scalar or vector, optional)
            b (scalar or vector, optional)
            y0 (scalar, optional)

Computes an ARMA-like filtering of the series x. The transformation can be
written as

y_t = a_0 x_t + a_1 x_t-1 + ... a_q x_t-q + b_1 y_t-1 + ... b_p y_t-p

The two arguments a and b are optional. They may be scalars, vectors or the
keyword null.

If a is a scalar, this is used as a_0 and implies q=0; if it is a vector of
q+1 elements, they contain the coefficients from a_0 to a_q. If a is null or
omitted, this is equivalent to setting a_0=1 and q=0.

If b is a scalar, this is used as b_1 and implies p=1; if it is a vector of
p elements, they contain the coefficients from b_1 to b_p. If b is null or
omitted, this is equivalent to setting B(L)=1.

The optional scalar argument y0 is taken to represent all values of y prior
to the beginning of sample (used only when p>0). If omitted, it is
understood to be 0. Pre-sample values of x are always assumed zero.

See also "bkfilt", "fracdiff", "hpfilt", "movavg".

Example:

	  nulldata 5
	  y = filter(index, 0.5, -0.9, 1)
	  print index y --byobs

produces

                   index            y   

          1            1     -0.40000   
          2            2      1.36000   
          3            3      0.27600   
          4            4      1.75160   
          5            5      0.92356   

# firstobs
Output:     scalar
Argument:   y (series)

First non-missing observation for the variable y. Note that if some form of
subsampling is in effect, the value returned may be smaller than the dollar
variable "$t1". See also "lastobs".

# floor
Output:     same type as input
Argument:   y (scalar, series or matrix)

Floor function: returns the greatest integer less than or equal to x. Note:
"int" and floor differ in their effect for negative arguments: int(-3.5)
gives -3, while floor(-3.5) gives -4.

# fracdiff
Output:     series
Arguments:  y (series)
            d (scalar)

Returns the fractional difference of order d for the series y.

Note that in theory fractional differentiation is an infinitely long filter.
In practice, presample values of y_t are assumed to be zero.

# gammafun
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the gamma function of x.

# getenv
Output:     string
Argument:   s (string)

If an environment variable by the name of s is defined, returns the string
value of that variable, otherwise returns an empty string. See also
"ngetenv".

# gini
Output:     scalar
Argument:   y (series)

Returns Gini's inequality index for the series y.

# ginv
Output:     matrix
Argument:   A (matrix)

Returns A^+, the Moore-Penrose or generalized inverse of A, computed via the
singular value decomposition.

This matrix has the properties A A^+ A = A and A^+ A A^+ = A^+ . Moreover,
the products A A^+ and A^+ A are symmetric by construction.

See also "inv", "svd".

# hdprod
Output:     matrix
Arguments:  X (matrix)
            Y (matrix)

Horizontal direct product. The two arguments must have the same number of
rows, r. The return value is a matrix with r rows, in which the i-th row is
the Kronecker product of the corresponding rows of X and 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

	  A = {1,2,3; 4,5,6}
	  B = {0,1; -1,1}
	  C = hdprod(A, B)

produces the following matrix:

         0    1    0    2    0    3 
        -4    4   -5    5   -6    6 

# hpfilt
Output:     series
Arguments:  y (series)
            lambda (scalar, optional)

Returns the cycle component from application of the Hodrick-Prescott filter
to series y. If the smoothing parameter, 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
"bkfilt".

# I
Output:     square matrix
Argument:   n (scalar)

Returns an identity matrix with n rows and columns.

# imaxc
Output:     row vector
Argument:   X (matrix)

Returns the row indices of the maxima of the columns of X.

See also "imaxr", "iminc", "maxc".

# imaxr
Output:     column vector
Argument:   X (matrix)

Returns the column indices of the maxima of the rows of X.

See also "imaxc", "iminr", "maxr".

# imhof
Output:     scalar
Arguments:  M (matrix)
            x (scalar)

Computes Prob(u'Au < x) for a quadratic form in standard normal variates, u,
using the procedure developed by Imhof (1961).

If the first argument, M, is a square matrix it is taken to specify A,
otherwise if it's a column vector it is taken to be the precomputed
eigenvalues of A, otherwise an error is flagged.

See also "pvalue".

# iminc
Output:     row vector
Argument:   X (matrix)

Returns the row indices of the minima of the columns of X.

See also "iminr", "imaxc", "minc".

# iminr
Output:     column vector
Argument:   X (matrix)

Returns the column indices of the mimima of the rows of X.

See also "iminc", "imaxr", "minr".

# inbundle
Output:     scalar
Arguments:  b (bundle)
            key (string)

Returns 1 if bundle b contains a data-item with name key, otherwise 0.

# infnorm
Output:     scalar
Argument:   X (matrix)

Returns the infinity-norm of X, that is, the maximum across the rows of X of
the sum of absolute values of the row elements.

See also "onenorm".

# inlist
Output:     scalar
Arguments:  L (list)
            y (series)

Returns the (1-based) position of y in list L, or 0 if y is not present in
L. The second argument may be given as the name of a series or alternatively
as an integer ID number.

# int
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the integer part of x, truncating the fractional part. Note: int and
"floor" differ in their effect for negative arguments: int(-3.5) gives -3,
while floor(-3.5) gives -4. See also "ceil".

# inv
Output:     matrix
Argument:   A (square matrix)

Returns the inverse of A. If A is singular or not square, an error message
is produced and nothing is returned. Note that gretl checks automatically
the structure of 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 "ginv", "invpd".

# invcdf
Output:     same type as input
Arguments:  c (character)
            ... (see below)
            p (scalar, series or matrix)

Inverse cumulative distribution function calculator. Returns x such that P(X
<= x) = p, where the distribution X is determined by the character c;
Between the arguments c and p, zero or more additional scalar arguments are
required to specify the parameters of the distribution, as follows.

  Standard normal (c = z, n, or N): no extra arguments

  Gamma (g or G): shape; scale

  Student's t (t): degrees of freedom

  Chi square (c, x, or X): degrees of freedom

  Snedecor's F (f or F): df (num.); df (den.)

  Binomial (b or B): probability; trials

  Poisson (p or P): mean

  Standardized GED (E): shape

See also "cdf", "critical", "pvalue".

# invmills
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the inverse Mills ratio at x, that is the ratio between the standard
normal density and the complement to the standard normal distribution
function, both evaluated at x.

This function uses a dedicated algorithm which yields greater accuracy
compared to calculation using "dnorm" and "cnorm", but the difference
between the two methods is appreciable only for very large negative values
of x.

See also "cdf", "cnorm", "dnorm".

# invpd
Output:     square matrix
Argument:   A (symmetric matrix)

Returns the inverse of the symmetric, positive definite matrix A. This
function is slightly faster than "inv" for large matrices, since no check
for symmetry is performed; for that reason it should be used with care.

# irf
Output:     matrix
Arguments:  target (scalar)
            shock (scalar)
            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 target variable to
an impulse of one standard deviation in the shock variable. These variables
are identified by their position in the VAR specification: for example, if
target and 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 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
alpha = 0.1 corresponds to 90 percent confidence.) If 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 "set" command, as in set horizon 10.

# irr
Output:     scalar
Argument:   x (series or vector)

Returns the Internal Rate of Return for x, considered as a sequence of
payments (negative) and receipts (positive). See also "npv".

# isconst
Output:     scalar
Arguments:  y (series or vector)
            panel-code (scalar, optional)

Without the optional second argument, returns 1 if y has a constant value
over the current sample range (or over its entire length if y is a vector),
otherwise 0.

The second argument is accepted only if the current dataset is a panel and y
is a series. In that case a 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 y is the same for all
groups).

If y is a series, missing values are ignored in checking for constancy.

# islist
Output:     scalar
Argument:   s (string)

Returns 1 if s is the identifier for a currently defined list, otherwise 0.
See also "isnull", "isseries", "isstring".

# isnull
Output:     scalar
Argument:   s (string)

Returns 0 if 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
"islist", "isseries", "isstring".

# kdensity
Output:     matrix
Arguments:  x (series)
            scale (scalar, optional)
            control (scalar, optional)

Computes a kernel density estimate for the series 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 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 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 "gnuplot" command, as in

	  matrix d = kdensity(x)
	  gnuplot 2 1 --matrix=d --with-lines

# kfilter
Output:     scalar
Arguments:  &E (reference to matrix, or null)
            &V (reference to matrix, or null)
            &S (reference to matrix, or null)
            &P (reference to matrix, or null)
            &G (reference to matrix, or 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: E gets the matrix of one-step ahead prediction errors and V
gets the variance matrix for these errors; S gets the matrix of estimated
values of the state vector and P the variance matrix of these estimates; G
gets the Kalman gain. All of these matrices have T rows, corresponding to T
observations. For the column dimensions and further details see the Gretl
User's Guide.

See also "kalman", "ksmooth", "ksimul".

# ksimul
Output:     matrix
Arguments:  v (matrix)
            w (matrix)
            &S (reference to matrix, or 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 v supplies artificial disturbances for the state transition
equation and w supplies disturbances for the observation equation, if
applicable. The optional argument S may be used to retrieve the simulated
state vector. For details see the Gretl User's Guide.

See also "kalman", "kfilter", "ksmooth".

# ksmooth
Output:     matrix
Argument:   &P (reference to matrix, or 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 P may be used to retrieve the MSE of the smoothed state.
For details see the Gretl User's Guide.

See also "kalman", "kfilter", "ksimul".

# kurtosis
Output:     scalar
Argument:   x (series)

Returns the excess kurtosis of the series x, skipping any missing
observations.

# isseries
Output:     scalar
Argument:   s (string)

Returns 1 if s is the identifier for a currently defined series, otherwise
0. See also "islist", "isnull", "isstring".

# isstring
Output:     scalar
Argument:   s (string)

Returns 1 if s is the identifier for a currently defined string, otherwise
0. See also "islist", "isnull", "isseries".

# lags
Output:     list
Arguments:  p (scalar)
            y (series or list)

Generates lags 1 to p of the series y, or if y is a list, of all variables
in the list. If p = 0, the maximum lag defaults to the periodicity of the
data; otherwise p must be positive.

The generated variables are automatically named according to the template
varname_i where varname is the name of the original series and 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
Output:     scalar
Argument:   y (series)

Last non-missing observation for the variable y. Note that if some form of
subsampling is in effect, the value returned may be larger than the dollar
variable "$t2". See also "firstobs".

# ldet
Output:     scalar
Argument:   A (square matrix)

Returns the natural log of the determinant of A, computed via the LU
factorization. See also "det", "rcond".

# ldiff
Output:     same type as input
Argument:   y (series or list)

Computes log differences; starting values are set to NA.

When a list is returned, the individual variables are automatically named
according to the template ld_varname where 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 "diff", "sdiff".

# lincomb
Output:     series
Arguments:  L (list)
            b (vector)

Computes a new series as a linear combination of the series in the list L.
The coefficients are given by the vector b, which must have length equal to
the number of series in L.

See also "wmean".

# ljungbox
Output:     scalar
Arguments:  y (series)
            p (scalar)

Computes the Ljung-Box Q' statistic for the series y using lag order 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 p degrees
of freedom as a test of the null hypothesis that the series y is serially
independent. See also "pvalue".

# lngamma
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the log of the gamma function of x.

# log
Output:     same type as input
Argument:   x (scalar, series, matrix or list)

Returns the natural logarithm of x; produces NA for non-positive values.
Note: ln is an acceptable alias for log.

When a list is returned, the individual variables are automatically named
according to the template l_varname where 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
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the base-10 logarithm of x; produces NA for non-positive values.

# log2
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the base-2 logarithm of x; produces NA for non-positive values.

# logistic
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the logistic function of the argument x, that is, e^x/(1 + e^x). If
x is a matrix, the function is applied element by element.

# lower
Output:     square matrix
Argument:   A (matrix)

Returns an n x n lower triangular matrix: the elements on and below the
diagonal are equal to the corresponding elements of A; the remaining
elements are zero.

See also "upper".

# lrvar
Output:     scalar
Arguments:  y (series or vector)
            k (scalar)

Returns the long-run variance of y, calculated using a Bartlett kernel with
window size k. If k is negative, int(T^(1/3)) is used.

# max
Output:     scalar or series
Argument:   y (series or list)

If the argument 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 "min", "xmax", "xmin".

# maxc
Output:     row vector
Argument:   X (matrix)

Returns a row vector containing the maxima of the columns of X.

See also "imaxc", "maxr", "minc".

# maxr
Output:     column vector
Argument:   X (matrix)

Returns a column vector containing the maxima of the rows of X.

See also "imaxc", "maxc", "minr".

# mcorr
Output:     matrix
Argument:   X (matrix)

Computes a correlation matrix treating each column of X as a variable. See
also "corr", "cov", "mcov".

# mcov
Output:     matrix
Argument:   X (matrix)

Computes a covariance matrix treating each column of X as a variable. See
also "corr", "cov", "mcorr".

# mcovg
Output:     matrix
Arguments:  X (matrix)
            u (vector, optional)
            w (vector, optional)
            p (scalar)

Returns the matrix covariogram for a T x k matrix X (typically containing
regressors), an (optional) T-vector u (typically containing residuals), an
(optional) (p+1)-vector of weights w, and a scalar lag order 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 u is given as null the u terms are omitted, and if w is given as null all
the weights are taken to be 1.0.

# mean
Output:     scalar or series
Argument:   x (series or list)

If x is a series, returns the (scalar) sample mean, skipping any missing
observations.

If x is a list, returns a series y such that y_t is the mean of the values
of the variables in the list at observation t, or NA if there are any
missing values at t.

# meanc
Output:     row vector
Argument:   X (matrix)

Returns the means of the columns of X. See also "meanr", "sumc", "sdc".

# meanr
Output:     column vector
Argument:   X (matrix)

Returns the means of the rows of X. See also "meanc", "sumr".

# median
Output:     scalar
Argument:   y (series)

The median of the non-missing observations in series y. See also "quantile".

# mexp
Output:     square matrix
Argument:   A (square matrix)

Computes the matrix exponential of A, using algorithm 11.3.1 from Golub and
Van Loan (1996).

# min
Output:     scalar or series
Argument:   y (series or list)

If the argument 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 "max", "xmax", "xmin".

# minc
Output:     row vector
Argument:   X (matrix)

Returns the minima of the columns of X.

See also "iminc", "maxc", "minr".

# minr
Output:     column vector
Argument:   X (matrix)

Returns the minima of the rows of X.

See also "iminr", "maxr", "minc".

# missing
Output:     same type as input
Argument:   x (scalar, series or list)

Returns a binary variable holding 1 if x is NA. If x is a series, the
comparison is done element by element; if 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 "misszero", "ok", "zeromiss".

# misszero
Output:     same type as input
Argument:   x (scalar or series)

Converts NAs to zeros. If x is a series, the conversion is done element by
element. See also "missing", "ok", "zeromiss".

# mlag
Output:     matrix
Arguments:  X (matrix)
            p (scalar or vector)
            m (scalar, optional)

Shifts up or down the rows of X. If p is a positive scalar, returns a matrix
in which the columns of X are shifted down by p rows and the first p rows
are filled with the value m. If p is a negative number, X is shifted up and
the last rows are filled with the value m. If m is omitted, it is understood
to be zero.

If p is a vector, the above operation is carried out for each element in p,
joining the resulting matrices horizontally.

# mnormal
Output:     matrix
Arguments:  r (scalar)
            c (scalar)

Returns a matrix with r rows and c columns, filled with standard normal
pseudo-random variates. See also "normal", "muniform".

# mols
Output:     matrix
Arguments:  Y (matrix)
            X (matrix)
            &U (reference to matrix, or null)
            &V (reference to matrix, or null)

Returns a k x n matrix of parameter estimates obtained by OLS regression of
the T x n matrix Y on the T x k matrix X.

If the third argument is not null, the T x n matrix U will contain the
residuals. If the final argument is given and is not null then the k x k
matrix V will contain (a) the covariance matrix of the parameter estimates,
if Y has just one column, or (b) X'X^-1 if Y has multiple columns.

By default, estimates are obtained via Cholesky decomposition, with a
fallback to QR decomposition if the columns of X are highly collinear. The
use of SVD can be forced via the command set svd on.

See also "mpols", "mrls".

# monthlen
Output:     scalar
Arguments:  month (scalar)
            year (scalar)
            weeklen (scalar)

Returns the number of (relevant) days in the specified month in the
specified year; 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
Output:     series
Arguments:  x (series)
            p (scalar)
            control (scalar, optional)

Depending on the value of the parameter p, returns either a simple or an
exponentially weighted moving average of the input series x.

If p > 1, a simple 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 control parameter the MA is centered, otherwise it is "trailing".

If 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 x, but the control parameter may be used to
specify the number of initial observations that should be averaged to
produce y(0). A zero value for control indicates that all the observations
should be used.

# mpols
Output:     matrix
Arguments:  Y (matrix)
            X (matrix)
            &U (reference to matrix, or null)

Works exactly as "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 GRETL_MP_BITS, e.g.
GRETL_MP_BITS=1024.

# mrandgen
Output:     matrix
Arguments:  c (character)
            a (scalar)
            b (scalar)
Examples:   matrix mx = mrandgen(u, 0, 100, 50, 1)
            matrix mt14 = mrandgen(t, 14, 20, 20)

Works like "randgen" except that the return value is a matrix rather than a
series. The initial arguments to this function are as described for 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 x 20 random matrix with drawings
from the the t distribution with 14 degrees of freedom.

See also "mnormal", "muniform".

# mread
Output:     matrix
Argument:   s (string)

Reads a matrix from a text file. The string 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:

  The columns must be separated by spaces or tab characters.

  The decimal separator must be the dot character, ".".

  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.

Should an error occur (such as the file being badly formatted or
inaccessible), an empty matrix is returned.

See also "mwrite".

# mreverse
Output:     matrix
Argument:   X (matrix)

Returns a matrix containing the rows of X in reverse order. If you wish to
obtain a matrix in which the columns of X appear in reverse order you can
do:

	  matrix Y = mreverse(X')'

# mrls
Output:     matrix
Arguments:  Y (matrix)
            X (matrix)
            R (matrix)
            q (column vector)
            &U (reference to matrix, or null)
            &V (reference to matrix, or null)

Restricted least squares: returns a k x n matrix of parameter estimates
obtained by least-squares regression of the T x n matrix Y on the T x k
matrix X subject to the linear restriction RB = q, where B denotes the
stacked coefficient vector. R must have k * n columns; each row of this
matrix represents a linear restriction. The number of rows in q must match
the number of rows in R.

If the fifth argument is not null, the T x n matrix U will contain the
residuals. If the final argument is given and is not null then the k x k
matrix V will hold the restricted counterpart to the matrix X'X^-1. The
variance matrix of the estimates for equation i can be constructed by
multiplying the appropriate sub-matrix of V by an estimate of the error
variance for that equation.

# mshape
Output:     matrix
Arguments:  X (matrix)
            r (scalar)
            c (scalar)

Rearranges the elements of X into a matrix with r rows and c columns.
Elements are read from X and written to the target in column-major order. If
X contains fewer than k = rc elements, the elements are repeated cyclically;
otherwise, if X has more elements, only the first k are used.

See also "cols", "rows", "unvech", "vec", "vech".

# msortby
Output:     matrix
Arguments:  X (matrix)
            j (scalar)

Returns a matrix in which the rows of X are reordered by increasing value of
the elements in column j.

# muniform
Output:     matrix
Arguments:  r (scalar)
            c (scalar)

Returns a matrix with r rows and 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 muniform to a scalar, as in

	  scalar x = muniform(1,1)

See also "mnormal", "uniform".

# mwrite
Output:     scalar
Arguments:  X (matrix)
            s (string)

Writes the matrix X to a plain text file named 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 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 mwrite command can be easily read by other programs;
see the Gretl User's Guide for details.

See also "mread".

# mxtab
Output:     matrix
Arguments:  x (series or vector)
            y (series or vector)

Returns a matrix holding the cross tabulation of the values contained in x
(by row) and 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 "values".

# nelem
Output:     scalar
Argument:   L (list)

Returns the number of members in list L.

# ngetenv
Output:     scalar
Argument:   s (string)

If an environment variable by the name of s is defined and has a numerical
value, returns that value; otherwise returns NA. See also "getenv".

# nobs
Output:     scalar
Argument:   y (series)

Returns the number of non-missing observations for the variable y in the
currently selected sample.

# normal
Output:     series
Arguments:  mu (scalar)
            sigma (scalar)

Generates a series of Gaussian pseudo-random variates with mean mu and
standard deviation sigma. If no arguments are supplied, standard normal
variates N(0,1) are produced. The values are produced using the Ziggurat
method (Marsaglia and Tsang, 2000).

See also "randgen", "mnormal", "muniform".

# npv
Output:     scalar
Arguments:  x (series or vector)
            r (scalar)

Returns the Net Present Value of x, considered as a sequence of payments
(negative) and receipts (positive), evaluated at annual discount rate 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 "irr".

# NRmax
Output:     scalar
Arguments:  b (vector)
            f (function call)
            g (function call, optional)
            h (function call, optional)

Numerical maximization via the Newton-Raphson method. The vector b should
hold the initial values of a set of parameters, and the argument 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, NRmax returns the
maximized value of the criterion, and 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 g and 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 genr
in the Gretl User's Guide. See also "BFGSmax", "fdjac".

# nullspace
Output:     matrix
Argument:   A (matrix)

Computes the right nullspace of A, via the singular value decomposition: the
result is a matrix B such that the product AB is a zero matrix, except when
A has full column rank, in which case an empty matrix is returned.
Otherwise, if A is m x n, B will be n by (n - r), where r is the rank of A.

See also "rank", "svd".

# obs
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 t instead
of obs with the same effect.

See also "obsnum".

# obslabel
Output:     string
Argument:   t (scalar)

Returns the observation label for observation t, where t is a 1-based index.
The inverse function is provided by "obsnum".

# obsnum
Output:     scalar
Argument:   s (string)

Returns an integer corresponding to the observation specified by the string
s. Note that the result is invariant to subsampling. This function is
especially useful with time-series datasets. For example, the following code

	  open denmark 
	  k = obsnum(1980:1)

yields k = 25, indicating that the first quarter of 1980 is the 25th
observation in the denmark dataset.

See also "obs", "obslabel".

# ok
Output:     same type as input
Argument:   x (scalar, series or list)

Returns a binary variable holding 1 if x is not NA. If x is a series, the
comparison is done element by element. If 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 "missing", "misszero", "zeromiss".

# onenorm
Output:     scalar
Argument:   X (matrix)

Returns the 1-norm of the matrix X, that is, the maximum across the columns
of X of the sum of absolute values of the column elements.

See also "infnorm", "rcond".

# ones
Output:     matrix
Arguments:  r (scalar)
            c (scalar)

Outputs a matrix with r rows and c columns, filled with ones.

See also "seq", "zeros".

# orthdev
Output:     series
Argument:   y (series)

Only applicable if the currently open dataset has a panel structure.
Computes the forward orthogonal deviations for variable 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 t is the deviation that,
strictly speaking, belongs at t - 1). That way one loses the first
observation in each time series, not the last.

See also "diff".

# pdf
Output:     same type as input
Arguments:  c (character)
            ... (see below)
            x (scalar, series or matrix)
Examples:   f1 = pdf(N, -2.5)
            f2 = pdf(X, 3, y)
            f3 = pdf(W, shape, scale, y)

Probability density function calculator. Returns the density at x of the
distribution identified by the code c. See "cdf" for details of the required
(scalar) arguments. The distributions supported by the pdf function are the
normal, Student's t, chi-square, 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 "dnorm".

# pergm
Output:     matrix
Arguments:  x (series or vector)
            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 x using a Bartlett lag window of the given
bandwidth, up to a maximum of half the number of observations (T/2).

Returns a matrix with two columns and T/2 rows: the first column holds the
frequency, omega, from 2pi/T to pi, and the second the corresponding
spectral density.

# pmax
Output:     series
Arguments:  y (series)
            mask (series, optional)

Only applicable if the currently open dataset has a panel structure. Returns
the per-unit maximum for variable y.

If the optional second argument is provided then observations for which the
value of mask is zero are ignored.

See also "pmin", "pmean", "pnobs", "psd".

# pmean
Output:     series
Arguments:  y (series)
            mask (series, optional)

Only applicable if the currently open dataset has a panel structure.
Computes the per-unit mean for variable 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 mask is zero are ignored.

See also "pmax", "pmin", "pnobs", "psd", "pshrink".

# pmin
Output:     series
Arguments:  y (series)
            mask (series, optional)

Only applicable if the currently open dataset has a panel structure. Returns
the per-unit mimimum for variable y.

If the optional second argument is provided then observations for which the
value of mask is zero are ignored.

See also "pmax", "pmean", "pnobs", "psd".

# pnobs
Output:     series
Arguments:  y (series)
            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 y.

If the optional second argument is provided then observations for which the
value of mask is zero are ignored.

See also "pmax", "pmin", "pmean", "psd".

# polroots
Output:     matrix
Argument:   a (vector)

Finds the roots of a polynomial. If the polynomial is of degree p, the
vector a should contain p + 1 coefficients in ascending order, i.e. starting
with the constant and ending with the coefficient on x^p.

If all the roots are real they are returned in a column vector of length p,
otherwise a p x 2 matrix is returned, the real parts in the first column and
the imaginary parts in the second.

# polyfit
Output:     series
Arguments:  y (series)
            q (scalar)

Fits a polynomial trend of order q to the input series y using the method of
orthogonal polynomials. The series returned holds the fitted values.

# princomp
Output:     matrix
Arguments:  X (matrix)
            p (scalar)

Let the matrix X be T x k, containing T observations on k variables. The
argument p must be a positive integer less than or equal to k. This function
returns a T x p matrix, P, holding the first p principal components of X.

The elements of P are computed as the sum from i to k of Z_ti times v_ji,
where Z_ti is the standardized value of variable i at observation t and v_ji
is the jth eigenvector of the correlation matrix of the X_is, with the
eigenvectors ordered by decreasing value of the corresponding eigenvalues.

See also "eigensym".

# psd
Output:     series
Arguments:  y (series)
            mask (series, optional)

Only applicable if the currently open dataset has a panel structure.
Computes the per-unit sample standard deviation for variable 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 NA is returned).

If the optional second argument is provided then observations for which the
value of mask is zero are ignored.

Note: this function makes it possible to check whether a given variable
(say, X) is time-invariant via the condition max(psd(X)) = 0.

See also "pmax", "pmin", "pmean", "pnobs".

# psdroot
Output:     square matrix
Argument:   A (symmetric matrix)

Performs a generalized variant of the Cholesky decomposition of the matrix
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 A is read. The result is a
lower-triangular matrix L which satisfies A = LL'. Indeterminate elements in
the solution are set to zero.

For the case where A is positive definite, see "cholesky".

# pshrink
Output:     matrix
Argument:   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 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 "pmean".

# pvalue
Output:     same type as input
Arguments:  c (character)
            ... (see below)
            x (scalar, series or matrix)
Examples:   p1 = pvalue(z, 2.2)
            p2 = pvalue(X, 3, 5.67)
            p2 = pvalue(F, 3, 30, 5.67)

P-value calculator. Returns P(X > x), where the distribution X is determined
by the character c. Between the arguments c and x, zero or more additional
arguments are required to specify the parameters of the distribution; see
"cdf" for details. The distributions supported by the pval function are the
standard normal, t, Chi square, F, gamma, binomial, Poisson, Weibull and
Generalized Error.

See also "critical", "invcdf", "urcpval", "imhof".

# qform
Output:     matrix
Arguments:  x (matrix)
            A (symmetric matrix)

Computes the quadratic form Y = xAx'. Using this function instead of
ordinary matrix multiplication guarantees more speed and better accuracy. If
x and A are not conformable, or A is not symmetric, an error is returned.

# qnorm
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns quantiles for the standard normal distribution. If x is not between
0 and 1, NA is returned. See also "cnorm", "dnorm".

# qrdecomp
Output:     matrix
Arguments:  X (matrix)
            &R (reference to matrix, or null)

Computes the QR decomposition of an m x n matrix X, that is X = QR where Q
is an m x n orthogonal matrix and R is an n x n upper triangular matrix. The
matrix Q is returned directly, while R can be retrieved via the optional
second argument.

See also "eigengen", "eigensym", "svd".

# quantile
Output:     scalar or matrix
Arguments:  y (series or matrix)
            p (scalar between 0 and 1)

If y is a series, returns the p-quantile for the series. For example, when p
= 0.5, the median is returned.

If y is a matrix, returns a row vector containing the p-quantiles for the
columns of y; that is, each column is treated as a series.

In addition, for matrix y an alternate form of the second argument is
supported: p may be given as a vector. In that case the return value is an m
x n matrix, where m is the number of elements in p and n is the number of
columns in y.

# randgen
Output:     series
Arguments:  c (character)
            a (scalar or series)
            b (scalar or series)
Examples:   series x = randgen(u, 0, 100)
            series t14 = randgen(t, 14)
            series y = randgen(B, 0.6, 30)
            series g = randgen(G, 1, 1)
            series P = randgen(P, mu)

All-purpose random number generator. The parameter c is a character, which
specifies from which distribution the pseudo-random numbers should be drawn.
The arguments a and (in some cases) 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 a or 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 a and,
where applicable, b.

  Uniform (continuous) (c = u or U): minimum; maximum

  Uniform (discrete) (c = i): minimum; maximum

  Standard normal (c = z, n, or N): mean; standard deviation

  Student's t (t): degrees of freedom

  Chi square (c, x, or X): degrees of freedom

  Snedecor's F (f or F): df (num.); df (den.)

  Gamma (g or G): shape; scale

  Binomial (b or B): probability; number of trials

  Poisson (p or P): Mean

  Weibull (w or W): shape; scale

  Generalized Error (E): shape

See also "normal", "uniform", "mrandgen".

# randint
Output:     scalar
Arguments:  min (scalar)
            max (scalar)

Returns a pseudo-random integer in the closed interval [min, max]. See also
"randgen".

# rank
Output:     scalar
Argument:   X (matrix)

Returns the rank of X, numerically computed via the singular value
decomposition. See also "svd".

# ranking
Output:     same type as input
Argument:   y (series or vector)

Returns a series or vector with the ranks of y. The rank for observation i
is the number of elements that are less than y_i plus one half the number of
elements that are equal to y_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 "sort", "sortby".

# rcond
Output:     scalar
Argument:   A (square matrix)

Returns the reciprocal condition number for A with respect to the 1-norm. In
many circumstances, this is a better measure of the sensitivity of A to
numerical operations such as inversion than the determinant.

The value is computed as the reciprocal of the product, 1-norm of A times
1-norm of A-inverse.

See also "det", "ldet", "onenorm".

# readfile
Output:     string
Argument:   fname (string)

If a file by the name of fname exists and is readable, returns a string
containing the content of this file, otherwise flags an error.

Also see the "sscanf" function.

# replace
Output:     same type as input
Arguments:  x (series or matrix)
            find (scalar or vector)
            subst (scalar or vector)

Replaces each element of x equal to the i-th element of find with the
corresponding element of subst.

If find is a scalar, subst must also be a scalar. If find and subst are both
vectors, they must have the same number of elements. But if find is a vector
and subst a scalar, then all matches will be replaced by subst.

Example:

	  a = {1,2,3;3,4,5}
	  find = {1,3,4}
	  subst = {-1,-8, 0}
	  b = replace(a, find, subst)
	  print a b

produces

          a (2 x 3)

            1   2   3 
            3   4   5 

          b (2 x 3)

            -1    2   -8 
            -8    0    5 

# resample
Output:     same type as input
Arguments:  x (series or matrix)
            b (scalar, optional)

Resamples from x with replacement. In the case of a series argument, each
value of the returned series, y_t, is drawn from among all the values of x_t
with equal probability. When a matrix argument is given, each row of the
returned matrix is drawn from the rows of x with equal probability.

The optional argument 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 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
Output:     same type as input
Argument:   x (scalar, series or matrix)

Rounds to the nearest integer. Note that when x lies halfway between two
integers, rounding is done "away from zero", so for example 2.5 rounds to 3,
but round(-3.5) gives -4. This is a common convention in spreadsheet
programs, but other software may yield different results. See also "ceil",
"floor", "int".

# rownames
Output:     scalar
Arguments:  M (matrix)
            s (named list or string)

Attaches names to the rows of the m x n matrix M. If s is a named list, the
row names are copied from the names of the variables; the list must have m
members. If s is a string, it should contain m space-separated sub-strings.
The return value is 0 on successful completion, non-zero on error. See also
"colnames".

# rows
Output:     scalar
Argument:   X (matrix)

Number of rows of the matrix X. See also "cols", "mshape", "unvech", "vec",
"vech".

# sd
Output:     scalar or series
Argument:   x (series or list)

If x is a series, returns the (scalar) sample standard deviation, skipping
any missing observations.

If x is a list, returns a series y such that y_t is the sample standard
deviation of the values of the variables in the list at observation t, or NA
if there are any missing values at t.

See also "var".

# sdc
Output:     row vector
Arguments:  X (matrix)
            df (scalar, optional)

Returns the standard deviations of the columns of X. If df is positive it is
used as the divisor for the column variances, otherwise the divisor is the
number of rows in X (that is, no degrees of freedom correction is applied).
See also "meanc", "sumc".

# sdiff
Output:     same type as input
Argument:   y (series or list)

Computes seasonal differences: y(t) - y(t-k), where k is the periodicity of
the current dataset (see "$pd"). Starting values are set to NA.

When a list is returned, the individual variables are automatically named
according to the template sd_varname where 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 "diff", "ldiff".

# selifc
Output:     matrix
Arguments:  A (matrix)
            b (row vector)

Selects from A only the columns for which the corresponding element of b is
non-zero. b must be a row vector with the same number of columns as A.

See also "selifr".

# selifr
Output:     matrix
Arguments:  A (matrix)
            b (column vector)

Selects from A only the rows for which the corresponding element of b is
non-zero. b must be a column vector with the same number of rows as A.

See also "selifc", "trimr".

# seq
Output:     row vector
Arguments:  a (scalar)
            b (scalar)
            k (scalar, optional)

Given only two arguments, returns a row vector filled with consecutive
integers, with a as first element and b last. If a is greater than 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 a and incremented (or decremented, if a is greater
than b) by k at each step. The final value is the largest member of the
sequence that is less than or equal to b (or mutatis mutandis for a greater
than b). The argument k must be positive; if it is not integral its
fractional part is discarded.

See also "ones", "zeros".

# sin
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the sine of x. See also "cos", "tan", "atan".

# sinh
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the hyperbolic sine of x.

See also "asinh", "cosh", "tanh".

# skewness
Output:     scalar
Argument:   x (series)

Returns the skewness value for the series x, skipping any missing
observations.

# sort
Output:     same type as input
Argument:   x (series or vector)

Sorts x in ascending order, skipping observations with missing values when x
is a series. See also "dsort", "values". For matrices specifically, see
"msortby".

# sortby
Output:     series
Arguments:  y1 (series)
            y2 (series)

Returns a series containing the elements of y2 sorted by increasing value of
the first argument, y1. See also "sort", "ranking".

# sqrt
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the positive square root of x; produces NA for negative values.

Note that if the argument is a matrix the operation is performed element by
element and, since matrices cannot contain NA, negative values generate an
error. For the "matrix square root" see "cholesky".

# sscanf
Output:     scalar
Arguments:  src (string)
            format (string)
            ... (see below)

Reads values from src under the control of 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 sscanf
function in the C programming language.

src may be either a literal string, enclosed in double quotes, or the name
of a predefined string variable. format is defined similarly to the format
string in "printf" (more on this below). args should be a comma-separated
list containing the names of pre-defined variables: these are the targets of
conversion from src. (For those used to C: one can prefix the names of
numerical variables with & but this is not required.)

Literal text in format is matched against src. Conversion specifiers start
with %, and recognized conversions include %f, %g or %lf for floating-point
numbers; %d for integers; %s for strings; and %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 * after the percent to suppress the conversion (thereby skipping any
characters that would otherwise have been converted for the given type). For
example, %3d converts the next 3 characters in source to an integer, if
possible; %*g skips as many characters in 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 %s conversion for strings, a simplified version of the C
format %N[chars] is available. In this format N is the maximum number of
characters to read and chars is a set of acceptable characters, enclosed in
square brackets: reading stops if N is reached or if a character not in
chars is encountered. The function of chars can be reversed by giving a
circumflex, ^, 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 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:

	  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

# sst
Output:     scalar
Argument:   y (series)

Returns the sum of squared deviations from the mean for the non-missing
observations in series y. See also "var".

# strlen
Output:     scalar
Argument:   s (string)

Returns the number of characters in s.

# strncmp
Output:     scalar
Arguments:  s1 (string)
            s2 (string)
            n (scalar, optional)

Compares the two string arguments and returns an integer less than, equal
to, or greater than zero if s1 is found, respectively, to be less than, to
match, or be greater than s2, up to the first n characters. If 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 if (s1 == s2) ...

# strsplit
Output:     string
Arguments:  s (string)
            i (scalar)

Returns space-separated element i from the string s. The index i is 1-based,
and it is an error if i is less than 1. In case s contains no spaces and i
equals 1, a copy of the entire input string is returned; otherwise, in case
i exceeds the number of space-separated elements an empty string is
returned.

# strstr
Output:     string
Arguments:  s1 (string)
            s2 (string)

Searches s1 for an occurrence of the string s2. If a match is found, returns
a copy of the portion of s1 that starts with s2, otherwise returns an empty
string.

# strsub
Output:     string
Arguments:  s (string)
            find (string)
            subst (string)

Returns a copy of s in which all occurrences of find are replaced by subst.

# sum
Output:     scalar or series
Argument:   x (series or list)

If x is a series, returns the (scalar) sum of the non-missing observations
in x.

If x is a list, returns a series y such that y_t is the sum of the values of
the variables in the list at observation t, or NA if there are any missing
values at t.

# sumc
Output:     row vector
Argument:   X (matrix)

Returns the sums of the columns of X. See also "meanc", "sumr".

# sumr
Output:     column vector
Argument:   X (matrix)

Returns the sums of the rows of X. See also "meanr", "sumc".

# svd
Output:     row vector
Arguments:  X (matrix)
            &U (reference to matrix, or null)
            &V (reference to matrix, or null)

Performs the singular values decomposition of the matrix X.

The singular values are returned in a row vector. The left and/or right
singular vectors U and V may be obtained by supplying non-null values for
arguments 2 and 3, respectively. For any matrix A, the code

	  s = svd(A, &U, &V) 
	  B = (U .* s) * V

should yield B identical to A (apart from machine precision).

See also "eigengen", "eigensym", "qrdecomp".

# tan
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the tangent of x.

# tanh
Output:     same type as input
Argument:   x (scalar, series or matrix)

Returns the hyperbolic tangent of x.

See also "atanh", "cosh", "sinh".

# toepsolv
Output:     column vector
Arguments:  c (vector)
            r (vector)
            b (vector)

Solves a Toeplitz system of linear equations, that is Tx = b where T is a
square matrix whose element T_i,j equals c_i-j for i>=j and r_j-i for i<=j.
Note that the first elements of c and r must be equal, otherwise an error is
returned. Upon successful completion, the function returns the vector x.

The algorithm used here takes advantage of the special structure of the
matrix 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 T
is nonsingular; this problem, however, cannot arise when T is positive
definite.

# tolower
Output:     string
Argument:   s (string)

Returns a copy of s in which any upper-case characters are converted to
lower case.

# tr
Output:     scalar
Argument:   A (square matrix)

Returns the trace of the square matrix A, that is, the sum of its diagonal
elements. See also "diag".

# transp
Output:     matrix
Argument:   X (matrix)

Returns the transpose of 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:
X'.

# trimr
Output:     matrix
Arguments:  X (matrix)
            ttop (scalar)
            tbot (scalar)

Returns a matrix that is a copy of X with ttop rows trimmed at the top and
tbot rows trimmed at the bottom. The latter two arguments must be
non-negative, and must sum to less than the total rows of X.

See also "selifr".

# uniform
Output:     series
Arguments:  a (scalar)
            b (scalar)

Generates a series of uniform pseudo-random variates in the interval (a, 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 Saito and
Matsumoto (2008).

See also "randgen", "normal", "mnormal", "muniform".

# uniq
Output:     column vector
Argument:   x (series or vector)

Returns a vector containing the distinct elements of x, not sorted but in
their order of appearance. See "values" for a variant that sorts the
elements.

# unvech
Output:     square matrix
Argument:   v (vector)

Returns an n x n symmetric matrix obtained by rearranging the elements of v.
The number of elements in v must be a triangular integer -- i.e., a number k
such that an integer n exists with the property k = n(n+1)/2. This is the
inverse of the function "vech".

See also "mshape", "vech".

# upper
Output:     square matrix
Argument:   A (square matrix)

Returns an n x n upper triangular matrix: the elements on and above the
diagonal are equal to the corresponding elements of A; the remaining
elements are zero.

See also "lower".

# urcpval
Output:     scalar
Arguments:  tau (scalar)
            n (scalar)
            niv (scalar)
            itv (scalar)

P-values for the test statistic from the Dickey-Fuller unit-root test and
the Engle-Granger cointegration test, as per James MacKinnon (1996).

The arguments are as follows: tau denotes the test statistic; n is the
number of observations (or 0 for an asymptotic result); niv is the number of
potentially cointegrated variables when testing for cointegration (or 1 for
a univariate unit-root test); and 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 n value of 0 to get an asymptotic result.

See also "pvalue".

# values
Output:     column vector
Argument:   x (series or vector)

Returns a vector containing the distinct elements of x sorted in ascending
order. If you wish to truncate the values to integers before applying this
function, use the expression values(int(x)).

See also "uniq", "dsort", "sort".

# var
Output:     scalar or series
Argument:   x (series or list)

If x is a series, returns the (scalar) sample variance, skipping any missing
observations.

If x is a list, returns a series y such that y_t is the sample variance of
the values of the variables in the list at observation t, or NA if there are
any missing values at t.

In each case the sum of squared deviations from the mean is divided by (n -
1) for n > 1. Otherwise the variance is given as zero if n = 1, or as NA if
n = 0.

See also "sd".

# varname
Output:     string
Argument:   v (scalar or list)

If given a scalar argument, returns the name of the variable with ID number
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
Output:     scalar
Argument:   varname (string)

Returns the ID number of the variable called varname, or NA is there is no
such variable.

# varsimul
Output:     matrix
Arguments:  A (matrix)
            U (matrix)
            y0 (matrix)

Simulates a p-order n-variable VAR, that is y(t) = A1 y(t-1) + ... + Ap
y(t-p) + u(t). The coefficient matrix A is composed by horizontal stacking
of the A_i matrices; it is n x np, with one row per equation. This
corresponds to the first n rows of the matrix $compan provided by gretl's
var and vecm commands.

The u_t vectors are contained (as rows) in U (T x n). Initial values are in
y0 (p x n).

If the VAR contains deterministic terms and/or exogenous regressors, these
can be handled by folding them into the U matrix: each row of U then becomes
u(t) = B' x(t) + e(t).

The output matrix has T + p rows and n columns; it holds the initial p
values of the endogenous variables plus T simulated values.

See also "$compan", "var", "vecm".

# vec
Output:     column vector
Argument:   X (matrix)

Stacks the columns of X as a column vector. See also "mshape", "unvech",
"vech".

# vech
Output:     column vector
Argument:   A (square matrix)

Returns in a column vector the elements of A on and above the diagonal.
Typically, this function is used on symmetric matrices; in this case, it can
be undone by the function "unvech". See also "vec".

# weekday
Output:     scalar
Arguments:  year (scalar)
            month (scalar)
            day (scalar)

Returns the day of the week (Sunday = 0, Monday = 1, etc.) for the date
specified by the three arguments, or NA if the date is invalid.

# wmean
Output:     series
Arguments:  Y (list)
            W (list)

Returns a series y such that y_t is the weighted mean of the values of the
variables in list Y at observation t, the respective weights given by the
values of the variables in list W at t. The weights can therefore be
time-varying. The lists Y and W must be of the same length and the weights
must be non-negative.

See also "wsd", "wvar".

# wsd
Output:     series
Arguments:  Y (list)
            W (list)

Returns a series y such that y_t is the weighted sample standard deviation
of the values of the variables in list Y at observation t, the respective
weights given by the values of the variables in list W at t. The weights can
therefore be time-varying. The lists Y and W must be of the same length and
the weights must be non-negative.

See also "wmean", "wvar".

# wvar
Output:     series
Arguments:  X (list)
            W (list)

Returns a series y such that y_t is the weighted sample variance of the
values of the variables in list X at observation t, the respective weights
given by the values of the variables in list W at t. The weights can
therefore be time-varying. The lists Y and W must be of the same length and
the weights must be non-negative.

See also "wmean", "wsd".

# xmax
Output:     scalar
Arguments:  x (scalar)
            y (scalar)

Returns the greater of x and y, or NA if either value is missing.

See also "xmin", "max", "min".

# xmin
Output:     scalar
Arguments:  x (scalar)
            y (scalar)

Returns the lesser of x and y, or NA if either value is missing.

See also "xmax", "max", "min".

# xpx
Output:     list
Argument:   L (list)

Returns a list that references the squares and cross-products of the
variables in list L. Squares are named on the pattern sq_varname and
cross-products on the pattern var1_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
Output:     same type as input
Argument:   x (scalar or series)

Converts zeros to NAs. If x is a series, the conversion is done element by
element. See also "missing", "misszero", "ok".

# zeros
Output:     matrix
Arguments:  r (scalar)
            c (scalar)

Outputs a zero matrix with r rows and c columns. See also "ones", "seq".