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

#
add
@Tests
Usage: add varlist
Examples: add 5 7 9 add xx yy zz
The variables in varlist are added to the previous model and the new model
estimated. If more than one variable is added, then the F statistic for the
added variables is printed (for the OLS procedure only) along with the
pvalue for it. A pvalue below 0.05 means that the coefficients are jointly
significant at the 5 percent level. A number of internal variables may be
retrieved using the genr command, provided genr is invoked immediately after
this command. Type help genr for more details on this.
#
addto
@Tests
Usage: addto model_ID varlist
Example: addto 2 5 7 9
Works like the "add" command, except that you specify a previous model (using
its ID number, which is printed at the start of the model output) to take as
the base for adding variables. The example above adds variables number 5, 7
and 9 to Model 2.
#
adf
@Tests
Usage: adf order varname
Example: adf 2 x1
Computes statistics for two DickeyFuller tests. In each case the null
hypothesis is that the variable in question exhibits a unit root.
The first is a ttest based on the model (1  L)x(t) = m + g * x(t1) + e(t).
The null hypothesis is that g = 0.
The second (augmented) test proceeds by estimating an unrestricted regression
(with regressors a constant, a time trend, the first lag of the variable, and
"order" lags of the first difference) and a restricted version (dropping the
time trend and the first lag). The test statistic is F, determined as
[(ESSr  ESSu)/2]/[ESSu/(T  k)]
where T is the sample size and k the number of parameters in the unrestricted
model. Note that the critical values for these statistics are not the usual
ones.
#
ar
@Estimation
Usage: ar lags ; depvar indepvar or
ar lags ; o depvar indepvar
Example: ar 1 3 4 ; y 0 x1 x2 x3
Computes the estimates of a model using the generalized CochraneOrcutt
iterative procedure (see Ramanathan, Section 9.5). Iteration is terminated
when successive error sum of squares do not vary by more than 0.005 percent
or when 20 iterations have been done. lags is a list of lags in the
residuals, terminated by a semicolon. In the above example, the error term
is specified as
u(t) = rho1 u(t1) + rho3 u(t3) + rho4 u(t4) + et
depvar is the dependent variable and indepvar is the list of independent
variables separated by spaces. Use the number zero for a constant term. If
the o flag is present, the covariance matrix of regression coefficients will
be printed. Residuals of the transformed regression are stored under the
name uhat, which can be retrieved by genr. A number of other internal
variables may be retrieved using the genr command, provided genr is invoked
immediately after this command. Type help genr for more details on this.
#
arch
@Tests
Usage: arch lag depvar indepvar
Examples: arch 4 1 0 2 4 6 7 or arch 4 y 0 x1 x2 x3 x4
This command tests the model for ARCH of the order specified in "lag", which
must be an integer. If the LM test statistic has pvalue below 0.10, then
ARCH estimation is also carried out. If the predicted variance of any
observation in the auxiliary regression is not positive, then the
corresponding uhat square is used instead. Weighted least square
estimation is then performed on the original model.
#
chow
@Tests
Usage: chow obs
Examples: chow 25
chow 1988.1
Must follow an OLS regression. Creates a dummy variable which equals 1
from the split point specified by "obs" to the end of the sample, 0
otherwise, and also creates interaction terms between this dummy and the
original independent variables. An augmented regression is run including
these terms and an F statistic is calculated, taking the augmented
regression as the unrestricted and the original as restricted. This
statistic is appropriate for testing the null hypothesis of no structural
break at the given split point.
#
coint
@Tests
Usage: coint order depvar indepvar
Examples: coint 2 y x
coint 4 y x1 x2
Carries out Augmented DickeyFuller tests on the null hypothesis that
each of the variables listed has a unit root, using the given lag order.
The cointegrating regression is estimated, and an ADF test is run on the
residuals from this regression. The DurbinWatson statistic for the
cointegrating regression is also given. Note that none of these test
statistics can be referred to the usual statistical tables.
#
corc
@Estimation
Usage: corc depvar indepvar or corc o depvar indepvar
Examples: corc 1 0 2 4 6 7 corc o 1 0 2 4 6 7
corc y 0 x1 x2 x3 corc o y 0 x1 x2 x3
Computes the estimates of a model using the CochraneOrcutt iterative
procedure (see Ramanathan, Section 9.4) with depvar as the dependent
variable and indepvar as the list of independent variables separated by
spaces and terminated by a ;. Use the number zero for a constant term.
Iteration is terminated when successive rho values do not differ by more
than 0.001 or when 20 iterations have been done. If the o flag is
present, the covariance matrix of regression coefficients is printed.
The final transformed regression is performed for the observation range
stobs+1 endobs currently in effect. Residuals of this transformed
regression are stored under the name uhat. A number of other internal
variables may be retrieved using the genr command, provided genr is invoked
immediately after this command. Type help genr for more details on this.
#
corr
@Statistics
Usage: corr
corr varlist
corr prints correlation coefficients for all pairs of variables in the data
set (missing values denoted by 999 are skipped). corr varlist prints
correlation coefficients for the listed variables.
#
corrgm
@Statistics
Usage: corrgm varname or varnumber
corrgm varname or varnumber maxlag
Prints the values of the autocorrelation function for the variable specified
(see Ramanathan, Section 11.7). It is thus cor[u(t), u(ts)], where u(t) is
the tth observation of the variable u and s is the number of lags. The
partial autocorrelations are also shown: these are net of the effects of
intervening lags. The command also graphs the correlogram and prints the
BoxPierce Q statistic for testing the null hypothesis that the series is
"white noise". This is asymptotically distributed as chisquare with degrees
of freedom equal to the number of lags used.
If an integer maxlag value is supplied the length of the correlogram is
limited to at most that number of lags, otherwise the length is determined
automatically.
#
criteria
@Utilities
Usage: criteria ess T k e.g. criteria 23.45 45 8
Computes the model selection statistics (see Section 4.4 of Ramanathan),
given ess (error sum of squares), the number of observations (T), and the
number of coefficients (k). T, k, and ess may be numerical values or names
of previously defined variables.
#
critical
@Utilities
Usage: critical t df e.g. critical t 20
critical X df e.g. critical X 5
critical F dfn dfd e.g. critical F 3 37
critical d n e.g. critical d 24
If the first parameter is t, X or F, prints out the critical values for the
students's t, chisquare or F distribution respectively, for the common
significance levels and using the specified degrees of freedom. If the first
parameter is d, prints the upper and lower values of the DurbinWatson
statistic at 5 percent significance, for the given n (number of observations),
and for the range of 1 to 5 explanatory variables.
#
cusum
@Tests
Usage: cusum
Must follow the estimation of a model via OLS. Performs the CUSUM test for
parameter stability. A series of (scaled) onestep ahead forecast errors is
obtained by running a series of regressions: the first regression uses the
first k observations and is used to generate a prediction of the dependent
variable at observation at observation k + 1; the second uses the first k + 1
observations and generates a prediction for observation k + 2, and so on
(where k is the number of parameters in the original model). The cumulated
sum of the scaled forecast errors is printed and graphed. The null hypothesis
of parameter stability is rejected at the 5 percent significance level if the
cumulated sum strays outside of the 95 percent confidence band.
The HarveyCollier tstatistic for testing the null hypothesis of parameter
stability is also quoted. See Chapter 7 of Greene's Econometric Analysis for
details.
#
delete
@Dataset
Usage: delete
Removes the last (highest numbered) variable from the current data set. Use
with caution: no confirmation is asked. Can be useful for getting rid of
temporary dummy variables. There is no provision for deleting any but the
last variable.
#
diff
@Transformations
Usage: diff varlist
The first difference of each variable in varlist is obtained and the
result stored in a new variable with the prefix "d_". Thus "diff x y"
creates the new variables d_x = x(t)  x(t1) and d_y = y(t)  y(t1).
#
endloop
@Programming
Terminates a simulation loop. See "loop".
#
eqnprint
@Printing
Usage: eqnprint
eqnprint o
Must follow the estimation of a model via OLS. Prints the estimated model
in the form of a LaTeX equation, to a file with a name of the form
"equation_N.tex", where N is the number of models estimated to date in the
current session. This can be incorporated in a LaTeX document. See also
the tabprint command.
If the o flag is given the LaTeX file is a complete document, ready
for processing; otherwise it must be included in a document.
#
fcast
@Prediction
Usage: fcast startobs endobs newvarname
fcast newvarname
Example: fcast fitted
Fitted values are retrieved from the last regression run and saved as
newvarname. These values can be printed, graphed, or plotted. The
righthand side variables are those in the original model. There is no
provision to substitute other variables. If starting and ending
observations are specified the forecast is restricted to the given range.
If an autoregressive error process is specified (for hilu, corc, and ar)
the forecast is conditional one step ahead and incorporates the error
process.
#
fcasterr
@Prediction
Usage: fcasterr startobs endobs
fcasterr startobs endobs o
After estimating an OLS model which includes a constant and at least
one independent variable (these restrictions may be relaxed at some
point) you can use this command to print out fitted values over the
specified observation range, along with the estimated standard errors of
those predictions and 95 percent confidence intervals. If the o flag
is given the results will also be displayed using gnuplot.
#
fit
@Prediction
Usage: fit
The fit command (which must follow an estimation command) is a shortcut
for the fcast command. It generates fitted values, in a series called
"autofit", for the current sample, based on the last regression. In the
case of timeseries models, fit also pops up a gnuplot graph of fitted
and actual values of the dependent variable against time (if support
for gnuplot was compiled in).
#
freq
@Statistics
Usage: freq varname (or varno)
Prints the frequency distribution for varname or varno; the results of a
Chisquare test for normality are also reported. The statistic for
the latter is
sample_size * [skewness^2/6 + (kurtosis  3.0)^2/24.0]
It has 2 degrees of freedom.
In interactive mode a gnuplot graph of the distribution is generated.
#
genr
@Dataset
Usage: genr newvarname = formula
Creates new variables, usually through transformations of existing
variables. See also diff, logs, lags, ldiff, multiply and square for
shortcuts.
Supported arithmetical operators are, in order of precedence: ^
(exponentiation); *, / and % (modulus or remainder); + and .
Boolean operators (again in order of precedence) are ! (logical NOT), &
(logical AND),  (logical OR), >, <, = and != (NOT EQUALS). The Boolean
operators can be used in constructing dummy variables: for instance (x > 10)
returns 1 if x(t) > 10, 0 otherwise.
Supported functions fall into these groups: Standard math functions: abs, cos,
exp, int (integer part), ln (natural log: log is a synonym), sin, sqrt.
Statistical functions: mean (arithmetic mean), median, var (variance), sd
(standard deviation), sum, cov (covariance), corr (correlation coefficient).
Timeseries functions: lag, lead, diff (first difference), ldiff
(logdifference, or first difference of natural logs). Miscellaneous: cum
(cumulate), sort, uniform, normal, misszero (replace the missing
observation code with zero), zeromiss (inverse operation of misszero), and
pvalue (probability value for a given statistic against a specified
distribution).
All of the above functions with the exception of cov, corr, uniform, normal
and pvalue take as their single argument either the name of a variable (note
that you can't refer to variable by their ID numbers in a genr command) or a
composite expression that evaluates to a variable (e.g. ln((x1+x2)/2)). cov
and corr both require two arguments, and return respectively the covariance
and the correlation coefficient between two named variables. uniform() and
normal(), which do not take arguments, return pseudorandom series drawn from
the uniform (0100) and standard normal distributions respectively (see also
the seed command). The pvalue() function takes the same arguments as the
pvalue command (see below), but in this context commas should be placed
between the arguments.
Besides the operators and functions just noted there are some special
uses of genr:
* genr time creates a time trend variable (1,2,3,...) called time.
* genr index creates an index variable (1,2,3,...) called index.
* genr dummy creates dummy variables up to the periodicity of the data.
E.g. in the case of quarterly data (periodicity 4), the program creates
dummy_1 = 1 for first quarter and 0 in other quarters, dummy_2 = 1 for the
second quarter and 0 in other quarters, and so on.
* genr paneldum creates a set of special dummy variables for use with a panel
data set (see the gretl manual for details)
* Various internal variables defined in the course of running a regression can
be retrieved using genr, as follows:
$ess error sum of squares
$rsq unadjusted Rsquared
$nobs number of observations
$df degrees of freedom
$trsq TR^2 (sample size times Rsquared)
$sigma standard error of residuals
$lnl loglikelihood (logit and probit models)
coeff(var) estimated coefficient for var
stderr(var) estimated std. error for var
rho(i) ith order autoregressive coefficient for residuals
vcv(xi,xj) covariance between coefficients for vars xi and xj
The internal variable t references the observations, starting at 1. Thus one
can do "genr dum15 = (t=15)" to generate a dummy variable with value 1 for
observation 15, 0 otherwise.
Examples of genr commands:
genr y = x1^3 [x1 cubed]
genr y=ln((x1+x2)/x3) [composite argument to ln function]
genr z=x>y [sets z(t) to 1 if x(t) > y(t) else to 0]
genr y=x(2) [x lagged 2 periods]
genr y=x(2) [x led 2 periods]
genr y = mean(x) [arithmetic mean]
genr y = diff(x) [y(t) = x(t)  x(t1)]
genr y = ldiff(x) [y = ln(x(t))  ln(x(t1))]
ldiff(x) is the instantaneous rate of growth of x.
genr y = sort(x) [sort x in increasing order and store in y]
genr y =  sort(x) [sort x in decreasing order]
genr y = int(x) [truncate x and store its integer value as y]
genr y = abs(x) [store the absolute values of x]
genr y = sum(x) [sum x values excluding missing 999 entries]
genr y = cum(x) [cumulate x: y(t) is the sum of x up to t]
genr aa = $ess [aa = Error Sum of Squares from last regression]
genr x = coeff(sqft) [grab sqft coefficient from last model]
genr rho4 = rho(4) [grab 4thorder autoregressive coeff. from last
model (presumes an ar model)]
genr cv=vcv(x1, x2) [covariance of x1 and x2 coeffs. in last model]
genr x=uniform()/100 [uniform pseudorandom variable, range 0 to 1]
genr x=3*normal() [normal pseudorandom var, mean 0, std. dev. 3]
genr x=pvalue(t,20,1.4) [pvalue for 1.4, under the t distribution with
20 degrees of freedom]
Tips on dummy variables:
* Suppose x is coded with values 1, 2, or 3 and you want three dummy
variables, d1 = 1 if x = 1, 0 otherwise, d2 = 1 if x = 2, and so on. To
create these, use the commands: genr d1 = (x=1), genr d2 = (x=2), and
genr d3 = (x=3).
* To get z = max(x,y) do genr d=x>y and genr z=(x*d)+(y*(1d))
#
gnuplot
@Graphs
Usage: gnuplot yvar1 xvar [ flag ]
gnuplot yvar1 yvar2 xvar [ flag ]
gnuplot yvar xvar dummy z
In the first two cases the yvars are graphed against xvar. If the flag o is
supplied the plot will use lines; if the flag m is given the plot uses
impulses (vertical lines); otherwise points will be used.
In the third case yvar is graphed against xvar with the points shown in
different colors depending on whether the value of "dummy" is 1 or 0.
To make a timeseries graph, do "gnuplot yvars time". If no variable named
"time" already exists, then it will be generated automatically. Special dummy
variables will be created for plotting quarterly and monthly data.
In interactive mode the result is piped to gnuplot for display. In batch mode
a file named gpttmp<n>.plt is written out, where <n> is a number from 01 to
99. The plots can be generated later using the shell command "gnuplot
gpttmp<n>.plt".
#
graph
@Graphs
Usage: graph var1 var2
graph o var1 var2
graph var1 var2 var3
In the first two examples, variable var1 (which may be a name or a number)
is graphed (yaxis) against var2 (xaxis). o flag will graph with 40 rows
and 60 columns. Without it, the graph will be 20 by 60 (for screen output).
In the third example, both var1 and var2 will be graphed (on yaxis) against
var3. This is particularly useful to graph observed and predicted values
against time.
#
hausman
@Tests
Usage: hausman
This test is available only after estimating a model using the "pooled"
command (see also the commands panel and setobs). It tests the simple pooled
model against the principal alternatives, the fixed effects and random effects
models.
The fixed effects model adds a dummy variable for all but one of the
crosssectional units, allowing the intercept of the regression to vary across
the units. An Ftest for the joint significance of these dummies is
presented. The random effects model decomposes the residual variance into two
parts, one part specific to the crosssectional unit and the other specific to
the particular observation. (This estimator can be computed only if the
number of crosssectional units in the data set exceeds the number of
parameters to be estimated.) The BreuschPagan LM statistic tests the null
hypothesis (that the pooled OLS estimator is adequate) against the random
effects alternative.
The pooled OLS model may be rejected against both of the alternatives, fixed
effects and random effects. Provided the unit or groupspecific error is
uncorrelated with the independent variables, the random effects estimator is
more efficient than the fixed effects estimator; otherwise the random effects
estimator is inconsistent and the fixed effects estimator is to be preferred.
The null hypothesis for the Hausman test is that the groupspecific error is
not so correlated (and therefore the random effects model is preferable). A
low pvalue for this test counts against the random effects model and in
favor of fixed effects.
#
hccm
@Estimation
Usage: hccm depvar indepvar
or hccm o depvar indepvar
Presents OLS estimates with the heteroscedasticity consistent covariance
matrix estimates for the standard errors of regression coefficients using
the MacKinnonWhite "jacknife" procedure.
#
help
@Utilities
help gives a list of esl commands
help commandname describes commandname (e.g. help smpl)
#
hilu
@Estimation
Usage: hilu depvar indepvar or hilu o depvar indepvar
Examples: hilu 1 0 2 4 6 7 hilu o 1 0 2 4 6 7
hilu y 0 x1 x2 x3 hilu o y 0 x1 x2 x3
Computes the estimates of a model using the HildrethLu search
procedure (fine tuned by the CORC procedure) with depvar as the dependent
variable and indepvar as the list of independent variables separated by
spaces. Use the number zero for a constant term. The error sum of squares
of the transformed model is graphed against the value of rho from 0.99 to
0.99. If the o flag is present, the covariance matrix of regression
coefficients will be printed. The final transformed regression is
performed for the observation range stobs+1 endobs currently in effect.
Residuals of this transformed regression are stored under the name uhat. A
number of internal variables may be retrieved using the genr command,
provided genr is invoked immediately after this command. Type help genr
for more details on this.
#
hsk
@Estimation
Usage: hsk depvar indepvar
or hsk o depvar indepvar
Prints heteroscedasticity corrected estimates and associated statistics.
The auxiliary regression predicts the log of the square of residuals (using
squares of independent variables but not their cross products) from which
weighted least squares estimates are obtained. If the o flag is present,
the covariance matrix of regression coefficients will be printed. A number
of internal variables may be retrieved using the genr command, provided genr
is invoked immediately after this command. Type help genr for more details
on this.
#
import
@Dataset
Usage: import csv_file
import o box_file
Without the o flag, brings in data from a commaseparated values (CSV) format
file, such as can easily be written from a spreadsheet program. The file
should have variable names on the first line and a rectangular data matrix on
the remaining lines. Variables should be arranged "by observation" (one
column per variable; each row represents an observation).
With the o flag, reads a data file in BOX1 format, as can be obtained using
the Data Extraction Service of the US Bureau of the Census.
#
info
@Dataset
Usage: info
Prints out any information contained in the header file corresponding
to the current datafile. This information must be enclosed between
"(*" and "*)", these markers being placed on separate lines.
#
labels
@Dataset
Usage: labels
Prints out the informative labels for any variables that have been
generated using the "genr" command.
#
lags
@Transformations
Usage: lags varlist
Creates new variables which are lagged values of each of the variables in
varlist. The number of lagged variables equals the periodicity. For
example, if the periodicity was 4 (quarterly), the command lags x y ; will
create x_1 = x(1), x_2 = x(2), x_3 = x(3) and x_4 = x(4). Similarly
for y. These variables must be referred to in the exact form, that is,
with the underscore.
#
ldiff
@Transformations
Usage: ldiff varlist
The first difference of the natural log of each variable in varlist is
obtained and the result stored in a new variable with the prefix "ld_".
Thus "ldiff x y" creates the new variables
ld_x = ln[x(t)]  ln[x(t1)]
ld_y = ln[y(t)]  ln[y(t1)].
#
lmtest
@Tests
Usage: lmtest
lmtest o
Must immediately follow an ols command. Prints the Lagrange multiplier test
statistics (and associated pvalues) for nonlinearity and heteroscedasticity
(White's test) or, if the o flag is present, for serial correlation up to the
periodicity. The corresponding auxiliary regression coefficients are also
printed out. See Chapters 7, 8, and 9 of Ramanathan for details.
Only the squared independent variables are used and not their cross products.
If the internal creation of squares causes exact multicollinearity, LM test
statistics cannot be obtained.
#
logit
@Estimation
Usage: logit depvar indepvars
Logit regression. The dependent variable should be a binary variable. Maximum
likelihood estimates of the coefficients on indepvars are obtained via
interated least squares (the EM or ExpectationMaximization method). As the
model is nonlinear the slopes depend on the values of the independent
variables: the reported slopes are evaluated at the means of those variables.
The Chisquare statistic tests the null hypothesis that all coefficients are
zero apart from the constant.
#
logs
@Transformations
Usage: logs varlist
The natural log of each of the variables in varlist is obtained and the
result stored in a new variable with the prefix l_ which is "el" underscore.
Thus, "logs x y" creates the new variables l_x = ln(x) and l_y = ln(y).
#
loop
@Programming
Usage: loop number_of_times
loop while condition
loop for i=start..end
Examples: loop 1000
loop while essdiff > .00001
loop for i=1991..2000
This (script) command opens a special mode in which the program accepts
commands to be repeated either a specified number of times, or so long as a
specified condition holds true, or for successive integer values of the
(internal) index variable i. Within a loop, only six commands can be used:
genr, ols, print, smpl, store and summary (store can't be used in a "while"
loop). With genr and ols it is possible to do quite a lot. You exit the mode
of entering loop commands with "endloop": at this point the stacked commands
are executed. Loops cannot be nested.
The ols command gives special output, depending on the sort of loop. If a
number of times is specified the results from each individual regression are
not printed, but rather you get a printout of (a) the mean value of each
estimated coefficient across all the repetitions, (b) the standard devation of
those coefficent estimates, (c) the mean value of the estimated standard error
for each coefficent, and (d) the standard devation of the estimated standard
errors. This makes sense only if there is some random input at each step.
The command is designed for Monte Carlo analysis. If a "while" condition is
given, you get a printout of the specified model from the last time round the
loop: this is designed for iterated least squares.
The print command also behaves differently in the context of a "number of
times" loop. It prints the mean and standard deviation of the variable,
across the repetitions of the loop. It is intended for use with variables
that have a single value at each iteration, for example the ess from a
regression. The print command behaves as usual with the other loop
constructions.
The store command (use only one of these per loop, and only in a "number
of times" loop) writes out the values of the specified variables, from
each time round the loop, to the specified file. Thus it keeps a complete
record of the variables. This data file can then be read into the program
and analysed.
Example of loop code (Monte Carlo):
genr x = uniform()
loop 100
genr u = normal()
genr y = (10*x) + (20*u)
ols y const x
genr r2 = $rsq
print r2
genr a = coeff(const)
genr b = coeff(x)
store foo.gdt a b
endloop
#
meantest
@Tests
Usage: meantest x1 x2
meantest x1 x2 o
Calculates the t statistic for the null hypothesis that the population means
are equal for the variables x1 and x2, and shows its pvalue. Without the o
flag, the statistic is computed on the assumption that the variances are equal
for the two variables; with the o flag the variances are assumed to be
unequal. (The flag will make a difference only if there are different numbers
of nonmissing observations for the two variables.)
#
multiply
@Transformations
Usage: multiply x suffix vars
Examples: multiply invpop pc 3 4 5 6
multiply 1000 big x1 x2 x3
The variables in the list "vars" (referenced by name or number) are
multiplied by x, which may be either a numerical value or the name of a
variable already defined. The products are named with the specified suffix
(maximum 3 characters). The original varnames are truncated first if need
be. For instance, suppose you want to create per capita versions of certain
variables, and you have the variable "pop" (population). A suitable set of
commands is then:
genr invpop = 1/pop
multiply invpop pc income expend
which will create incomepc = income * invpop, expendpc = expend * invpop.
#
nulldata
@Dataset
Usage: nulldata series_length
Example: nulldata 100
Establishes a "blank" data set, containing only a constant, with
periodicity 1 and the specified number of observations. This may be used
for simulation purposes: some of the genr commands (e.g. genr uniform(),
genr normal(), genr time) will generate dummy data from scratch to fill out
the data set. The nulldata command may be useful in conjunction with
"loop".
#
ols
@Estimation
Usage: ols depvar indepvar or ols o depvar indepvar
Examples: ols 1 0 2 4 6 7 ols o 1 0 2 4 6 7
ols y 0 x1 x2 x3 ols o y 0 x1 x2 x3
Computes ordinary least squares estimates with depvar as the dependent
variable and indepvar as the list of independent variables.
The o flag will print the covariance matrix of regression coefficients. The
variables can be specified either by names or by their number. Use the
number zero for a constant term. The program also prints the pvalues for t
(twotailed) and Fstatistics. A pvalue below 0.01 indicates significance
at the 1 percent level and is denoted by three *'s. Two *'s indicate
significance between 1 and 5 percent and one * indicates significance between
5 and 10 percent levels. Model selection statistics described in Section 4.4
are also printed. A number of internal variables may be retrieved using the
genr command, provided genr is invoked immediately after this command. Type
help genr for more details on this.
#
omit
@Tests
Usage: omit varlist
Examples: omit 5 7 9
omit xx yy zz
Must be invoked immediately after an ols, corc, hilu, ar, arch, hsk, wls,
hccm, add, omit, list, or genr command. The variables in varlist will be
omitted from the previous model and the new model estimated. If more than one
variable is omitted, the Wald Fstatistic for the omitted variables will be
printed along with the pvalue for it (for the OLS procedure only). A pvalue
below 0.05 means that the coefficients are jointly significant at the 5
percent level. A number of internal variables may be retrieved using the genr
command, provided genr is invoked immediately after this command. Type help
genr for more details on this.
#
omitfrom
@Tests
Usage: omitfrom model_ID varlist
Example: omitfrom 2 5 7 9
Works like the "omit" command, except that you specify a previous model (using
its ID number, which is printed at the start of the model output) to take as
the base for omitting variables. The example above omits variables number 5,
7 and 9 from Model 2.
#
open
@Dataset
Usage: open datafile
Opens a data file. If a data file is already open, it is replaced by the
newly opened one. The program will try to detect the format of the data file
("native", CSV or BOX1) and treat it accordingly.
#
panel
@Dataset
Usage: panel
panel s
panel c
Request that the current data set be interpreted as a panel (pooled cross
section and time series). With no flag, or with the s flag, the data set is
taken to be in the form of stacked time series (successive blocks of data
contain time series for each crosssectional unit). With the c flag, the
data set is read as stacked crosssections (successive blocks contain cross
sections for each time period). Also see the setobs command.
#
pergm
@Statistics
Usage: pergm varname
pergm varname o
Computes and displays (and if not in batch mode, graphs) the spectrum of the
specified variable. Without the o flag the sample periodogram is given; with
the flag a Bartlett lag window of length 2 * sqrt(sample size) is used in
estimating the spectrum (see Chapter 18 of Greene's Econometric Analysis).
When the sample periodogram is printed, a ttest for fractional integration of
the series ("long memory") is also given: the null hypothesis is that the
integration order is zero.
#
plot
@Graphs
Usage: plot x1 plot x1 x2
plot 3 7 plot o x1 x2
Plots data values for specified variables, for the range of observations
currently in effect. Each line stands for an observation and the values are
plotted horizontally. If the flag o is present, x1 and x2 are plotted in the
same scale, otherwise x1 and x2 are scaled appropriately. The o flag should
be used only if the variables have approximately the same range of values
(e.g. observed and predicted dependent variable).
#
pooled
@Estimation
Usage: pooled depvar indepvars
Estimates a model via OLS (see the ols command for details on syntax), and
flags it as a pooled or panel model, so that the "panel diagnostics" test item
becomes available. For an account of these diagnostics see the hausman
command.
#
print
@Printing
Prints the values of the specified variables for the current stobsendobs
range.
print prints the entire data set in tabular form
print 3 6 prints values of variable numbers 3 and 6
print x y z prints values of variables named x, y and z
If the o flag is given, the variables are printed in columns, otherwise they
are printed in consecutive blocks.
#
probit
@Estimation
Usage: probit depvar indepvars
Probit regression. The dependent variable should be a binary variable.
Maximum likelihood estimates of the coefficients on indepvars are obtained via
interated least squares (the EM or ExpectationMaximization method). As the
model is nonlinear the slopes depend on the values of the independent
variables: the reported slopes are evaluated at the means of those variables.
The Chisquare statistic tests the null hypothesis that all coefficients are
zero apart from the constant.
#
pvalue
@Utilities
Usage interactively: pvalue
Usage in batch mode (or gretl console mode):
Normal distribution: pvalue 1 xvalue
tdistribution: pvalue 2 d.f. xvalue
Chisquare: pvalue 3 d.f. xvalue
Fdistribution: pvalue 4 dfn dfd xvalue
Gamma distribution: pvalue 5 mean variance xvalue
Computes the area to the right of xvalue in the specified distribution. d.f.
is the degrees of freedom, dfn is the d.f. for the numerator, dfd is the d.f.
for the denominator.
#
quit
@Utilities
Exit from esl. ('q' is a shortcut; 'x' exits without a prompt to save
output.)
#
rhodiff
@Transformations
Usage: rhodiff rholist ; varlist
Examples: rhodiff .65 ; 2 3 4
rhodiff r1 r2 ; x1 x2 x3
Creates rhodifferenced counterparts of the variables (given by number or by
name) in varlist and adds them to the data set, using the suffix # for the new
vars. Given variable v1 in varlist, and entries r1 and r2 in rholist,
v1# = v1(t)  r1*v1(t1)  r2*v1(t2)
is created. The rholist entries can be given as numerical values or as the
names of variables previously defined.
#
run
@Programming
Usage: run inputfile
If the file "inputfile" contains esl commands, this command (invoked
from within esl) will execute them one by one. This is a useful way of
executing batch commands within an interactive session.
#
runs
@Tests
Usage: runs varname
Carries out the nonparametric runs test for randomness of the specified
variable. If you want to test for randomness of deviations from the median,
for a variable named x1 with a nonzero median, you can do the following:
genr signx1 = x1  median(x1)
runs signx1
#
scatters
@Graphs
Usage: scatters yvar ; xvarlist or
scatters yvarlist ; xvar
Examples: scatters 1 ; 2 3 4 5
scatters 1 2 3 4 5 6 ; time
Plots (using gnuplot) pairwise scatters of yvar against all the variables in
xvarlist, or of all the variables in yvarlist against xvar. The first
example above puts variable 1 on the yaxis and draws four graphs, the first
having variable 2 on the xaxis, the second variable 3 on the xaxis, and so
on. Scanning a set of such plots can be a useful step in exploratory data
analysis. The maximum number of plots is six; any extra variable in the list
will be ignored.
#
seed
@Programming
Usage: seed integer
Sets the seed for the pseudorandom number generator for the uniform() and
normal() functions (see the genr command). By default the seed is set
when the program is started, using the system time. If you want to
obtain repeatable sequences of pseudorandom numbers you will need to
set the seed manually.
#
setobs
@Dataset
Usage: setobs periodicity startobs
Examples: setobs 4 1990.1
setobs 12 1978.03
setobs 20 1.01
Use this commmand to force the program to interpret the current data set as
time series or panel, when the data have been read in as simple undated
series. "periodicity" must be an integer; "startobs" is a string representing
the date or panel ID of the first observation. Use one digit after the point
in "startobs" for data with periodicity less than 10, two digits (with a
leading zero if necessary) for periodicity from 10 to 99.
In the case of daily data a special form of the "startobs" string is required,
namely a date on the pattern YY/MM/DD, for example "55/02/15" if the data
start on the 15th of February, 1955. If the YY part is less than 50 the year
is assumed to be in the 21st century, otherwise it is assumed to be in the
20th century. (With daily data, periodicity 5 and 7 are both acceptable.)
#
setmiss
@Dataset
Usage: setmiss 1
setmiss xvar 100
Use this command to get the program to interpret some specific numerical data
value (the first parameter to the command) as a code for "missing", in the
case of imported data. If this value is the only parameter, as in the first
example above, the interpretation will be applied to all series in the data
set. If the missing numeric value code is followed by a list of variables, by
name or number, the interpretation is confined to the specified variable(s).
Thus in the second example the value 100 is interpreted as "missing", but only
for the variable named xvar.
#
shell
@Utilities
Usage: ! [shell command]
A "!" at the beginning of an gretl command line is interpreted as an escape
to the user's shell. Thus arbitrary shell commands can be executed from
within gretl.
#
sim
@Dataset
Usage: sim stobs endobs y a0 a1 a2 ...
Simulates values for y for the periods stobs through endobs. The variable y
must have been defined earlier with appropriate initial values. Also stobs
and endobs must be consistent with the periodicity. The formula used is
y(t) = a0(t) + a1(t)*y(t1) + a2(t)*y(t2) + ...
ai(t) may either be constants or variable names previously defined.
Examples:
sim 1979.2 1983.1 y 0 0.9 [generates y(t) = 0.9*y(t1)]
sim 15 25 y 10 0.8 x [generates y(t) = 10 + 0.8*y(t1) + x(t)*y(t2)]
#
smpl
@Dataset
Usage: smpl startobs endobs
smpl o dummyvar
smpl o
smpl r <boolean expression>
Resets the sample range. In the first form startobs and endobs must be
consistent with the periodicity of the data. In the second form, dummyvar
must be an indicator variable with values 0 or 1: the sample will be
restricted to those observations where the indicator value is 1. The
third form, smpl o, drops all observations for which values of one or more
variables are missing. The fourth form, using the r flag, restricts the
sample to cases satisfying the given expression.
smpl 3 10 for data with periodicity 1
smpl 1950 1990 for annual data with periodicity 1
smpl 1960.2 1982.4 for quarterly data
smpl 1960.04 1985.10 for monthly data
smpl 1960.2 ; to keep endobs unchanged
smpl ; 1984.3 to keep startobs unchanged
smpl o dum1 to create a sample based on "dum1"
smpl r sqft>1400 sample cases in which the variable sqft has
a value greater than 1400
One point should be noted about the "o" and "r" forms of smpl: any
"structural" information in the data header file (regarding the time series or
panel nature of the data) is lost when this command is issued. You may
reimpose structure with the "setobs" command.
#
spearman
@Statistics
Usage: spearman x y
spearman x y o
Prints Spearman's rank correlation coefficient for the two variables x and y.
The variables do not have to be ranked manually in advance; the function takes
care of this. If the o flag is supplied, the original data and the ranked
data are printed out side by side.
The automatic ranking is from largest to smallest (i.e. the largest data value
gets rank 1). If you need to invert this ranking, create a new variable which
is the negative of the original first. For example:
genr altx = x
spearman altx y
#
square
@Transformations
Usage: square x y or square o x y
Generates new variables which are squares and cross products of selected
variables (o will create the cross products). For the above example, new
variables created will be sq_x = x squared, sq_y = y squared and x_y = x
times y. If a particular variable is a dummy variable it is not squared
because we will get the same variable.
#
store
@Dataset
Usages: store filename flag
store filename flag varlist
Examples: store mydata.gdt
store mydata.csv c
store mydatabin.gdt o 2 3 4
Filename is the name of the file in which the values should be stored. If
varlist is absent, the values of all the variables will be stored, otherwise
only those variables specified will be written to file.
Possible values of the optional "flag" are as follows:
none: data are saved in gretl xml format
z : as above, but using gzip data compression
o : data saved as binary, in double precision
s : data saved as binary, in single precision
c : data saved in commaseparated values format, which can be read
directly by spreadsheet programs
r : data are stored in the native format of GNU R. They can be loaded
using the R command 'source()'.
m : data are stored in the native format of GNU Octave. The first
variable cited is taken to be the dependent variable, and is written
out as a column vector; the remaining data are written as a matrix
named 'X', with one variable per column.
t : data saved in "traditional" gretl format, as in Ramanathan's ESL,
with an ascii data file plus a "header" file.
#
summary
@Statistics
summary prints summary statistics for all variables in the file
summary 3 7 9 prints summary statistics for variable numbers 3, 7, and 9
summary x y z prints summary statistics for the variables x, y, and z
Output consists of the mean, standard deviation (sd), coefficient of variation
(CV = sd/mean), median, minimum, maximum, skewness coefficient, and excess
kurtosis.
#
tabprint
@Printing
Usage: tabprint
tabprint o
Must follow the estimation of a model via OLS. Prints the estimated model
in the form of a LaTeX tabular environment, to a file with a name of the
form "model_N.tex", where N is the number of models estimated to date in
the current session. This can be incorporated in a LaTeX document. See
also the eqnprint command.
If the o flag is given the LaTeX file is a complete document, ready
for processing; otherwise it must be included in a document.
#
testuhat
@Tests
Usage: testuhat
Must follow a model estimation command. Gives the frequency distribution for
the residual from the model along with a chisquare test for normality.
#
tsls
@Estimation
Usage: tsls depvar varlist1 ; varlist2 [o is optional]
Example: tsls y1 0 y2 y3 x1 x2 ; 0 x1 x2 x3 x4 x5 x6
This command computes twostage least squares (tsls) estimates of parameters.
depvar is the dependent variable, varlist1 is the list of independent
variables (including righthand side endogenous variables) in the structural
equation for which tsls estimates are needed. varlist2 is the combined list
of exogenous and predetermined variables in all the equations. If varlist2 is
not at least as long as varlist1, the model is not identified. The o flag
will print the covariance matrix of the coefficients. In the above example,
the y's are the endogenous variables and the x's are the exogenous and
predetermined variables. A number of internal variables may be retrieved
using the genr command, provided genr is invoked immediately after this
command. Type help genr for more details on this.
#
var
@Estimation
Usage: var order depvar indepvar
Examples: var 4 x1 const time x2 x3
var 3 1 0 2 3 4
Sets up and estimates (via OLS) a vector autoregression. The first
argument specifies the lag order, then follows the setup for the first
equation, much as in the "ols" command. Don't include lags among the
elements of the "indepvar" list  they will be added automatically. A
regression will be run for each variable in the list, excluding the
constant, the time trend and any dummy variables. Output for each
equation includes Ftests for zero restrictions on all lags of each of the
variables, and an Ftest for the maximum lag.
#
varlist
@Dataset
Usage: varlist
Prints a complete list of variables currently defined. "list" and "ls" are
synonyms.
#
vartest
@Tests
Usage: vartest x1 x2
Calculates the F statistic for the null hypothesis that the population
variances for the variables x1 and x2 are equal, and shows its pvalue.
#
wls
@Estimation
Usage: wls weightvar depvar indepvar [o optional]
Weighted least squares estimates are obtained using weightvar as the weight,
depvar as the dependent variable and indepvar as the list of independent
variables. More specifically, ols regression is run on weightvar*depvar
against weight*indepvar. If the weightvar is a dummy variable, this is equi
valent to eliminating all observations with the number zero for weightvar.
The flag o will print the covariance matrix of coefficients. A number of
internal variables may be retrieved using the genr command, provided genr is
invoked immediately after this command. Type help genr for more details on
this.
