gretl commands

add

Argument:varlist [ -o ]
Examples:add 5 7 9
 add xx yy zz -o

Must be invoked after an estimation command. The variables in varlist are added to the previous model and the new model estimated. If more than one variable is added, the F statistic for the added variables will be printed (for the OLS procedure only) along with its p-value. A p-value 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 directly after this command. The -o flag causes the coefficient variance–covariance matrix to be printed.

addto

Arguments:modelID 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

Arguments:order varname
Example:adf 2 x1

Computes statistics for two Dickey–Fuller tests. In each case the null hypothesis is that the variable in question exhibits a unit root. The first is a t-test based on the model

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

where T is the sample size, k the number of parameters in the unrestricted model, and the subscripts u and r denote the unrestricted and restricted models respectively. Note that the critical values for these statistics are not the usual ones; a p-value range is printed, when it can be determined.

ar

Arguments:lags ; depvar indepvars [ -o ]
Example:ar 1 3 4 ; y 0 x1 x2 x3

Computes parameter estimates using the generalized Cochrane–Orcutt iterative procedure (see Section 9.5 of Ramanathan). Iteration is terminated when successive error sums of squares do not differ by more than 0.005 percent or after 20 iterations. lags is a list of lags in the residuals, terminated by a semicolon. In the above example, the error term is specified as

depvar is the dependent variable and indepvars is the list of independent variables. If the -o flag is given, the covariance matrix of regression coefficients is 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 after this command.

arch

Arguments:order depvar indepvars [ -o ]
Example:arch 4 y 0 x1 x2 x3

Tests the model for ARCH (Autoregressive Conditional Heteroskedasticity) of the lag order specified in order, which must be an integer. If the LM test statistic has p-value 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 squared residual is used instead. Weighted least square estimation is then performed on the original model. The flag -o calls for the coefficient covariance matrix.

chow

Argument: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

Arguments:order depvar indepvar
Examples:coint 2 y x
 coint 4 y x1 x2

Carries out Augmented Dickey–Fuller 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 Durbin–Watson statistic for the cointegrating regression is also given. Note that none of these test statistics can be referred to the usual statistical tables.

corc

Arguments:depvar indepvars [ -o ]
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 parameter estimates using the Cochrane–Orcutt iterative procedure (see Section 9.4 of Ramanathan) with depvar as the dependent variable and indepvars as the list of independent variables. Iteration is terminated when successive estimates of the autocorrelation coefficient do not differ by more than 0.001 or after 20 iterations. If the -o flag is given, the covariance matrix of regression coefficients is printed. Residuals of this transformed regression are stored under the name uhat. Various internal variables may be retrieved using the genr command, provided genr is invoked immediately after this command.

corr

Argument:[ varlist ]
Examples:corr 1 3 5
 corr y x1 x2 x3

Prints the pairwise correlation coefficients for the variables in varlist, or for all variables in the data set if varlist is not given.

corrgm

Arguments:variable [ maxlag ]

Prints the values of the autocorrelation function for the variable specified (either by name or number). See Ramanathan, Section 11.7. It is thus where ut 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 Box-Pierce Q statistic for testing the null hypothesis that the series is "white noise". This is asymptotically distributed as chi-square with degrees of freedom equal to the number of lags used.

If an (optional) 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

Arguments:ess T k
Example:criteria 23.45 45 8

Computes the model selection statistics (see Ramanathan, Section 4.3), 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.

cusum

Must follow the estimation of a model via OLS. Performs the CUSUM test for parameter stability. A series of (scaled) one-step 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 Harvey–Collier t-statistic for testing the null hypothesis of parameter stability is also quoted. See Chapter 7 of Greene's Econometric Analysis for details.

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

Argument: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(t-1) and d_y = y(t) - y(t-1).

endloop

Terminates a simulation loop. See loop.

eqnprint

Must follow the estimation of a model via OLS. Prints the estimates 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 tabprint.

fcast

Argument:[ startobs endobs ] newvarname
Examples:fcast 1997.1 1999.4 f1
 fcast f2

Must follow an estimation command. Forecasts are generated for the specified range (or the largest possible range if no startobs and endobs are given) and the values saved as newvarname, which can be printed, graphed, or plotted. The right-hand side variables are those in the original model. There is no provision to substitute other variables. 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

Arguments: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. The augmented regression method of Salkever (1976) is used to generate the forecast standard errors.

fit

The fit command (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 time-series models, fit also pops up a gnuplot graph of fitted and actual values of the dependent variable against time.

freq

Argument:var

Prints the frequency distribution for var (given by name or number) along with a chi-square test for normality. In interactive mode a gnuplot graph of the distribution is displayed.

genr

Argument:newvar = 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 -.

The available Boolean operators are (again, in order of precedence): ! (negation), & (logical AND), | (logical OR), >, <, = and != (not equal to). The Boolean operators can be used in constructing dummy variables: for instance (x > 10) returns 1 if x > 10, 0 otherwise. Supported functions fall into these groups:

All of the above functions with the exception of cov, corr, pvalue, uniform and normal take as their single argument either the name of a variable (note that you can't refer to variables 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. The pvalue function takes the same arguments as the pvalue command (see below), but in this context commas should be placed between the arguments. uniform() and normal(), which do not take arguments, return pseudo-random series drawn from the uniform (0–100) and standard normal distributions respectively (see also the seed command). Uniform series are generated using the C library function rand(); for normal series the method of Box and Muller (1958) is used.

Besides the operators and functions just noted there are some special uses of genr:

Note: In the command-line program, genr commands that retrieve model-related data always reference the model that was estimated most recently. This is also true in the GUI program, if one uses genr in the "gretl console" or enters a formula using the "Define new variable" option under the Variable menu in the main window. With the GUI, however, you have the option of retrieving data from any model currently displayed in a window (whether or not it's the most recent model). You do this under the "Model data" menu in the model's window.

Table 10-1 gives several examples of uses of genr with explanatory notes; here are a couple of tips on dummy variables:

Table 10-1. Examples of use of genr command

CommandComment
genr y = x1^3x1 cubed
genr y = ln((x1+x2)/x3) 
genr z = x>ysets 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 = diff(x)y(t) = x(t) - x(t-1)
genr y = ldiff(x)y(t) = log x(t) - log x(t-1), the instantaneous rate of growth of x
genr y = sort(x)sorts x in increasing order and stores 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)cumulation:
genr aa = $essset aa equal to the Error Sum of Squares from last regression
genr x = coeff(sqft)grab the estimated coefficient on the variable sqft from the last regression
genr rho4 = rho(4)grab the 4th-order autoregressive coefficient from the last model (presumes an ar model)
genr cvx1x2 = vcv(x1, x2)grab the estimated coefficient covariance of vars x1 and x2 from the last model
genr foo = uniform()/100uniform pseudo-random variable in range 0–1
genr bar = 3 * normal()normal pseudo-random variable, μ = 0, σ = 3

 

gnuplot

Arguments:yvars xvar [ -o | -m ]
 gnuplot -z yvar xvar dummy

In the first case 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 second 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 time-series 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 plot file named gpttmp01.plt is written. (With subsequent uses of gnuplot similar files are created, with the number in the file name incremented.) The plots can be generated later using the command gnuplot gpttmp.plt. (Under MS Windows, start wgnuplot and open the file gpttmp01.plt.) To gain control over the details of the plot, edit the .plt file.

graph

Arguments:var1 var2 [ -o ]
 graph var1 var2 var3

ASCII graphics. In the first example, variable var1 (which may be a name or a number) is graphed (y-axis) against var2 (x-axis) using ASCII symbols. -o flag will graph with 40 rows and 60 columns. Without it, the graph will be 20 by 60 (for screen output). In the second example, both var1 and var2 will be graphed (on y-axis) against var3. This is useful to graph observed and predicted values against time. See also the gnuplot command.

hausman

This test is available only after estimating a model using the pooled command (see also 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 cross-sectional units, allowing the intercept of the regression to vary across the units. An F-test 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 cross-sectional unit and the other specific to the particular observation. (This estimator can be computed only if the number of cross-sectional units in the data set exceeds the number of parameters to be estimated.) The Breusch–Pagan 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 group-specific 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 group-specific error is not so correlated (and therefore the random effects model is preferable). A low p-value for this test counts against the random effects model and in favor of fixed effects.

hccm

Arguments:depvar indepvars [ -o ]

Presents OLS estimates with the heteroskedasticity consistent covariance matrix estimates for the standard errors of regression coefficients using MacKinnon and White (1985) "jackknife" estimates (see Ramanathan, Section 8.3). The coefficient covariance matrix is printed if the -o flag is given.

help

Gives a list of available commands. help command describes command (e.g. help smpl). You can type man instead of help if you like.

hilu

Arguments:depvar indepvars [ -o ]
Examples:hilu 1 0 2 4 6 7
 hilu -o y 0 x1 x2 x3

Computes parameter estimates using the Hildreth–Lu search procedure (fine tuned by the CORC procedure) with depvar as the dependent variable and indepvars as the list of independent variables. 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. Residuals of this transformed regression are stored under the name uhat.

hsk

Arguments:depvar indepvars [ -o ]

Prints heteroskedasticity corrected estimates (see Ramanathan, ch. 8) 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 given, the covariance matrix of regression coefficients is printed. Various internal variables may be retrieved using the genr command, provided genr is invoked immediately after this command.

import

Argument:filename [ -o ]

Without the -o flag, brings in data from a comma-separated 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). See Chapter 5 for details.

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

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

Prints out the informative labels for any variables that have been generated using genr, and any labels added to the data set via the GUI.

lags

Argument: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 is 4 (quarterly), the command lags x y creates x_1 = x(t-1), x_2 = x(t-2), x_3 = x(t-3) and x_4 x(t-4). Similarly for y. These variables must be referred to in the exact form, that is, with the underscore.

ldiff

Argument: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 = and ld_y = .

lmtest

Must immediately follow an ols command. Prints the Lagrange multiplier test statistics (and associated p-values) for nonlinearity and heteroskedasticity (White's test) or, if the -o flag is given, the LMF test statistic for serial correlation up to the periodicity (see Kiviet, 1986). The corresponding auxiliary regression coefficients are also printed out. See Ramanathan, Chapters 7, 8, and 9 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

Arguments:depvar indepvars

Binomial logit regression. The dependent variable should be a binary variable. Maximum likelihood estimates of the coefficients on indepvars are obtained via the EM or Expectation–Maximization method (see Ruud, 2000, ch. 27). 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 chi-square statistic tests the null hypothesis that all coefficients are zero apart from the constant.

If you want to use logit for analysis of proportions (where the dependent variable is the proportion of cases having a certain characteristic, at each observation, rather than a 1 or 0 variable indicating whether the characteristic is present or not) you should not use the logit command, but rather construct the logit variable (e.g. genr lgt_p = log(p/(1 - p))) and use this as the dependent variable in an OLS regression. See Ramanathan, ch. 12.

logs

Agument: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. logs x y creates the new variables l_x = ln(x) and l_y = ln(y).

loop

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

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). You exit the mode of entering loop commands with endloop: at this point the stacked commands are executed. Loops cannot be nested. See Chapter 8 for details.

meantest

Arguments:var1 var2 [ -o ]

Calculates the t statistic for the null hypothesis that the population means are equal for the variables var1 and var2, and shows its p-value. 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 non-missing observations for the two variables.)

multiply

Arguments:x suffix varlist
Examples:multiply invpop pc 3 4 5 6
 multiply 1000 big x1 x2 x3

The variables in varlist (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 variable names 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 as the product of income and invpop, and expendpc as expend times invpop.

nulldata

Argument: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. This command may be useful in conjunction with loop. See also the seed command.

ols

Arguments:depvar indepvars [ -o ]
Examples: ols 1 0 2 4 6 7
 ols -o y 0 x1 x2 x3

Computes ordinary least squares estimates with depvar as the dependent variable and indepvars as the list of independent variables. The -o flag calls for printing of the covariance matrix of regression coefficients. The variables may be specified by name or number; use the number zero for a constant term. The program also prints the p-values for t (two-tailed) and F-statistics. A p-value below 0.01 indicates significance at the 1 percent level and is denoted by ***. ** indicates significance between 1 and 5 percent and * indicates significance between 5 and 10 percent levels. Model selection statistics (described in Ramanathan, Section 4.3) are also printed. Various internal variables may be retrieved using the genr command, provided genr is invoked immediately after this command.

omit

Argument:varlist [ -o ]
Example:omit 5 7 9

This command must be invoked after an estimation command. The variables in varlist are omitted from the previous model and the new model estimated. If more than one variable is omitted, the Wald F-statistic for the omitted variables will be printed along with its p-value (for the OLS procedure only). A p-value below 0.05 means that the coefficients are jointly significant at the 5 percent level. Various internal variables may be retrieved using the genr command, provided genr is invoked immediately after this command. The coefficient covariance matrix is printed if the -o flag is given.

omitfrom

Arguments:modelID 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

Argument: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).

pergm

Argument: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 root T (where T is the sample size). is used in estimating the spectrum (see Chapter 18 of Greene's Econometric Analysis). When the sample periodogram is printed, a t-test for fractional integration of the series ("long memory") is also given: the null hypothesis is that the integration order is zero.

plot

Examples:plot x1
 plot x1 x2
 plot -o x1 x2

Plots data values for specified variables, for the range of observations currently in effect, using ASCII symbols. 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). See also gnuplot.

pooled

Arguments:depvar indepvars [ -o ]

Estimates a model via OLS (see ols for details on syntax), and flags it as a pooled or panel model, so that the hausman test item becomes available.

print

Argument:[ varlist ] [ -o ]
Examples:print
 print x y
 print 1 2 3 -o

If varlist is given, prints the values of the specified variables, otherwise prints the values of all variables in the current data file. If the -o flag is given the data are printed by observation, otherwise they are printed by variable.

probit

Arguments:depvar indepvars

Probit regression. The dependent variable should be a binary variable. Maximum likelihood estimates of the coefficients on indepvars are obtained via iterated least squares (the EM or Expectation–Maximization 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 chi-square statistic tests the null hypothesis that all coefficients are zero apart from the constant.

Probit for analysis of proportions is not implemented in gretl at this point.

pvalue

Usage: 
 pvalue 1 xvalue (normal distribution)
 pvalue 2 df xvalue (t distribution)
 pvalue 3 df xvalue (chi-square distribution)
 pvalue 4 dfn dfd xvalue (F distribution)
 pvalue 5 mean variance xvalue (Gamma distribution)

Computes the area to the right of xvalue in the specified distribution. df is the degrees of freedom, dfn is the d.f. for the numerator, dfd is the d.f. for the denominator. Instead of the code numbers you can use z, t, X, F and G for the normal, t, chi-square, F, and gamma distributions respectively.

quit

Exits from the program, giving you the option of saving the output from the session on the way out.

rhodiff

Arguments:rholist ; varlist
Examples: rhodiff .65 ; 2 3 4
 rhodiff r1 r2 ; x1 x2 x3

Creates rho-differenced 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 variables. Given variable v1 in varlist, and entries r1 and r2 in rholist, v1# = v1(t) - r1*v1(t-1) - r2*v1(t-2) is created. The rholist entries can be given as numerical values or as the names of variables previously defined.

run

Argument:inputfile

Execute the commands in inputfile then return control to the interactive prompt.

runs

Argument: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 non-zero median, you can do the following:


	    genr signx1 = x1 - median(x1)
	    runs signx1

scatters

Argument:yvar ; xvarlist
 scatters yvarlist ; xvar
Examples:scatters 1 ; 2 3 4 5
 scatters 1 2 3 4 5 6 ; time

Plots 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 y-axis and draws four graphs, the first having variable 2 on the x-axis, the second variable 3 on the x-axis, and so on. The second example plots each of variables 1 through 6 against time. 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

Argument:integer

Sets the seed for the pseudo-random 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 pseudo-random numbers you will need to set the seed manually.

setobs

Arguments:periodicity startobs
Examples:setobs 4 1990.1
 setobs 12 1978.03
 setobs 20 1.01

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. See also Chapter 6.

setmiss

Arguments:value [ varlist ]
Examples:setmiss -1
 setmiss 100 x2

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 value 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 data value 100 is interpreted as a code for "missing", but only for the variable x2.

shell

Usage:! shellcommand

A ! at the beginning of a command line is interpreted as an escape to the user's shell. Thus arbitrary shell commands can be executed from within the program (not available under MS Windows).

sim

Arguments:startobs endobs y a0 a1 a2
Examples:sim 1979.2 1983.1 y 0 0.9 creates y(t) = 0.9*y(t-1)
 sim 15 25 y 10 0.8 x creates y(t) = 10 + 0.8*y(t-1) + x(t)*y(t-2)

Simulates values for y for the periods startobs through endobs. The variable y must have been defined earlier with appropriate initial values. The formula used is y(t) = a0(t) + a1(t)*y(t-1) + a2(t)*y(t-2) + … The ai(t) may either be numerical constants or variable names previously defined.

smpl

Arguments:startobs endobs
 smpl -o dummyvar
 smpl -o
 smpl -r condition

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 at each observation; the sample will be restricted to observations where the value is 1. The third form, smpl -o, drops all observations for which values of one or more variables are missing. The fourth form (-r) restricts the sample to observations that satisfy the given (Boolean) condition.

smpl 3 10 data with periodicity 1
smpl 1950 1990 annual data, periodicity 1
smpl 1960.2 1982.4 quarterly data
smpl 1960.04 1985.10 monthly data
smpl 1960.2 ; keep endobs unchanged
smpl ; 1984.3 keep startobs unchanged
smpl -o dum1 draw sample of observations where dum1=1
smpl -r income > 30000 sample cases where income has a value greater than 30000.

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

Arguments: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

Argument:varlist [ -o ]

Generates new variables which are squares and cross products of the variables in varlist (-o will create the cross products). For example square x y will generate 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

Argument:datafile [ varlist ] [ flag ]

datafile is the name of the file in which the values should be stored.

If varlist is absent, the values of all the variables in the current data set will be stored.

By default storage is in native gretl XML format. There are six valid (mutually exclusive) flags:

-z The default format, but gzip compressed.
-o Store the data by variables, in binary format using double precision.
-s Store the data by variables, in binary format using single precision.
-c Store the data in CSV (comma-separated values) format. Such data can be read directly by spreadsheet programs.
-r Store the data in GNU R format.
-m Store the data in GNU Octave format.
-t Store the data in "traditional" ESL format, with an ascii data file and a separate informative header file.

summary

Argument:[ varlist ]

Print summary statistics for the variables in varlist, or for all the variables in the data set if varlist is omitted. Output consists of the mean, standard deviation (sd), coefficient of variation (= sd/mean), median, minimum, maximum, skewness coefficient, and excess kurtosis.

tabprint

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 eqnprint.

testuhat

Must follow a model estimation command. Gives the frequency distribution for the residual from the model along with a chi-square test for normality.

tsls

Arguments:depvar varlist1 ; varlist2 [ -o ]
Example: tsls y1 0 y2 y3 x1 x2 ; 0 x1 x2 x3 x4 x5 x6

Computes two-stage least squares (TSLS) estimates of parameters. depvar is the dependent variable, varlist1 is the list of independent variables (including right-hand 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 ys are the endogenous variables and the xs 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.

var

Arguments: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, 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 F-tests for zero restrictions on all lags of each of the variables, and an F-test for the maximum lag.

varlist

Prints a listing of variables currently available. list and ls are synonyms.

vartest

Arguments:var1 var2

Calculates the F statistic for the null hypothesis that the population variances for the variables var1 and var2 are equal, and shows its p-value.

wls

Arguments:weightvar depvar indepvars [ -o ]

Weighted least squares estimates are obtained using weightvar as the weight, depvar as the dependent variable and indepvars as the list of independent variables. More specifically, an OLS regression is run on weightvar * depvar against weight * indepvars. If the weightvar is a dummy variable, this is equivalent 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.