2SLS Analysis


In this section, you will learn to carry out the 2SLS (Two Stage Least Square) analysis in STATA. We will explain in detail about this in the following steps:


Step 1: Upload the MS-Excel datasheet in STATA


Let us assume, the name of the MS-Excel datasheet is "Panel-Data-Representation.xlsx" and it is located in the path "D:\data\". Then the data upload command in STATA is given by:

import excel "D:\data\Panel-Data-Representation.xlsx", sheet("DATA") firstrow

Now click ENTER. Your data is uploaded in STATA.



Step 2: Define the data as panel data in STATA

Once the data is uploaded in STATA, we need to define the data to be panel data. For that purpose, we need to declare the cross-section and time-series ids in the data. Then the data declaration command in STATA is given by:

xtset CODE YEAR

Once you click ENTER, you will get the following:

panel variable: CODE (strongly balanced)
time variable: YEAR, 2001 to 2013
delta: 1 unit


Now your data is declared in STATA.



Step 3: Run the 2SLS estimation in STATA


Once the data is declared in STATA, you can run the 2SLS estimation. The basic command for running a 2SLS estimation in STATA is xtivreg. It has the option of running 2SLS estimation. In the dataset, there are five variables (POP, EC, PT, Y, and N), and for the purpose of analysis, we can assume Y as dependent variable, POP and EC as independent variables, and PT and N as the instrumental variables. Here, we are considering POP as the exogenous variable. While choosing instruments, you should always remember this: No. of instruments >= No. of exogenous variables. So, the command in STATA is given by:

xtivreg Y EC (POP = PT N), ec2sls

Once you click ENTER, you will get the following:



Now, look at the individual coefficients. The coefficients of POP and EC are significant at 1% level (look at the
p-values of the coefficients). The instrumental variables are shown below the estimation results.

Following these steps, you can easily carry out the 2SLS analysis in STATA. For more information on these tests and exploring other options of 2SLS estimation and the diagnostic tests, please give the following commands respectively in STATA:

help xtivreg

If the commands are not installed in STATA, then you will have to use the following commands respectively in STATA to find and install the codes:

findit xtivreg


Go Backfast_rewind
add