How to perform Panel data regression for random effect model in STATA?

By Saptarshi Basu Roy Choudhury & Priya Chetty on October 31, 2018

The previous article (Pooled panel data regression in STATA) showed how to conduct pooled regression analysis with dummies of 30 American companies. The results revealed that the joint hypothesis of dummies reject the null hypothesis that these companies do not have any alternative or joint effects. Therefore pooled regression is not a favourable technique for the panel data sets. It is also due to the fact that the inclusion of too many dummies can lead to the consequent loss of degrees of freedom. Therefore pooled regression is not the right technique to analyze panel data series. Therefore the present article intends to introduce the concept of the random effect model in STATA.

Ways to conduct panel data regression

There are two ways to conduct panel data regression; random-effects model and fixed-effect model. In a random effect model, the intercepts in the regression equation represent the mean values of cross-sectional intercepts. On the other hand, the error terms represent random deviations of individual intercepts from the mean value. Therefore internalise the effects of different cross-sections (in this case, 30 firms) as random effects in the regression equation. Since no joint or alternative effect appears in regression results, generate the effect estimates.

Conducting random effect model in STATA

Use the below command to start with random effect panel data analysis:

xtreg EBIT LTD Int, re

In the above syntax, “xtreg” represents the command Earnings Before Interest and Taxes (EBIT), Long Term Debt (LTD) and Interest payments (INT). These are the variables in the order of dependent and independent variables. “re” represents the random effects for the above panel data regression. The below results will appear.

Figure 1: Result of random effects model in STATA for panel data analysis
Figure 1: Result of the random effect model in STATA for panel data analysis

In the above results, both the independent variables have significant effects on the dependent variable EBIT.  Therefore,

  1. The coefficients of independent variable LDT and INT are significant with the p-value less than 0.05.
  2. The R square value also indicates the goodness of fit equals 68% which is significantly large.
  3. The rho value is 0.8516 which indicates the individual effects of cross-sections are 0.8%.

Since the data set is not normal, there are several implications in the random effect model. Although non-normal data in the case of panel regression does not have any direct impact when observations are above 83, it may have some indirect impacts. Due to lack of normality, the error variances may be unequal and the problem of heteroscedasticity may be present. To check this, use the below command.


The below result will appear.

Figure 2: Heteroscedasticity in panel data regression for random effect model in STATA
Figure 2: Heteroscedasticity in panel data regression for random effect model in STATA

The above figure represents the outcome of the Breusch and Pegan Lagrangian Multiplier test which helps to identify the presence of heteroscedasticity. The null hypothesis for the above test is homoscedasticity and the alternative hypothesis suggest heteroscedasticity. Since the p values are 0.000 reject the null hypothesis. Thus the above random effect model contains the problem of heteroscedasticity.

Use 5E25A5EE63214 to save 5000 on 15001 - 20000 words standard order of literature survey.
Order now

Correcting heteroscedasticity in the random effect model in STATA

In order to rectify the heteroscedasticity use another version of the random effect model known as ‘random effect with GLS’. Follow the below steps.

  1. Click on ‘Statistics’ in the main window.
  2. Go to ‘Longitudinal/ panel data’.
  3. Click on ‘Random coefficients regression by GLS’.

Or use the below STATA command.

xtrc EBIT LTD Int
Figure 3: STATA pathway for random GLS model
Figure 3: STATA pathway for random GLS model

The below window will appear. Here select the dependent and independent variables.

Figure 4: Conducting random effect GLS model in STATA
Figure 4: Conducting random effect GLS model in STATA

The results of the above GLS random effect model will appear.

Figure 5: Results of GLS random effect model in STATA
Figure 5: Results of the GLS random effect model in STATA

The above results show that the model takes care of the problem of heteroscedasticity Also the variable interest does not appear to be significantly different from the previous model. The overall random-effects model looks fine and indicates that the relationship between concerned variables is significant.

However, the results do not indicate if the randomness of this random effect model is correct and if it provides the effect set of solution. In order to determine that, it is necessary to perform the fixed effects model in the next article.


Priya is the co-founder and Managing Partner of Project Guru, a research and analytics firm based in Gurgaon. She is responsible for the human resource planning and operations functions. Her expertise in analytics has been used in a number of service-based industries like education and financial services.

Her foundational educational is from St. Xaviers High School (Mumbai). She also holds MBA degree in Marketing and Finance from the Indian Institute of Planning and Management, Delhi (2008).

Some of the notable projects she has worked on include:

  • Using systems thinking to improve sustainability in operations: A study carried out in Malaysia in partnership with Universiti Kuala Lumpur.
  • Assessing customer satisfaction with in-house doctors of Jiva Ayurveda (a project executed for the company)
  • Predicting the potential impact of green hydrogen microgirds (A project executed for the Government of South Africa)

She is a key contributor to the in-house research platform Knowledge Tank.

She currently holds over 300 citations from her contributions to the platform.

She has also been a guest speaker at various institutes such as JIMS (Delhi), BPIT (Delhi), and SVU (Tirupati).



4 thoughts on “How to perform Panel data regression for random effect model in STATA?”