A CONCISE GUIDE TO LIMDEP COMMANDS

advertisement
A CONCISE GUIDE TO LIMDEP COMMANDS
Professor Thornton
Economics
TABLE OF CONTENTS
INTRODUCTION ………………………………………………………………………... 3
EXEUCTING LIMDEP COMMANDS ………………………………. ………………….3
CREATING A LIMDEP DATA FILE ……………………………….…………………... 7
DISPLAYING AND EDITING DATA ………………………………………………….. 9
DELETING OBSERVATIONS FROM THE SAMPLE ………………………………… 9
CREATING NEW VARIABLES ………………………………………………………. 10
LOGICAL EXPRESSION, RECODING DATA, AND RENAMING VARIABLES …. 11
CALCULATIONS ………………………………………………………………………. 11
DESCRIPTIVE STATISTICS ……………………………………………………………12
LINEAR REGRESSION MODEL ……………………………………………………….13
NONLINEAR LEAST SQUARES REGRESSION MODEL ……………………………15
LINEAR SEEMINGLY UNRELATED REGRESSIONS MODEL ……………………..16
NONLINEAR SEEMINGLY UNRELATED REGRESSIONS MODEL ………………. 17
LINEAR TWO-STAGE LEAST SQUARES REGRESSION MODEL ………………… 18
NONLINEAR TWO-STAGE LEAST SQUARES REGRESSION MODEL …………… 19
LINEAR THREE-STAGE LEAST SQUARES REGRESSION MODEL ………………. 19
NONLINEAR THREE-STAGE LEAST SQUARES REGRESSION MODEL …………. 20
BINARY PROBIT REGRESSION MODEL …………………………………………….. 21
BINARY LOGIT REGRESSION MODEL ………………………………………………. 22
STOCHASTIC FRONTIER REGRESSION MODEL …………………………………… 22
TRUNCATED REGRESSION MODEL …………………………………………………. 23
TOBIT (CENSORED) REGRESSION MODEL …………………………………………. 25
REGRESSION MODEL WITH SAMPLE SELECTION ………………………………… 26
MATRIX COMMANDS ………………………………………………………………….. 27
2
INTRODUCTION
This guide provides an explanation of a number useful Limdep commands and capabilities. It does not
explain all Limdep commands and capabilities. Limdep is an extremely powerful statistical package, and
if you desire to learn its full capabilities you should also consult the Limdep User's Manual.
In this guide, Limdep commands are explained in the context of examples. The examples are based on the
following three data sets. It is assumed that each data set is contained in a Limdep data file on a floppy
disk in drive A.
CONSUMER.LPJ
The Limdep data file CONSUMER.LPJ consists of prices and quantities purchased of three goods, and
income, for a cross section of 30 individual consumers. These data are simulated, not real world data. The
variables are: Q1 = quantity purchased of good 1, Q2 = quantity purchased of good 2, Q3 = quantity
purchased of good 3, P1 = price of good 1, P2 = price of good 2, P3 = price of good 3, I = consumer income.
PRODUCER.LPJ
The Limdep Data File PRODUCER.LPJ consists of cross-section data for 92 dairy farm households for the
year 1986. These data were obtained from a random sample of Utah dairy farmers in five counties that were
the major dairy production centers. The variables are: OUTPUT = pounds of milk produced per year,
LABOR = hours worked per year by household members, CAPITAL = units of capital, LAND = units of
land, PCAPITAL = price per unit of capital, PLAND = price per unit of land, POUTPUT = price per pound
of milk, PLABOR = hourly wage of labor. Note that the price of labor and the price of land do not vary
across dairy farms i.e., all 92 dairy farms can purchase labor and land at the same price.
LABORSUPPLY.LPJ
The Limdep data File LABORSUPPLY.LPJ consists of cross-section data for 100 families taken from the
1976 panel study of income dynamics, and is based on data for the year 1975. The variables are: LFP = a
dummy variable for wife labor force participation (1 if wife worked in 1974, 0 otherwise), WHRS = wife’s
hours of work in 1975, KL6 = number of children less than 6 years old in household, K618 = number of
children between 6 and 18 in the household, WA = wife’s age, WE = wife’s years of education, WW =
wife’s hourly wage for 1975, HHRS = husband’s hours worked in 1975, HA = husband’s age, HE =
husband’s years of education, HW = husband’s hourly wage rate for 1975, FAMINC = total family income
for 1975, MTR = marginal tax rate for wife, WMED = wife’s mother’s years of education, WFED = wife’s
father’s years of education, UN = unemployment rate in county of residence (percentage), CIT = dummy
variable for urban area (1 if family lives in large city, 0 otherwise), AX = wife’s years of labor market
experience.
EXECUTING LIMDEP COMMANDS
Limdep commands can be executed in either batch mode or interactive windows mode. This section
explains both of these command modes. With the exception of the section on “Creating a Limdep Data
File,” all subsequent sections in this guide are explained in the context of interactive windows mode.
This is the easiest way to write and execute Limdep commands.
Example
3
Suppose that you are using the Limdep data file CONSUMER.LPJ. You want to run a linear regression of
the variable Q1 on the variables P1, P2, P3, and I, using the ordinary least squares (OLS) estimation
procedure.
Batch Mode
Step #1
Use a text editor to create an input file. (I recommend WordPad). For example, suppose that you name
this file PROGRAM1.LIM. Enter the following command lines in the input file.
LOAD; FILE = A:CONSUMER.LPJ $
OPEN; OUTPUT = A:CONSUMER.OUT $
REGRESS; LHS = Q1; RHS = ONE, P1, P2, P3, I $
This Limdep program has three command lines. A command line begins with a command name. The
command name is followed by one or more command specifications. The command name and each
command specification is separated by a semicolon. The command line always ends with $. The LOAD
command tells Limdep to load a Limdep data file. The FILE specification tells Limdep the name and
location of the Limdep data file. The OPEN command tells Limdep to create a new file in which to place
the output generated by the commands in the input file. The OUTPUT specification tells Limdep the
name and location of the output file. In this example, the output file is named CONSUMER.OUT and is
located on the floppy disk in drive A. The REGRESS command tells Limdep to run a linear regression
using OLS. The LHS specification tells Limdep that the left-hand side (dependent) variable is Q1. The
RHS specification tells Limdep that P1, P2, P3, and I are the right-hand side (independent) variables.
Including ONE in the list of right-hand side variables tells Limdep to include an intercept in the
regression.
Step #2
Save the input file PROGRAM1.LIM in ascii format on the floppy disk in drive A. If you are using
WordPad as your text editor, then save the file as a “Text Document – MS-DOS Format” file.
Step #3
Open the Limdep Windows program To do this, use the mouse and click the Limdep Windows Icon on
the desktop. The Project Window will be displayed on the left side of the screen. At the top of the screen,
is both a Menu Bar and a Tool Bar.
Step #4
Execute the commands in the input file. To do this, click Run on the menu bar at the top of the screen.
Click Run File… on the Run menu. Find the input file PROGRAM1.LIM. Click on this file to highlight it.
Click the Open button. Limdep will execute the commands in your input file and place the output in the
file CONSUMER.OUT
Step #5
Display the output. There are two alternative ways to display the output. 1) Click the maximize button on
the title bar for the Output Window that appears on the screen after the commands have been executed.
This displays a split screen Output Window. The lower half of the window displays your statistical
4
results. The upper half of the window displays the Limdep trace file. The trace file lists your commands,
diagnostics, and error messages, if you made an error when entering the commands. 2) Exit the Limdep
program. Open your text editor (e.g. WordPad). In the text editor, open the file CONSUMER.OUT.
Interactive Windows Mode
There are two ways to execute a command or set of commands in interactive windows mode. You can use
either the editing window or the model builder.
Editing Window
Step #1
Open the Limdep Windows program.
Step #2
Load your data file. To do this, click File on the Menu Bar. Click Open Project…on the File Menu. Find
the Limdep data file CONSUMER.LPJ on the floppy disk in drive A. Click on this file to highlight it.
Click the Open button. This loads the data file into the Limdep program.
Step #3
Open the Edit Window. To do this, click File on the Menu Bar. Click New…on the File Menu. This opens
a New Window. Click on Text/Command Document to highlight it. Click the OK button. This opens the
Edit Window.
Step #4
Enter the command or commands you want to execute in the Edit Window. For the present example, enter
the command line
REGRESS; LHS = Q1; RHS = ONE, P1, P2, P3, I $
Step #5
Execute the command in the Edit Window. To do this, use the mouse to highlight the command line.
Click the green Go button on the Tool Bar. When the command has been executed, a Title Bar for the
Output Window will be displayed on the screen.
Step #6
Display the output. There are two ways to view the output from this regression. 1) Open the Output
Window. To do this, click the Maximize button on the Title Bar for the Output Window. 2) View the
output in the Project Window. To do this, click the Data folder in the Project Window. You will now see
4 additional folders: variable folder, namelist folder, matrices folder, scalar folder. Click on the Matrices
folder. You will now see 3 entries: B, VARB, SIGMA. Click B to see the vector of parameter estimates.
Click VARB to see the variance-covariance matrix of the estimated parameters. Click on the Scalars
folder. You will now see 14 entries. Click on any entry to view a scalar measure for the regression. For
example, if you click on RSQRD you will see the R2 statistic. If you click on LOGL you will see the
maximized value of the log likelihood function for the regression.
5
Comments
1. In step #2, to verify that the data file is open, click on the Data folder in the Project Window. Click on
the Variables folder. A list of the variables in your data file will be displayed under Variables. To see the
values of a variable, click on that variable. This will open Limdep’s Data Editor Window.
2. In step #4, you can enter as many commands in the edit window as you desire. You can then execute
the command lines that you want by highlighting these command lines only.
3. A single command can be entered on as many separate lines as desired. Limdep continues reading a
command until it encounters $.
4. You can enter and execute as many commands as desired during a single session. Limdep will
accumulate all of your commands and output and continue to display these in the Output Window.
5. To save your output, make sure the Output Window is the active window. (Note: The Title Bar of the
active window is blue. If the Output Window is not the active window, click on the Title Bar to make it
the active window). Click File on the Menu Bar. Click Save As…on the File Menu. Select a file name and
a location to store the file. For example, you may want to name the file CONSUMER.LIM and store it on
a floppy disk in drive A. Click the Save button.
6. To save the commands that you enter in the Edit Window for future use, click on the Title Bar of the
Edit Window to make it the active window. Then proceed as in comment 3 above.
Model Builder
Step #1
Open the Limdep Windows program.
Step #2
Load your data file.
Step #3
Open the command dialogue box for the command you want to execute and specify the command. In the
present example, you want to run a linear regression of Q1 on P1, P2, P3 and I. Click Model on the Menu
Bar. Click Linear Models on the Model Menu. Click Regression…on the Linear Models Menu. A Regress
dialogue box will be displayed. In the box for Dependent Variable, click the Down Arrow. Click the
variable Q1. In the box to the right of Independent Variables, click ONE then click the Double Arrow
button that points to the left; click each independent variable you desire and the Double Arrow button.
Step #4
Execute the command. To do this, click the Run button at the bottom right of the box.
Step #5
Display the output. To do this, click the Maximize button on the Title Bar for the Output Window.
6
Comment
When you use the model builder you must execute one command at a time. However, you can execute as
many commands as you desire during a single session. Limdep will accumulate all of your commands and
output, and display these in the Output Window.
CREATING A LIMDEP DATA FILE
Example
Suppose that you have 30 observations on 7 variables. The variables are P1, P2, P3, I, Q1, Q2, Q3. You
want to place these observations in a data file that Limdep can read. To create a Limdep data file proceed
as follows.
Batch Mode
Step #1
Use a text editor (e.g., WordPad) to create a file that contains the data. For example, you might name this
file CONSUMER.DAT. This file should contain numbers only. For example, the first three rows would
look as follows.
10.76 4.47 6.62 487.64 11.63 13.19 45.77
13.03 10.83 13.77 364.87 12.02
2.81 13.39
9.24 5.85 4.06 541.03
8.91
5.58 104.81
This file would contain a total of 30 rows and 7 columns of numbers. Each row is an observation. Each
column is a variable. Column 1 is variable P1, column 2 is variable P2, column 3 is variable P3, column 4
is variable I, column 5 is variable Q1, column 6 is variable Q2, and column 7 is variable Q3. Note that the
numbers in the columns are separated by at least one blank space, but they do not need to be neatly
arranged as in the above example. Save the file CONSUMER.DAT in ascii format on the floppy disk in
drive A. If you are using WordPad as your text editor, then save this file as a “Text Document-MS-DOS
Format” file.
Step #2
Use the text editor to create an input file. For example, you might name this file
DATAPROGRAM.LIM. Enter the following command lines in this input file.
READ; FILE = A:CONSUMER.DAT; NOBS=30; NVAR=7; NAMES = P1, P2, P3, I, Q1, Q2,
Q3 $
SAVE; FILE = A:CONSUMER.LPJ $
The READ command tells Limdep to read the data. The FILE specification tells Limdep the name and
location of the file that contains the data. The NOBS specification tells Limdep the number of
observations in the file. The NVAR specification tells Limdep the number of variables in the file. The
NAMES specification tells Limdep the names of the variables in the file. The SAVE command tells
Limdep to save the Limdep data file that you create. The FILE specification tells Limdep the name and
location of the Limdep data file. In this example, the Limdep data file is named CONSUNER.LPJ and is
located on the floppy disk in drive A. Save this input file DATAPROGRAM.LIM in ascii format on the
7
floppy disk in drive A. Once again, if you are using WordPad as your text editor, then save this file as a
“Text Document-MS-DOS Format” file.
Step #3
Execute the commands in the input file DATAPROGRAM.LIM. To do this, open the Windows program.
Click Run on the Menu Bar. Click Run File… on the Run Menu. Find the input file
DATAPROGRAM.LIM. Click on this file to highlight it. Click the Open button. Limdep will create a
Limdep data file named CONSUMER.LPJ located on the floppy disk in drive A.
Editing Window
Step #1
Same as batch mode.
Step #2
Open the Limdep Windows program. Click File on the Menu Bar. Click Open… on the File Menu. Find
the file CONSUMER.DAT. Click on this file to highlight it. Click the Open button. Limdep will place the
data from the file CONSUMER.DAT in the Edit Window. At the top of the Edit Window before the data
type the READ command line. Directly after the data type the SAVE command line. Thus, the Edit
Window should look as follows.
READ; NOBS=30; NVAR=7; NAMES = P1, P2, P3, I, Q1, Q2, Q3 $
10.76 4.47 6.62 487.64 11.63 13.19 45.77
13.03 10.83 13.77 364.87 12.02
2.81 13.39
9.24 5.85 4.06 541.03
8.91
5.58 104.81
(Last 27 observations go here)
SAVE; FILE = A:CONSUMER.LPJ $
If you desire, you can omit step #1 and enter the data directly in the Edit Window. However, often times a
data set already exists in ascii format so that step #1 would be necessary.
Step #3
Use the mouse to highlight the data and command lines. Click the green Go button on the Tool Bar. This
will create a Limdep data file named CONSUMER.LPJ located on the floppy disk in drive A.
Comments
1. Suppose that you have a large number of variables. For example, suppose that you have 30
observations on 15 variables. The variables are P1, P2, P3, P4, P5, P6, P7, I, Q1, Q2, Q3, Q4, Q5, Q6,
Q7. Once again, you want to place these observations in a data file that Limdep can read. To create a
Limdep data file proceed as follows. Use a text editor to create as many ascii files as necessary for the
data. For example, because we have 15 variables we might need two files for the data. Suppose that we
create a file named CONSUMER1.DAT that contains the data on the variables P1, P2, P3, P4, P5, P6, P7,
I. We create a second file named CONSUMER2.DAT that contains data on the variables Q1, Q2, Q3, Q4,
Q5, Q6, Q7. The input file DATAPROGRAM.LIM would now have the following command lines.
8
READ; FILE = A:CONSUMER1.DAT; NOBS=30; NVAR=8; NAMES = P1, P2, P3, P4, P5, P6,
P7, I $
READ; FILE = A:CONSUMER2.DAT; NOBS=30; NVAR=7; NAMES = Q1, Q2, Q3, Q4, Q5,
Q6, Q7 $
SAVE; FILE = A:CONSUMER.LPJ $
Executing the commands in this input file would create the Limdep data file CONSUMER.LPJ that
contains the data on the 15 variables.
2. If your data set contains missing values, you must include a symbol for these missing values to tell
Limdep these values are missing. For example, in place of a missing value you could enter the letter M
(or any letter for that matter), or a period ".", which is used by the statistical program SAS to indicate
missing values. When Limdep reads the data into a Limdep data file it will automatically convert your
missing value letter or period to the numeric value -999. It uses the number -999 as an internal code for
missing values. If you use the Data Editor to view the data (see DISPLAYING AND EDITING DATA),
missing values have a blank cell. This is because -999 is an internal code.
DISPLAYING AND EDITING DATA
Suppose you want Limdep to display the data in the Limdep data file CONSUMER.LPJ. Open the
Limdep Windows program and load the Limdep data file. Click Project on the Menu Bar. Click Data
Editor on the Project Menu. This opens the Data Editor Window and displays the data.
Comment
To change the value of an observation, click the cell that contains the observation. Click in the box
labeled “Cell.” Type the new value of the observation in the cell box. Click the button to the right of the
cell box with a green check mark.
DELETING OBSERVATIONS FROM THE SAMPLE
Example
Suppose that you are using the Limdep data file CONSUMER.LPJ. You want to delete from this sample
of data all observations for which the variable I is less than 200 and all observations for which the
variable Q3 is equal to zero.
Edit Window Commands
REJECT; I < 200 $
REJECT; Q3 = 0 $
The REJECT command tells Limdep to delete observations from the current sample. The specifications I
< 200 and Q3 = 0 tells Limdep which observations to delete.
Comments
1. If you now display the data in the Data Editor Window, the observation numbers for deleted
observations will not have double arrows. This indicates that these observations will not be included in
the current sample.
9
2. If you want to include these observations in the sample, use the INCLUDE command. For the above
example, the commands would be
INCLUDE; I < 200 $
INCLUDE; Q3 = 0 $
Alternatively, you could use the command: SAMPLE; ALL $. This sets the sample to be all observations
in the data file.
3. If a variable in your data file has one or more missing values (say, the variable Q1), and you want to
eliminate observations with missing values from the sample, use the following command:
REJECT = Q1 = -999 $.
CREATING NEW VARIABLES
Example
Suppose you are using the Limdep data file CONSUMER.LPJ. You want to create the following 3 new
variables. 1) The logarithm of Q1. 2) The relative price of P1 in terms of P3. 3) An income dummy
variable that takes a value of 1 if income is greater than 400, and 0 otherwise.
Edit Window Command
CREATE; LQ1 = LOG(Q1); RP1 = P1/P3; IDUMMY = I > 400 $
The CREATE command tells Limdep to create one or more new variables. The specification LQ1 =
LOG(Q1) tells Limdep to create a new variable named LQ1 that is the natural logarithm of the variable
Q1. The specification RP1 = P1/P3 tells Limdep to create a new variable named RP1 that is the ratio of
the variables P1 and P3. The specification IDUMMY = I > 400 tells Limdep to create a new variable
named IDUMMY that takes a value of 1 if the variable I is greater than 400, and zero otherwise.
Comments
1. If you now display the data in the Data Editor Window, you will find that 3 new variables have been
added to your data file: LQ1, RP1, and IDUMMY. If you want to save these new variables permanently
in the Limdep data file CONSUMER.LPJ, you can do so by clicking File on the Menu Bar, and then
clicking Save on the File Menu.
2. Limdep uses the following operators: + addition; - subtraction; * multiplication; / division,
^ exponentiation (e.g., P1^2 tells Limdep to square the variable P1);
3. Limdep uses the following operators in logical expressions and to create dummy variables: = equal; >
greater than; >= greater than or equal to; < less than; <= less than or equal to; # not equal to.
Model Builder Procedure
Click Project on the Menu Bar. Click New on the Project Menu. Click Variable… on the New Menu. This
opens the new variable dialogue box. Enter the necessary information.
Comment
10
When using this method, you must create one variable at a time.
LOGICAL EXPRESSIONS, RECODING DATA, AND RENAMING VARIABLES
Example
Suppose you are using the Limdep data file PRODUCER.LPJ. You want to do the following. 1) The
variable POUTPUT takes only three values: 0.1152, 0.1214, 0.1236. You want to create a dummy
variable for each of these values. PDUM1 = 1 if POUTPUT = 0.1152, and 0 otherwise. PDUM2 = 1 if
POUTPUT = 0.1236, and zero otherwise. PDUM3 = 1 if POUTPUT = 0.1236, and zero otherwise. 2)
You want to create a new output variable, named NOUTPUT, that assumes a value of 1,000,000 if
OUTPUT is greater than or equal to 1,000,000, and assumes the same value as OUTPUT is less than
1,000,000 4) You want to change the value of PLABOR to 10 for all dairy farms for which POUTPUT is
0.1152 4). The variable LAND has a value of zero for five observations. You want to recode these
observations so that they have a value of one. 5) You want to change the name of the variable PLABOR
to PRICELAB.
Edit Window Commands
CREATE; IF (POUTPUT = 0.1152) PDUM1 = 1; (ELSE) PDUM1 = 0 ;
IF (POUTPUT = 0.1214) PDUM2 = 1; (ELSE) PDUM2 = 0 ;
IF (POUTPUT = 0.1236) PDUM3 = 1; (ELSE) PDUM3 = 0 $
CREATE; IF (OUTPUT >= 1000000) NOUTPUT=1000000; (ELSE) NOUTPUT = OUTPUT$
CREATE; IF (POUTPUT = 0.1152) PLABOR = 10 $
RECODE; LAND; 0 = 1 $
RENAME; PLABOR = PRICELAB $
The first CREATE command tells Limdep to create three new variables. The IF, (ELSE) specifications
tell Limdep to test the IF statement first. The IF statement appears in parentheses directly following the
IF specification. (e.g., POUTPUT = 0.1152). If the IF statement is true, then Limdep assigns the new
variable (e.g. PDUM1) a value of one. If the IF statement is false then the succeeding (ELSE) statement
tells Limdep to assign the new variable (e.g. PDUM1) a value of zero. The second CREATE command
tells Limdep to create one new variable. The IF specification tells Limdep to assign a value of 1 million
to the new variable NOUTPUT if the value of the existing variable POUTPUT is greater than or equal to
1 million. The (ELSE) specification tells Limdep to assign the value of the variable OUTPUT to the new
variable NOUTPUT if the value of the variable OUTPUT is less than 1 million. The third CREATE
statement tells Limdep to change the value of the existing variable PLABOR to 10 for any observation for
which the value of the existing variable POUTPUT is 0.1152. The RECODE command tells Limdep to
change each value of the existing variable LAND that is zero to a new value of one. The RENAME
command tells Limdep to change the name of the existing variable PLABOR to PRICELAB.
CALCUATIONS
Example
Suppose you are using the Limdep data file CONSUMER.LPJ. You want to calculate the following scalar
values (i.e., single numbers). 1) Covariance of Q1 and P1. 2) Correlation coefficient of Q1 and P1. 2)
Sample median of I . 3) Minimum value of Q2. 4) Sum of the values of P2. 5) Natural logarithm of the
number 3000. 6) The 95 percent critical value from the F-distribution with 2 degrees of freedom in the
numerator and 25 degrees of freedom in the denominator.
11
Edit Window Command
CALC; LIST; COV(Q1,P1); COR(Q1,P1); MED(I); MIN(Q2); SUM(P2); LOG(3000);
FTB(.95,2,25) $
The CALC command tells Limdep to calculate a scalar value. The LIST specification tells Limdep to
display the results of the calculations in the Output Window. The COV specification tells Limdep to
calculate the covariance. The COR specification tells Limdep to calculate the correlation coefficient. The
MED specification tells Limdep to calculate the median. The MIN specification tells Limdep to find the
minimum value. The SUM specification tells Limdep to calculate the sum of the values. The LOG
specification tells Limdep to calculate the natural log. The FTB specification tells Limdep to find a
critical value from an F-distribution.
Limdep’s Calculator Window.
Open the Calculator Window. To do this, click Tools on the Menu Bar. Click Scalar Calculator on the
Tools Menu. This opens the Calculator Window. The Calculator Window is an interactive window. Enter
a CALC command in the expression box at the top of the window. For example, enter the CALC
command COV(Q1,P1). Then hit the return key on the keyboard. The results of this calculation will be
displayed in the window. Continue entering CALC commands one at a time in the expression box. Each
result will be displayed in the window. To enter CALC commands in the expression box, you can also use
the insert function box. To do so, click the x button to the right of the expression box. This opens the
insert function dialogue box. On the right hand side of this dialogue box, you will see a list of CALC
command names. Click on the command that you want. Click on the insert button. The general form of
the CALC command will appear in the expression box. Fill in the necessary information for your
particular calculation. Hit the return key.
Comment
The CALC command is similar to the CREATE command. The difference is that the CALC command is
used to calculate single values (scalars), while the CREATE command is used to calculate entire columns
of data. In addition, the CALC command can be used to look-up critical values for the normal, t, F, and
chi-square distributions.
DESCRIPTIVE STATISTICS
Example
Suppose you are using the Limdep data file CONSUMER.LPJ. You want to obtain descriptive statistics
for the variables P1, P2, P3, I, Q1, Q2, Q3. You also want Limdep to calculate the covariances and
correlation coefficients for the variables P1, P2, P3, I, Q1, Q2, and Q3.
Edit Window Command
DSTAT; RHS= P1, P2, P3, I, Q1, Q2, Q3; OUTPUT = 3 $
The DSTAT command tells Limdep to provide information on the mean, standard deviation, skewness,
kurtosis, minimum, maximum, and number of valid cases for each of these variables. The RHS
specification tells Limdep the variables for which to provide descriptive statistics. . The OUTPUT = 3
specification tells Limdep to calculate and show the covariance matrix and the correlation matrix for the
12
variables listed after RHS. If you only want the covariance matrix, use the specification OUTPUT = 1. If
you only want the correlation matrix, use the specification OUTPUT = 2.
Model Builder Procedure
Click Model on the Menu Bar. Click Descriptive Statistics on the Model Menu. This opens the dstats
dialogue box. Enter the necessary information. To request the covariance matrix and/or correlation
matrix, click the Options button. Click the box to the right of Display Covariance Matrix and/or Display
Correlation Matrix. Click the Run button.
LINEAR REGRESSION MODEL
Example
Suppose you are using the Limdep data file CONSUMER.LPJ. You want to use OLS to run a linear
regression of the log of Q1 on the log of P1, the log of P2, the log of P3, and the log of I. You also want
to print the variance-covariance matrix for the parameter estimates, and save the residuals and predicted
values for this regression.
Edit Window Commands
CREATE; LQ1 = LOG(Q1); LP1 = LOG(P1); LP2 = LOG(P2); LP3 = LOG(P3); LI = LOG(I) $
REGRESS; LHS = LQ1; RHS = ONE, LP1, LP2, LP3, LI; PRINTVC; KEEP = PREDICT;
RES = RESID $
The REGRESS command tells Limdep to run a linear regression using OLS. The LHS and RHS
specifications tell Limdep the dependent and independent variables. Note that Limdep does not
automatically include an intercept in the regression; if you want an intercept you must include ONE in the
RHS list. The PRINT specification tells Limdep to display the variance-covariance matrix of estimates
(VC). The KEEP specification tells Limdep to save the predicted (fitted) values of the dependent variable
as a new variable named PREDICT. The RES specification tells Limdep to save the residuals as a new
variable named RESID.
Model Builder Procedure
Create the logarithmic variables. To do so, click Project on the Menu Bar. Click New on the Project
Menu. Click Variable… on the New Menu. This opens the new variable dialogue box. Enter the necessary
information. Click the Run button. Click Model on the Menu Bar. Click Linear Models on the Model
Menu. Click Regression… on the Linear Models Menu. This opens the regress dialogue box. At the top
of the dialogue box, there are 3 tabs: Main, Options, Output. The Main tab is used to enter the
information dependent and independent variables. Click on the Output tab to enter information about
predicted values, residuals, and the variance-covariance matrix. Click the Run button.
Comment
Limdep saves the 17 matrix and scalar entries for the most recent regression that you run. You can then
use these matrices and scalars in any additional calculations you may want to perform. For example, you
want to find the inverse matrix of the variance-covariance matrix of estimates, VARB. You could do so
as follows. Click Tools on the Menu Bar. Click Matrix Calculator on the Tools Menu. This opens the
Calculator Window. Enter the command <VARB> in the expression box at the top of the window. Hit the
return key on the keyboard. The results of this calculation will be displayed in the window.
13
Testing and Imposing Linear Restrictions
The command specification “CLS:” allows you to test and /or impose one or more linear restrictions on a
linear regression model. Limdep designates the parameters of a linear regression model as B(1), B(2),
B(3), … according to the order of the variables in the RHS list. In the above example, B(1) is the
intercept, B(2) is the coefficient attached to LP1, B(3) is the coefficient attached to LP2, B(4) is the
coefficient attached to LP3, and B(5) is the coefficient attached to LI. Suppose that you want to test the
linear restriction B(2)+B(3)+B(4)+B(5) = 1. To do so, you would use the following REGRESS command
line.
REGRESS; LHS = LQ1; RHS = ONE, LP1, LP2, LP3, LI; CLS: B(2)+B(3)+B(4)+B(5) = 1 $
Limdep will estimate and report results for two models: 1) unrestricted model without the restriction, 2)
restricted model with the restriction imposed. As part of the results for the restricted model, Limdep will
report the value of the F-statistic and its P-value.
Suppose that you want to test the following two linear restrictions: B(2)+B(3) = 0 and B(4)+B(5) =10. To
do so, you would use the following REGRESS command line.
REGRESS; LHS = LQ1; RHS = ONE, LP1, LP2, LP3, LI; CLS: B(2)+B(3) =0, B(4)+B(5) = 10 $
When you have more than one restriction, each restriction is separated by a comma. You must always
express a restriction in a form such that a numerical value is to the right of the equal sign.
You could also use the Limdep model builder to test and/or impose linear restrictions. To do so, open the
regress dialogue box. After specifying the regression variables click the Options tab. Click the box to the
left of Impose and Test Restrictions. Then, in the box to the right type the restriction(s).
Testing Nonlinear Restrictions
Limdep has a separate command that can be used to test one or more nonlinear restrictions using a Wald
test. This is the WALD command. When a linear regression model is estimated, Limdep saves the
parameter estimates in the form of B_VARIABLE. In the above example, Limdep would save the
parameter estimates as B_ONE, B_LP1, B_LP2, B_LP3, and B_LI. Suppose that you want to test the
following nonlinear restriction: B(2)/B(3) + B(4)/B(5) = 0. To do so, place the following WALD
command line directly after the REGRESS command line as follows.
REGRESS; LHS = LQ1; RHS = ONE, LP1, LP2, LP3, LI $
WALD; FN1 = B_LP1 / B_LP2 + B_LP3 / B_LI $
The WALD command tells Limdep to test one or more nonlinear restrictions. The FN1 specification tells
Limdep the nonlinear restriction to test. Note that a nonlinear function must be written in a form that sets
FN1 equal to zero. Limdep will report the value of the Wald-statistic and its P-value after the results of
the unrestricted model in the output.
Suppose that you want to test the following two nonlinear restrictions: B(2)*B(3)/B(4) = 5 and B(1)*B(5)
+ B(2)*B(3) = 0. To do so, place the following WALD command line directly after the REGRESS
command line as follows.
REGRESS; LHS = LQ1; RHS = ONE, LP1, LP2, LP3, LI $
14
WALD; FN1 = B_LP1*B_LP2 / B_LP3 - 5; FN2 = B_ONE*B_LI + B_LP1*B_LP2 $
Note that each nonlinear restriction is designated by FN and a number (FN1, FN2). Each nonlinear
restriction is separated by a semicolon. Each nonlinear restriction must be written in a form that sets FN
equal to zero. Up to 20 nonlinear and/or linear restrictions can be given in a single WALD command.
Heteroskedasticity
Suppose that you believe heteroskedasticity exists. If so, then the estimated variance-covariance matrix
and hence standard errors of the regression coefficients will be biased and inconsistent, and tests of
hypotheses will be invalid. To obtain a consistent estimate of the variance-covariance matrix, you can use
White's heteroskedasticity consistent variance-covariance matrix estimator. To do this, use the command
specification HETERO. In the above example, you would use the following REGRESS command line.
REGRESS; LHS = lQ1; RHS = ONE, LP1, LP2, LP3, LI; HETERO $
If you are using the model builder procedure, open the regress dialogue box. Click the Options tab. Click
in the box to the left of Use Robust Covariance Matrix For. Click on the Down Arrow to the right of the
rectangular box. Click on Heteroskedasticity.
NONLINEAR LEAST SQUARES REGRESSION MODEL
Example
Suppose you are using the Limdep data file CONSUMER.LPJ. You want to define the new variable
Q1EXP = P1*Q1. You then want to use a nonlinear least squares (NLSQ) estimator to run a regression of
Q1EXP on P1, P2, P3, I, that is nonlinear in parameters. In particular, you want to estimate a Stone-Geary
demand equation.
Edit Window Commands
CREATE; Q1EXP = P1*Q1 $
NLSQ;
LHS = Q1EXP;
LABELS = A, C, D, E;
START = 50, 0.5, 30, 40;
FCN = A*P1 + C*(I - A*P1 - D*P2 - E*P3) $
The CREATE command tells Limdep to create the new variable. The NLSQ command tells Limdep to
run a nonlinear least squares regression. Note that for clarity each command specification in the NLSQ
command line has been placed on a separate line. This is an acceptable way to write a command line
using Limdep. The LHS specification tells Limdep the dependent variable. The LABELS specification
tells Limdep which words, letters, symbols, etc. are to be interpreted as parameters in the regression
equation. In this example, the parameters to be estimated are designated by letters: A, C, D, E. Note that
you cannot designate parameters with letters and words such as B, S, RHO, SIGMA, VARB, etc. because
Limdep uses these names and letters to save regression results. The START specification tells Limdep the
starting value for each parameter. For example, the starting value for A is 50, for C is 0.5, etc. Starting
values are your best guess of the parameter values. If you do not have a best guess, then use zeros as your
starting values. However, you must give Limdep starting values. The FCN specification tells Limdep the
functional form to estimate. If you want to save the residuals and name this variable RESID, include the
RES=RESID specification. If you want to save the predicted (fitted) values of Q1 and name this variable
15
PREDICT, include the KEEP=PREDICT specification. If you want to change the maximum number of
iterations to, say 75, include the specification MAXIT=75. The default algorithm is
Davidson/Fletcher/Powell; however five other algorithms are also available.
Model Builder Procedure
Click Model on the Menu Bar. Click Nonlinear Regression on the Model Menu. Click NLSQ… on the
Nonlinear Regression Menu. This opens the NLSQ dialogue box. At the top of the dialogue box, there are
2 tabs: Main, Options. Click the desired tabs and provide the necessary information. Click the Run button.
Testing Linear and Nonlinear Restrictions
To test linear or nonlinear restrictions in the nonlinear least squares regression model, you can use the
WALD command. Suppose that you want to test the linear restriction 2*D = E. To do so, include the
following WALD command line after the NLSQ command.
WALD; FN1 = 2*D – E $
Limdep will report the value of the Wald-statistic and its P-value after the results of the nonlinear least
squares regression model in the output.
LINEAR SEEMINGLY UNRELATED REGRESSIONS MODEL
Example
Suppose you are using the Limdep data file CONSUMER.LPJ. You want to estimate the parameters of
two linear equations jointly. For equation 1, the dependent variable is Q1. The independent variables are
P1, P2, P3, and I. For equation 2, the dependent variable is Q2. The independent variables are P1, P2, and
I.
Edit Window Command
SURE;
LHS = Q1, Q2;
EQ1 = ONE, P1, P2, P3, I;
EQ2 = ONE, P1, P2, I $
The SURE command tells Limdep to use the seemingly unrelated regressions estimation procedure to
estimate the set of linear regressions jointly. The LHS specification tells Limdep the dependent variable in
each equation. The EQ1 specification tells Limdep the independent variables for equation number 1. The
EQ2 specification tells Limdep the independent variables for equation number 2. If you do not include a
MAXIT specification, then Limdep will use an iterated FGLS estimator to obtain estimates of the
parameters. Limdep will iterate until convergence is achieved. If you include the specification MAXIT=1,
then Limdep will use a FGLS estimator to obtain estimates of the parameters. To do this, Limdep will
stop after one iteration.
Model Builder Procedure
Click Model on the Menu Bar. Click Linear Models on the Model Menu. Click SURE… on the Linear
Models Menu. This opens the SURE dialogue box. At the top of the dialogue box, there are 2 tabs: Main,
Options. Click the desired tabs and provide the necessary information. Click the Run button.
16
Testing and Imposing Linear Restrictions
The command specification “CLS:” allows you to test and /or impose one or more linear restrictions on
the parameters of a SURE regression model. Limdep designates the parameters of the model as B(1),
B(2), B(3), … according to the order of the variables in the EQ1 and EQ2 lists. In the above example,
B(1) is the intercept in equation 1, B(2) is the coefficient attached to P1 in equation 1, B(3) is the
coefficient attached to P2 in equation 1 B(4) is the coefficient attached to P3 in equation 1, B(5) is the
coefficient attached to I in equation 1, B(6) is the coefficient attached to the intercept in equation 2, B(7)
is the coefficient attached to P1 in equation 2, B(8) is the coefficient attached to P2 in equation 2, and
B(9) is coefficient attached to I in equation 2. Suppose that you want to impose the linear restrictions
B(3) = B(7) and B(5) = B(9). That is, you want to impose the restrictions that the coefficient attached to
P2 in equation 1 is equal to the coefficient attached to P1 in equation 2, and the coefficient attached to
income in equation 1 is equal to the coefficient attached to income in equation 2. These are called “crossequation restrictions.” To do so, you would use the following SURE command line.
SURE;
LHS = Q1, Q2;
EQ1 = ONE, P1, P2, P3, I;
EQ2 = ONE, P1, P2, I;
CLS: B(3) – B(7) = 0, B(5) – B(9) = 0 $
Limdep will estimate and report results for two models: 1) unrestricted model without the cross-equation
restrictions, 2) restricted model with the cross-equation restrictions imposed. As part of the results for the
restricted model, Limdep will report the value of the Wald statistic and its P-value.
NONLINEAR SEEMINGLY UNRELATED REGRESSIONS MODEL
Example
Suppose you are using the Limdep data file CONSUMER.LPJ. You want to create two new variables:
Q1EXP = P1*Q1, and Q2EXP = P2*Q2. You want to estimate the parameters of two equations jointly
that are nonlinear in parameters. For equation 1, the dependent variable is Q1EXP. The independent
variables are P1, P2, P3, and I. For equation 2, the dependent variable is Q2EXP. The independent
variables are P1, P2, P3, and I. In particular, you want to estimate a system of two Stone-Geary demand
equations.
Edit Window Commands
CREATE; Q1EXP = P1*Q1; Q2EXP = P2*Q2 $
NLSURE;
LHS = Q1EXP, Q2EXP;
LABELS = A, C, D, E, F;
START = 0, 0, 0, 0, 0;
FN1 = A*P1 + C*(I -A*P1 - D*P2 - E*P3);
FN2 = D*P2 + F*(I -A*P1 - D*P2 - E*P3) $
The CREATE command tells Limdep to create the new variables. Note that the expression for each new
variable is separated by a semicolon. The NLSURE command tells Limdep to estimate two or more
equations that are nonlinear in parameters using the nonlinear seemingly unrelated regressions estimation
procedure. The LHS specification tells Limdep the dependent variables for the two equations. The
17
LABELS specification tells Limdep which words, letters, symbols, etc. are to be interpreted as parameters
in the regression equations. The START specification tells Limdep the starting value for each parameter.
In this example, zero is used as a starting value for each parameter. (Note: For a more detailed
explanation about labels and starting values, see the section entitled, NONLINEAR LEAST SQUARES
REGRESSION MODEL). The FN1 specification tells Limdep the functional form for equation 1. The
FN2 specification tells Limdep the functional form for equation 2. Note that in this example, “crossequation restrictions” were imposed. That is, the values of the parameter estimates for A, D, and E are
forced to be the same in both equations because the same letter is used to designate the parameters in each
equation.
Model Builder Procedure
Click Model on the Menu Bar. Click Nonlinear Regression on the Model Menu. Click NLSURE… on the
Nonlinear Regression Menu. This opens the NLSURE dialogue box. At the top of the dialogue box, there
are 2 tabs: Main, Options. Click the desired tabs and provide the necessary information. Click the Run
button
Testing Linear and Nonlinear Restrictions
To test linear or nonlinear restrictions in the nonlinear seemingly unrelated regressions model, you can
use the WALD command. Suppose that you want to test the linear restriction C = F. To do so, include the
following WALD command line after the NLSURE command line.
WALD; FN1 = C - F $
Limdep will report the value of the Wald-statistic and its P-value after the results of the nonlinear least
squares regression model in the output.
LINEAR TWO-STAGE LEAST SQUARES REGRESSION MODEL
Example
Suppose you are using the Limdep data file PRODUCER.LPJ. You want to use two-stage least squares to
run a linear regression of the log of OUTPUT on the log of LABOR and the log of CAPITAL. You
assume that OUTPUT and LABOR are endogenous variables. You assume that CAPITAL, LAND,
PCAPITAL, and POUTPUT are exogenous variables.
Edit Window Commands
CREATE; LOUTPUT = LOG(OUTPUT); LLABOR = LOG(LABOR);
LCAPITAL = LOG(CAPITAL) $
2SLS; LHS =LOUTPUT; RHS = ONE, LLABOR, LCAPITAL; INST = ONE, LCAPITAL, LAND,
PCAPITAL, POUTPUT $
The CREATE command tells Limdep to create the necessary variables. The 2SLS command tells Limdep
to run a linear two-stage least squares regression. The LHS and RHS specifications tell Limdep the lefthand side and right-hand side variables for the regression. The INST specification tells Limdep what
variables to use as instruments. The list of instruments must include any right-hand side variables that are
exogenous (CAPITAL, in the above example). The list of instruments can also include any other
exogenous variables in the data set that you want to use as instruments (LAND and PLABOR, in the
above example). If the regression equation includes a constant term, ONE, then you should also include
18
ONE in the list of instruments. Even if the regression equation does not include a constant term, most
often you will want to include ONE in the list of instruments.
Model Builder Procedure
Create the new variables. Then click Model on the Menu Bar. Click Linear Models on the Model Menu.
Click 2SLS… on the Linear Models Menu. This opens the 2SLS dialogue box. At the top of the dialogue
box, there are 3 tabs: Main, Options, Output. Click the desired tabs and provide the necessary
information. Click the Run button
Testing and Imposing Linear Restrictions
Same as for REGRESS. Use the CLS: specification.
Testing Nonlinear Restrictions
Same as for REGRESS. Use the WALD command.
NONLINEAR TWO-STAGE LEAST SQUARES REGRESSION MODEL
Example
Suppose you are using the Limdep data file PRODUCER.LPJ. You want to use a nonlinear two-stage
least squares estimator to run a regression of OUTPUT on LABOR and CAPITAL, that is nonlinear in
parameters. In particular, you want to estimate is a constant elasticity of substitution (CES) production
function. You assume that OUTPUT and LABOR are endogenous variables. You assume that CAPITAL,
LAND, PCAPITAL, and POUTPUT are exogenous variables.
Edit Window Command
NLSQ;
LHS = OUTPUT;
LABELS = A, E, C, D;
START = 2.1, 0.3, 0.1, 0.5;
FCN = A*(E*LABOR^(-C) + (1 - E)*CAPITAL^(-C))^(-D/C);
INST = ONE, CAPITAL, LAND, PCAPITAL, POUTPUT $
The command line is the same as the nonlinear least squares regression model. See section entitled
NONLINEAR LEAST SQUARES REGRESSION MODEL. The only difference is that you include the
specification INST. Testing linear and nonlinear restrictions is also the same as for the nonlinear least
squares regression model.
Model Builder Procedure
Click Model on the Menu Bar. Click Nonlinear Regression on the Model Menu. Click NLSQ… on the
Nonlinear Regression Menu. This opens the NLSQ dialogue box. At the top of the dialogue box, there are
2 tabs: Main, Options. Click the desired tabs and provide the necessary information. Click the Run button.
LINEAR THREE-STAGE LEAST SQUARES REGRESSION MODEL
Example
19
Suppose you are using the Limdep data file PRODUCER.LPJ. You want to estimate the parameters of
two equations jointly. Equation 1 is a production function. The left-hand side variable is the log of
OUTPUT. The right-hand side variables are the log of LABOR and the log of CAPITAL. Equation 2 is a
labor demand equation. The left-hand side variable is the log of LABOR. The right hand side variables
are the log of the real price of labor (LRPLAB), the log of the real price of capital (LRPCAP), and the log
of OUTPUT. You assume that LOUTPUT and LLABOR are endogenous variables. You assume that
LCAPITAL, LRPLAB, and LRPCAP are exogenous variables.
Edit Window Commands
CREATE; LOUTPUT = LOG(OUTPUT); LLABOR = LOG(LABOR); LCAPITAL = LOG(CAPITAL);
LRPLAB = LOG(PLABOR / POUTPUT); LRPCAP = LOG(PCAPITAL / POUTPUT) $
3SLS;
LHS = LOUTPUT, LLABOR;
EQ1 = ONE, LLABOR, LCAPITAL;
EQ2 = ONE, LRPLAB, LRPCAP, LOUTPUT;
INST = ONE, LCAPITAL, LRPLAB, LRPCAP $
The CREATE command creates the necessary variables. The 3SLS command tells Limdep to use the
three-stage least squares estimation procedure to estimate the set of linear regressions jointly. The LHS
specification tells Limdep the left-hand side variable in each equation. The EQ1 specification tells
Limdep the right-hand side variables for equation number 1. The EQ2 specification tells Limdep the
right-hand side variables for equation number 2. The INST specification tells Limdep the exogenous
variables to use as instruments. It you do not include a MAXIT specification, then Limdep will use an
iterated three-stage least squares estimator to obtain estimates of the parameters. If you include the
specification MAXIT=1, then Limdep will us a three-stage least squares estimator to obtain estimates of
the parameters. To do this Limdep will stop after one iteration.
Model Builder Procedure
Click Model on the Menu Bar. Click Linear Models on the Model Menu. Click 3SLS… on the Linear
Models Menu. This opens the 3SLS dialogue box. At the top of the dialogue box, there are 2 tabs: Main,
Options. Click the desired tabs and provide the necessary information. Click the Run button.
Testing and Imposing Linear Restrictions
Same as for SURE. Use the CLS: specification.
Testing Nonlinear Restrictions
Use the WALD command.
NONLINEAR THREE-STAGE LEAST SQUARES REGRESSION MODEL
Example
Suppose you are using the Limdep data file PRODUCER.LPJ. You want to estimate the parameters of
two equations jointly. Equation 1 is a constant elasticity of substitution (CES) production function, and
therefore it is nonlinear in parameters. The left-hand side variable is OUTPUT. The right-hand side
variables are LABOR and CAPITAL. Equation 2 is a labor demand equation that is linear in parameters.
20
The left-hand side variable is LABOR. The right hand side variables are the real price of labor (RPLAB),
the real price of capital (RPCAP), and OUTPUT. You assume that OUTPUT and LABOR are
endogenous variables. You assume that CAPITAL, RPLAB, and RPCAP are exogenous variables.
Edit Window Commands
CREATE; RPLAB = PLABOR / POUTPUT; RPCAP = PCAPITAL / POUTPUT $
NLSURE;
LHS = OUTPUT, LABOR;
LABELS = A, E, C, D, E, F, G, H;
START = 2.1, 0.3, 0.1, 0.5, 0, 0, 0, 0;
FN1 = A*(E*LABOR^(-C) + (1 - E)*CAPITAL^(-C))^(-D/C);
FN2 = E + F*RPLAB + G*RPCAP + H*OUTPUT;
INST = ONE, CAPITAL, RPLAB, RPCAP $
The command line is the same as the nonlinear seemingly unrelated regressions model. See section
entitled NONLINEAR SEEMINGLY UNRELATED REGRESSIONS MODEL. The only difference is
that you include the specification INST. Testing linear and nonlinear restrictions is also the same as for
the nonlinear least squares regression model.
Model Builder Procedure
Click Model on the Menu Bar. Click Nonlinear Regression on the Model Menu. Click NLSUR… on the
Nonlinear Regression Menu. This opens the NLSURE dialogue box. At the top of the dialogue box, there
are 2 tabs: Main, Options. Click the desired tabs and provide the necessary information. Click the Run
button.
BINARY PROBIT REGRESSION MODEL
Example
Suppose you are using the Limdep data file LABORSUPPLY.LPJ. Suppose that you want to estimate a
labor force participation equation for women. The dependent variable is LFP (a dummy variable). The
independent variables are WA, WE, KL6, K618, CIT, UN. You want to analyze the impact that each of
the independent variables has on the probability that a woman will choose to work. (the probability that
LFP =1).
Edit Window Command
PROBIT; LHS = LFP; RHS = ONE, WA, WE, KL6, K618, CIT, UN; MARGINAL EFFECTS $
The PROBIT command tells Limdep to obtain maximum likelihood estimates of the parameters of the
right-hand side variables using Newton's algorithm. The LHS specification tells Limdep the dependent
variable. The RHS specification tells Limdep the independent variables. The MARGINAL EFFECTS
specification tells Limdep to calculate and report the marginal effects of the independent variables on the
probability that the dependent variable will take a value of one.
Model Builder Procedure
Click Model on the Menu Bar. Click Binary Choice on the Model Menu. Click Probit… on the Binary
Choice Menu. This opens the PROBIT dialogue box. At the top of the dialogue box, there are 3 tabs:
21
Main, Options, Output. Click the desired tabs and provide the necessary information. Click the Run
button.
Comments
1. When you use the above command, Limdep will give you four sets of results. To obtain starting
values, Limdep runs an OLS regression of the left-hand side variable on the right-hand side variables (i.e.,
it estimates a linear probability model). Limdep reports the results from this regression. Next, Limdep
reports the results for the probit model. Next, Limdep reports estimates of the marginal effects of the
independent variables calculated at the sample means. Finally, Limdep reports a table that lists the
number of correct and incorrect predictions, using a threshold default value, for the model you estimate.
2. The probit estimation procedure will break-down under two conditions: 1) If either the number of 0s or
the number of 1s for the dependent variable is less than the number of independent variables in the model.
2) If an independent variable is a dummy variable and the dependent variable only takes on values of : a)
0 for a 0 value of the independent variable, b) 1 for a 0 value of the independent variable, c) 0 for a 1
value of the independent variable, d) 1 for a 1 value of the independent variable.
BINARY LOGIT REGRESSION MODEL
Example
Same as for the probit model.
Edit Window Command
LOGIT; LHS = LFP; RHS = ONE, WA, WE, KL6, K618, CIT, UN; MARGINAL EFFECTS $
The command line is the same as for the probit model, except the command name is LOGIT.
Model Builder Procedure
Click Model on the Menu Bar. Click Binary Choice on the Model Menu. Click Logit… on the Binary
Choice Menu. This opens the LOGIT dialogue box. At the top of the dialogue box, there are 3 tabs: Main,
Options, Output. Click the desired tabs and provide the necessary information. Click the Run button.
STOCHASTIC FRONTIER REGRESSION MODEL
Example
Suppose you are using the Limdep data file PRODUCER.LPJ. You want to estimate the parameters of a
Cobb-Douglas stochastic frontier production function. The left-hand side variable is the log of OUTPUT.
The right-hand side variables are the log of LABOR and the log of CAPITAL. You also want to calculate
the average technical efficiency of firms in the sample.
Edit Window Commands
CREATE; LOUTPUT = LOG(OUTPUT); LLABOR = LOG(LABOR); LCAPITAL = LOG(CAPITAL) $
FRONTIER; LHS = LOUTPUT; RHS = ONE, LLABOR, LCAPITAL $
CALC; LIST;
E = EXP(1);
22
SIGMASQU = (S^2*LMDA^2) / (1 + LMDA^2);
SIGMAU = SQR(SIGMASQU);
TE=2*E^(SIGMASQU / 2)*(1 - PHI(SIGMAU)) $
The CREATE command tells Limdep to create the necessary variables. The FRONTIER command tells
Limdep to use a maximum likelihood estimation procedure to estimate the parameters of the stochastic
frontier production function. The one-sided error term (U) is assumed to have a half-normal distribution.
The LHS and RHS specifications tell Limdep the left-hand side and right-hand side variables for the
production function. The CALC command line calculates the measure of average technical efficiency for
the Cobb-Douglas stochastic frontier production function. E is the base of the natural logarithm.
SIGMASQU calculates the estimate of the variance of the half normal disturbances. SIGMAU calculates
the square root of the variance of the half-normal disturbances. TE calculates the measure of average
technical efficiency.
Comments
1. To assume that the one-sided error term has a truncated normal distribution, include the command
specification MODEL = T. To assume that the one-sided error term has an exponential distribution,
include the command specification MODEL = E.
2. If you assume that the one sided error term has a truncated normal distribution, then the CALC
command given above can be used to calculate the measure of technical efficiency.
3. If you assume that the one sided error term has an exponential distribution, then to calculate the
measure of technical efficiency you must use the following CALC command.
CALC; LIST; TE = 1 / (1 + THETA) $
3. Limdep reports two sets of results. To obtain starting values, Limdep runs an OLS regression of the
left-hand side variable on the right-hand side variables. It reports the OLS results in the standard way.
Next, Limdep reports the results for the stochastic frontier production function. The output includes the
parameter estimates. The half-normal and truncated normal models also include an estimate of the
variance of the one-sided error term (Sigma-squared(u)), an estimate of the variance of the symmetric
error term (Sigma-squared(v)), an estimate of the square root of the ratio of Sigma-squared(u) to Sigmasquared(v) (Lambda), and an estimate of the square root of the variance of the combined one-sided and
symmetric error term (Sigma). Note that Limdep saves the results for Lambda and Sigma as LMDA and
S, respectively. It does not save the results for Sigma-squared(u) and Sigma-squared(v).
4. To estimate a stochastic cost function frontier, include the command specification COST. Make sure
that the appropriate cost function variables are include in the LHS and RHS specifications.
TRUNCATED REGRESSION MODEL
Suppose that you are have a sample Utah dairy farmers that is a subset of Limdep data file
PRODUCER.LPJ. This sample includes small and medium size dairy farms, but excludes large dairy
farms defined as dairy farms that produce 1 million pounds or more of milk per year. Thus, your sample
is drawn from a subset of the population of Utah diary farmers. You want to estimate the parameters of a
linear production function for milk. The dependent variable is OUTPUT. The right-hand side variables
are LABOR, CAPITAL, and LAND. In this case, the appropriate regression model is a truncated
regression model. This is because the distribution of the dependent variable is truncated at OUTPUT = 1
million pounds.
23
Edit Window Commands
To see what the truncated sample would look like, type the following command.
SORT; LHS = OUTPUT; RHS = CAPITAL, LABOR, LAND, POUTPUT, PLABOR, PCAPITAL,
PLAND $
The SORT command tells Limdep to sort the data in ascending order for a specific variable. The LHS
specification tells Limdep to sort the data in ascending order for the variable output. The RHS
specification tells Limdep to carry all remaining variables in the data set with OUTPUT. If you want to
sort the data in descending order add the specification ; DESC. Now, open the Data Editor Window and
display the data (see section entitled DISPLAYING AND EDITING DATA). The truncated sample will
be comprised of the first 61 observations because these observations are for dairy farms that produce less
than 1 million pounds of milk per year.
To create the truncated sample, type the following command.
REJECT; OUTPUT>=1000000$
This eliminates from the sample all dairy farms that produce 1 million pounds of milk or more.
The command for the truncated regression model is as follows.
TRUNCATION; LHS = OUTPUT; RHS = ONE, LABOR, CAPITAL, LAND; UPPER;
LIMIT = 1000000$
The command TRUNCATION tells Limdep to estimate a truncated regression model. The LHS and RHS
specifications tell Limdep the left-hand side and right-hand side variables for the regression. The UPPER
specification tells Limdep that the distribution of the left-hand side variable is truncated from above (i.e.,
the upper tail of the distribution is cut-off). The LIMIT specification tells Limdep that the distribution of
the left-hand side variable is truncated at the value 1000000
Model Builder Procedure
Click Model on the Menu Bar. Click Censoring and Truncation on the Model Menu. Click Truncation…
on the Censoring and Truncation Menu. This opens the TRUNCATED REGRESSION dialogue box. At
the top of the dialogue box, there are 2 tabs: Main, Options. Click the desired tabs and provide the
necessary information. Click the Run button.
Comments
1. Limdep reports two sets of results: OLS regression results and truncated regression results.
2. The parameter estimates that Limdep reports as standard output are estimates of the parameters for the
full population, not the subpopulation. In the example above, the estimates that Limdep reports in its
table of standard output are estimates of the marginal products for the population of Utah dairy farmers,
which includes large farms. These estimates are obtained even though the model was estimated using a
sample which excluded large farms.
24
3. If you want Limdep to calculate and report estimates of the marginal effects of the independent
variables on the dependent variable (in this example, estimates of the marginal products of the inputs) for
the subpopulation (in this example, the population of small and medium size farms), then include the
specification ; MARGINAL EFFECTS in the command line.
4. If the left-hand side variable is truncated from below, then eliminate the UPPER specification. Thus, by
default Limdep truncates the distribution of the dependent variable from below.
5. If you do not include the LIMIT specification, then Limdep will truncate the distribution at zero by
default.
TOBIT (CENSORED) REGRESSION MODEL
Example
Suppose you are using the Limdep data file LABORSUPPY.LPJ. You want to estimate an hours of work
equation for wives. The dependent variable is WHRS. The explanatory variables are KL6, K618, WA,
WE. Fifty of the 100 wives in the sample do not work, and therefore WHRS is zero for these 50
observations. However, we do have data for the explanatory variables for all 100 wives. In this case, the
distribution of the dependent variable, WHRS, is censored from below at zero. The appropriate
regression model is a Tobit (censored) regression model.
Edit Window Commands
TOBIT; LHS = WHRS; RHS = ONE, KL6, K618, WA, WE; MARGINAL EFFECTS $
The command TOBIT tells Limdep to estimate a censored regression model. The LHS and RHS
specifications tell Limdep the left-hand side and right-hand side variables for the regression. The
MARGINAL EFFECTS specification tells Limdep to calculate and report estimates of the marginal
effects of the explanatory variables on the dependent variable for the observed values of WHRS (wives
with positive hours of work and zero hours of work).
Model Builder Procedure
Click Model on the Menu Bar. Click Censoring and Truncation on the Model Menu. Click Tobit… on
the Censoring and Truncation Menu. This opens the TOBIT dialogue box. At the top of the dialogue box,
there are 2 tabs: Main, Options. Click the desired tabs and provide the necessary information. Click the
Run button.
Comments
1. The Tobit model can be thought of as a combination of a probit model and an OLS regression model.
In this example, the probit component represents the choice to work (WHRS > 0) or not work (WHRS <
0). The OLS regression component represents the choice of the number of hours to work if a woman
chooses to work.
2. Limdep reports two sets of results: OLS regression results and censored regression results.
3. The parameter estimates that Limdep reports as standard output are estimates of the marginal effects of
the explanatory variables on the latent variable interpretation of the dependent variable, not the observed
values of the dependent variable. In the example above, the latent variable interpretation of WHRS would
25
be an index of the desire to work. The marginal effects of the explanatory variables on the observed
values of the dependent variable are nonlinear functions of the parameter estimates and obtained by
including the specification MARGINAL EFFECTS.
4. If the left-hand side variable is censored from above, then you must include the specification UPPER.
Thus, by default Limdep censors the distribution of the dependent variable from below.
5. By default Limdep will censor the distribution at zero. If the distribution of the dependent variable is
censored at some value other than zero, you must include the specification LIMIT = followed by the
value at which the dependent variable is censored.
REGRESSION MODELS WITH SAMPLE SELECTION
Example
Suppose you are using the Limdep data file LABORSUPPY.LPJ. You want to estimate an hours of work
equation for wives who work. The dependent variable is WHRS. The explanatory variables are KL6,
K618, WA, WE. Fifty of the 100 wives in the sample work (observations 1 through 50). This sample of
50 working wives is not a random sample; rather it is a self-selected sample, because these women chose
to work, and hence self-selected into the sample. One way to correct for self-selection bias is to use a two
stage estimation procedure. In the first stage, the entire sample of 100 wives is used to estimate a probit
model of the choice to work or not work. This is called the selection equation. The dependent variable in
the probit model is a dummy variable that equals one if WHRS > 0 and zero if WHRS = 0. We assume
that two variables influence the work/no work choice: KL6 and CIT. In the second stage, we use the
parameter estimates from the probit model to calculate an estimate of the inverse of the Mills ratio. We
then include this as an additional variable in the hours of work equation and estimate this equation using
the ordinary least squares estimator. The inclusion of the inverse Mills ratio corrects the sample selection
bias.
Edit Window Commands
CREATE; WORKDUM = WHRS > 0 $
PROBIT; LHS = WORKDUM; RHS = ONE, KL6, CIT; HOLD $
SELECT; LHS = WHRS; RHS = ONE, KL6, K618, WA, WE $
The CREATE command creates the dummy variable to be used as the dependent variable in the probit
model. The PROBIT command tells Limdep to estimate the parameters of a probit model. (see BINARY
PROBIT REGRESSION MODEL). The LHS and RHS specifications tell Limdep the dependent and
explanatory variables for the probit model. The HOLD specification tells Limdep to save the results so
that they can be used to calculate an estimate of the inverse Mills ratio. The SELECT command tells
Limdep to run an OLS regression that includes the inverse Mills ratio as an additional right-hand side
variable. The LHS and RHS specifications tell Limdep the dependent and explanatory variables for the
selectivity corrected regression model.
Model Builder Procedure
Click Model on the Menu Bar. Click Censoring and Truncation on the Model Menu. Click Selection…
on the Censoring and Truncation Menu. This opens the SELECTION dialogue box. At the top of the
dialogue box, there are 2 tabs: Main, Options. Click the desired tabs and provide the necessary
information. Click the Run button.
26
MATRIX COMMANDS
Defining a Matrix
Example
Suppose that you want to create the following two matrices.
| 7 4 9 |
| 2 8 9 |
| 5 4 7 |
| 1 5 2 |
| 6 7 4 |
| 7 1 3 |
Edit Window Command
MATRIX; A = [7,4,9 / 2,8,9 / 5,4,7]; C = [1,5,2 / 6,7,4 / 7,1,3] $
The MATRIX command tells Limdep to create a matrix. The specification A = [7,4,9 / 2,8,9 / 5,4,7] tells
Limdep that the name of the matrix is A. The elements of the matrix must be placed inside square
brackets. In this example, the elements of the matrix A are the numbers 7 4 9 2 8 9 5 4 7. Limdep assigns
elements to the matrix in row-major order; that is, it fills the rows of the matrix from top to bottom. Each
element is separated by a comma, and each row is separated by /. The matrix C is created in the same
manner.
Comment
To see the matrices you have created, go to the Project Window. Click on the Data folder. Click on the
Matrices folder. Click on A. This opens a window for the matrix A. Click on C to see the matrix C. If you
want these matrices to be displayed in the Output Window, include the specification LIST; after the
MATRIX command. In this case, the command line would be as follows.
MATRIX; LIST; A = [7,4,9 / 2,8,9 / 5,4,7]; C = [1,5,2 / 6,7,4 / 7,1,3] $
Example
Suppose that you want to create the following two vectors, a column vector and a row vector.
| 5 |
| 2 |
| 9 |
| 1 8 9 |
Edit Window Command
MATRIX; D = [5 / 2 / 9]; E = [1,8,9] $
Defining a Matrix with Existing Data
Example
Suppose that you are using the Limdep data file CONSUMER.LPJ. You want to create to create a data
matrix. The first column of this matrix is a column of ones. The second column is the observations on P1.
27
The third column is the observations on P2. The fourth column is the observations on P3. The fifth
column is the observations on I.
Edit Window Command
NAMELIST; X = ONE, P1, P2, P3, I $
The NAMELIST command is used to define a single name which will be used for a group of variables.
One use for the NAMELIST command is to create a matrix from data that exists in a Limdep data file.
The specification X = ONE, P1, P2, P3, I tells Limdep that the name of the matrix is X. Each variable
listed to the right of the equal sign is a column vector of data in the matrix X. The data matrix X has
dimension 30x5 (30 rows and 5 columns). The number of rows in the matrix will always equal the
number of observations in the current sample. If you want to display this vector in the Output Window,
use the following command.
MATRIX; LIST; X = X $
When you open the output window, you will see a small box with a black outline that says Matrix: X.
Click inside the box on Matrix: X. This will display the data matrix X.
Example
Suppose that you want to create a column vector whose elements are the observations on the variable Q1.
Edit Window Command
No command is necessary. This column vector already exists, because Limdep interprets each variable in
the data file as a column vector of observations.
Comment
The data file CONSUMER.LPJ contains the following 7 column vectors: P1, P2, P3, Q1, Q2, Q3, I.
Defining an Identity Matrix
Example
An identity matrix is a square matrix with ones on the principal diagonal and zeros off the principal
diagonal. Suppose you want to create a 30x30 identity matrix named ID.
Edit Widow Command
MATRIX; ID = IDEN(30) $
The number inside parentheses defines the number of rows and columns of the matrix.
Defining a Diagonal Matrix from a Vector
Example
28
A diagonal matrix is square matrix that has nonzero elements on the principal diagonal and zeros off the
principal diagonal. Suppose that you want to create a diagonal matrix named DM from the vector Q1 in
the data file CONUMER.LPJ.
Edit Window Command
MATRIX; DM = [Q1] $
The matrix DM is a 30x30 square matrix. The elements on the principal diagonal are the same as the
elements in the vector Q1. The elements off the principal diagonal are all zeros.
Matrix Operations and Matrix Algebra
The following is an example of "some" of the matrix operations that can be done with Limdep's MATRIX
command. The command specifications below are given in the form NAME = OPERATION, where
NAME is the name of the matrix or scalar that results from the operation that is performed. If you do not
want to save the result of an operation for future use, you can omit the NAME = part of the specification
and include only the OPERATION. Many operations have more than one specification that can be used.
This is indicated below.
Example
After creating the matrices and vectors A, C, D, and E above, suppose you type the following command
line. A description the operation that will be performed is to the right of the command specification for
each operation.
Edit Window Command
MATRIX; LIST;
F1 = DTRM(A);
F2 = LOGD(A);
F3 = RANK(A);
F4 = TRCE(A);
F5 = A + C;
F6 = A*C;
F7 = A - C;
F8 = A';
F9 = <A>;
F10 = KRON(A,C);
F11 = A'C;
F12 = <A'C>;
F13 = C'<A>C;
or
or
or
F5 = MSUM(A,C);
F6 = MPRD(A,C);
F7 = MDIF(A,C);
or
F11 = A'*C ;
or
F13 = C'*<A>*C;
F1 is the determinant of A
F2 is the log of the determinant of A
F3 is the rank of A
F4 is the trace of A
F5 is the sum of A and C
F6 is the product A and C
F7 is the difference A and C
F8 is the transpose of A
F9 is the inverse of A
F10 is the Kroneker product of A and C
F11 is the transpose of A times B
F12 is the inverse of the transpose of A times B
F13 is the product of the transpose of C, the
Inverse of A, and C
F14 is the inverse of the transpose of A times the
inverse of C times A.
F15 is the product of A, C'C, and A
F16 is 10 times the matrix which is the inverse
of the transpose of A time A
F17 is the inverse of the transpose of A times the
diagonal matrix D times A
F14 = <A'<C>A>;
F15 = A*C'C*A;
F16 = 10*<A'A>;
or F15 = A*C'*C*A;
F17= <A'[D]A> $
29
Comments
1. The examples in column 1 show that certain operations can be performed with concise notation. In
these examples, products of many types of transposes and inverses can be performed without the
multiplication symbol (*). When doing matrix algebra calculations, Limdep treats these algebraic
expressions as a single matrix. See the Limdep Users Manual for more information on this.
2. If the dimensions of the matrices on which the operation is being performed is small, then the
command specifications in column 1 and column 2 are equally preferred. However, if the dimensions of
the matrices is large (e.g., the matrix is a data matrix), then the command specification in column 1 is
preferred, since these specifications use memory more efficiently.
Matrix Command Examples
The following are some examples of how Limdep's MATRIX command can be used.
Example
Suppose you are using Limdep data file CONSUMER.LPJ. You want to calculate estimates of the
parameters of the linear regression of Q1 on an intercept, P1, P2, and I, using the OLS estimator. You
then want to calculate the variance-covariance matrix for the parameter estimates.
Edit Window Commands
NAMELIST; X = ONE, P1, P2, P3, I $
MATRIX; LIST;
BETAHAT = <X'X>*X'Q1;
MATRIX;LIST;
Q1FITTED = X*BETAHAT;
RESID = Q1 - Q1FITTED;
RSS = RESID'RESID $
CALC;
SIGMASQ = RSS/25 $
MATRIX;LIST;
VCMATRIX = SIGMASQ*<X'X> $
The NAMELIST command creates the data matrix, named X, for the regression. Recall that Q1 is the
vector of observations on the dependent variable, because Limdep interprets each variable in the data file
as a column vector of observations. The first MATRIX command applies the OLS estimation rule to
calculate the vector of parameter estimates (BETAHAT). The second MATRIX command calculates the
residual sum of squares for the regression (RSS). The CALC command calculates the estimate of the error
variance (SIGMASQ). The last MATRIX command calculates the variance-covariance matrix for the
parameter estimates.
Example
Suppose you are using Limdep data file CONSUMER.LPJ. You want to run a regression of Q1 on an
intercept, P1, P2, P3, and I, and use an F-test to test the restriction that the sum of the coefficients
attached to P1, P2, P3, and I is equal to one.
Edit Window Commands
30
REGRESS; LHS = Q1; RHS = ONE, P1, P2, P3, I $
MATRIX; LIST;
R = [0, 1, 1, 1, 1];
SR = [1];
RBSR = R*B - SR;
RCOVR = R*VARB*R';
INVRCOVR = <RCOVR>;
F = RBSR'*INVRCOVR*RBSR $
The REGRESS command runs the regression. Note that Limdep saves the vector of parameter estimates
from the regression in a column vector named B. It also saves the variance-covariance matrix of
parameter estimates in a matrix name VARB. Both B and VARB can be used in the subsequent MATRIX
command. The MATRIX command forms the F-statistic: F = {(R*B - r)'*[R*COVB*R']-1(R*B - r)}/ J.
Example
Suppose you are using Limdep data file CONSUMER.LPJ. You want to run a regression of Q1 on an
intercept, P1, P2, P3, and I. You believe that the disturbances are heteroskedastic, and therefore you want
to construct White's heteroskedasticity corrected variance-covariance matrix for the parameter estimates.
Edit Window Commands
NAMELIST; X = ONE, P1, P2, P3, I $
REGRESS; LHS = Q1; RHS = ONE, P1, P2, P3, I; RES = RESID $
CREATE; RSS = RESID^2 $
MATRIX; LIST;
WHITEVC = <X'X>*X'[RSS]X*<X'X> $
The NAMELIST command creates the data matrix, named X, for the regression. The REGRESS
command runs the OLS regression. The CREATE command calculates the squared residuals for the
regression. The MATRIX command calculates White's heteroskedasticity corrected variance-covariance
matrix for the parameter estimates. Note that in the matrix calculation, Limdep treats <X'X>, X'[RSS]X,
and <X'X> as single matrices.
31
Download