FUNDAMENTALS OF LIMDEP

The purpose of this session is to introduce to LIMDEP and gain some familiarity with a few LIMDEP commands that will be used in future sessions.

SOME BASICS

Most LIMDEP programs require only two lines, though there may be other lines added to transform data, calculate results, manipulate matrices, etc. These are:

READ ; OPTION 1 ; OPTION 2 ; … ; LAST OPTION $
MODEL COMMAND ; OPTION 1 ; OPTION 2 ; … ; LAST OPTION $

The first line reads in the data. The second line tells LIMDEP which model to estimate and gives some options for the particular model.

As an example, enter LIMDEP by clicking the LIMDEP icon from the Windows desktop or program menu. Then click FILE NEW from the LIMDEP menu. Then click TEXT/COMMAND DOCUMENT.

This opens a work area for editing a set of LIMDEP commands. Now type in the following.

READ ; FILE=EXAMPLE.DAT ; NOBS=15 ; NVAR=4 ; NAMES=Y,X1,X2,X3 $
DSTATS ; RHS=Y,X1,X2,X3 ; OUTPUT=3 $

Make sure that the path is correct for finding the file called EXAMPLE.DAT on the "FILE= " option.

Now, execute this program by marking (highlighting) the two lines as in any text processor with the left mouse button, then click the right mouse button, and then click RUN SELECTION from the right mouse menu.

This brief program reads in a data set contained in a file called EXAMPLE.DAT and computes descriptive statistics on the variables in EXAMPLE.DAT.

Note that LIMDEP automatically opened a second window for viewing the OUTPUT. You may switch back and forth between the OUTPUT and COMMAND windows by clicking on the other window or choosing WINDOW on the LIMDEP menu and the appropriate selection.

Alternative ways to run this program would have been to:

  1. Mark the text and press the ENTER key on the number keypad, or
  2. Mark the text and press CTRL-R, or
  3. Mark the text and select RUN and then RUN SELECTION from the LIMDEP menu.

A fast way to mark all of the text in a command file is by pressing CTRL-A. To run an entire set of commands in a command window press CTRL-A and then CTRL-R .

You may also run commands one line at a time. Place the cursor on the line and press the ENTER key on the number pad. This is often useful for de-bugging programs.

Now let's consider what was in the command file we just executed.

The "FILE= " option tells LIMDEP the data are in a file called EXAMPLE.DAT. The number of observations, NOBS, in the file is 14; the number of variables, NVAR, is 4; the NAMES of the variables are Y,X1,X2,X3.

The DSTATS command tells LIMDEP to do descriptive statistics on exogenous (RHS) variables Y,X1,X2,X3. The OUTPUT=3 option calls for correlations and covariances between the four variables.

Note that the typical LIMDEP command begins with a keyword (e.g., READ, DSTATS, REGRESS, CALC, MATRIX,…) that alerts the program that a command has begun. Options within commands are separated by semicolons. All LIMDEP commands end with a $. If a command runs onto multiple lines of the command file then just press ENTER (not the one on the number keypad) to move to the next line. If the $ is not present, then LIMDEP does not know to start a new command. Commands may extend onto any number of lines with any number of spaces. They are not case sensitive. The only quirks are that commands must end with the $ and options must be separated by semicolons.

You may save a set of commands from the command file by selecting FILE SAVE from the LIMDEP menu, while in the COMMAND window. You will be prompted for a file name for the saved file that can then be used for later work.

You may also want to print results or save them for viewing. To do this, select FILE SAVE or FILE PRINT from the LIMDEP menu, while in the OUTPUT window.

Pressing the right mouse button while in the COMMAND or OUTPUT windows gives a full set of editing options that are very useful.

 

The READ Command

Now lets discuss the various ways to get data into LIMDEP using the READ command. There are multiple ways to read data into LIMDEP.

  1. External ASCII file- The data can be in an external ASCII file created by a text processor, as the example above. (As an illustration, go to the LIMDEP FILE menu and OPEN the file called EXAMPLE.DAT from above.)
  2. Internal ASCII file- The data can be placed within the command file itself (if you omit the "file=filename" option from the Read line). This is useful for small datasets. Note that for many of the data sets used in this course I have created a data file with the Read command at the top of the file. To use these files just cut and paste the data file into the command file. Also, the LIMDEP HELP menu has example datasets that can be cut and pasted into the command file.
  3. Other formats- The data can also be read from a spreadsheet in WKS format, or from an ASCII file in Fortran format (for speed), or from a binary file created by LIMDEP (very fast for reading large data sets). The Format= option is required for these three methods.

For all input data files it is particularly important that you have the correct path for finding the data.

For more information on reading and creating data files, go to the LIMDEP HELP menu, select MANUAL, and read chapter 4. The HELP menu contains about 80 percent of the actual LIMDEP manual that can be purchased for around $50. For information on purchasing LIMDEP manual, see http://www.limdep.com .

 

MODEL Commands

LIMDEP has many "canned" statistical procedures that can be executed using a single MODEL statement with options. Many other statistical procedures can be performed using the Maximize/Minimize commands that allow you to program your own Maximum Likelihood procedure. We will use this latter approach frequently in this course. Below is a listing of models that can be called in the MODEL statement. Most of the procedures have numerous options, so this is merely an overview. The quick reference guide distributed with the LIMDEP manual lists the full set of options. For a full description of each model go to the LIMDEP HELP menu, select MANUAL, choose the appropriate model from the table of contents, and read. You should pay particular attention for now to the DSTATS, REGRESS, and MAXIMIZE commands that will be used over the next few sessions. Here is a list of "canned" LIMDEP procedures. 

ARMAX Box-Jenkins ARIMA models.
BIVARIATE PROBIT Bivariate probit models.
BOXCOX MLE or nonlinear least squares for Box-Cox model.
CROSSTAB Cross-tabulation. Frequency counts and contingency tables.
DISCRETE CHOICE Random utility models and nested logit models.
DSTATS Descriptive statistics.
FINTEGRATE Integrate a function over a given range.
FPLOT Plot values of a function of a variable.
FRONTIER REGRESSION Stochastic frontier.
GROUPED DATA REGRESSION Completely censored data.
HISTOGRAM
HREG MLE for heteroskedastic regression model.
Var[e] = exp(a'zi).
IDENTIFY Plot autocorrelations and partial autocorrelations.
INCIDENTAL TRUNCATION A form of selection model.
LOGIT Binomial or multinomial logit model.
LOGNORMAL REGRESSION
MAXIMIZE Maximize a user defined function.
MINIMIZE Minimize a function or compute nonlinear least squares estimates.
MPLOT Plot elements of one matrix against those of another.
MSCORE Maximum score estimation for binary choice data.
NEGBIN Negative binomial regression models.
NLOGIT Nested logit and conditional logit models.
NLSURE Nonlinear seemingly unrelated regressions.
NPREG Nonparametric regression estimator for binary choice data.
NTOBIT Two level, nested tobit models.
ORDERED PROBIT Ordered probit or logit models.
PROBIT Univariate probit model.
TOBIT Censored regression.
TRUNCATED REGRESSION
PLOT Scatter diagrams and time series plots.
POISSON Poisson and negative binomial regression models.
REGRESS (or OLSQ, CRMODEL) Classical regression. Least squares regression.
SELECTIVITY Sample selection models.
SURE Seemingly unrelated and multivariate regression.
SURVIVAL MODEL Analysis of duration data.
SWITCHING REGRESSIONS
TSCS Time series/cross section regressions.

WALD Test restrictions or obtain variances for nonlinear functions.
2SLS Two stage least squares.
3SLS Three stage least squares.

Transformations and Calculations

The basic command for creating new variables is CREATE. The format for the CREATE command is:

CREATE ; NEWVAR=function $

where NEWVAR is the new variable name. For a list of available functions see Chapter 5 of the LIMDEP manual.

If you want to see a listing of the new variable, use:

LIST ; NEWVARIABLE $

The basic command for working with scalars is CALCULATE. The format for this command is:

CALC ; SCALAR=function $

where scalar is a single number created by the function. If you want to see a listing of the scalar use:

CALC ; LIST; SCALAR=FUNCTION $

There is a calculator located on the LIMDEP menu under TOOLS.

 

ASSIGNMENT: As an exercise for this first session, read the data from the data file called EXAMPLE.DAT. Use the CREATE command to create some new variables, x1*x2 and x3 squared (See Chapter 5 of the LIMDEP manual). Compute descriptive statistics on these variables. Use the REGRESS command to do a regression of y on a constant, x1, x2, x1*x2, and x3 squared. (See Chapter 14 of the LIMDEP manual). In your regression list and save the residuals and predicted values to new variables, plot the residuals, and obtain CUSUM plots for parameter stability. Finally, use the CALCULATE command to save and view the log likelihood.

Try this first independently. However, if you get into trouble, here is what the command file would look like.

READ ; FILE=EXAMPLE.DAT ; NOBS=15 ; NVAR=4 ; NAMES=Y,X1,X2,X3 $
CREATE ; X1X2=X1*X2 $
CREATE ; X3SQR=X3^2 $
DSTATS ; RHS=X1X2,X3SQR $
REGRESS ; LHS=Y; RHS=ONE,X1X2,X3SQR ; RES=E ; KEEP=YHAT ; LIST ; PLOT
; CUSUM $
CALC ; LIST ; LNL=LOGL $