Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 21

TUTORIAL HOW TO RUN PANEL DATA ANALYSIS BY USING STATA (COMPARED

TO EVIEWS RESULT)
22.40.00 Analisis Data Panel, English Version, STATA 6 comments

TUTORIAL HOW TO RUN PANEL DATA ANALYSIS BY USING STATA (COMPARED


TO EVIEWS RESULT)

Hello friends,, How are you?? Hope that everything gonna be alright okay?? Hahaha.. Now, I
wanna post again in my blog wajibstat.blogspot.com. The topic is about how to run panel data
analysis by using STATA 10 (Tutorial) and then compared to Eviews.

Formerly, I have ever posted a writing about how to run panel data analysis in Eviews include
the stasionerity test (Levin, ADF), the best model from Chow and Hausman Test and how to
interpret the individual effect for random effect model.

As we know, Chow Test is used to compare common effect model/Pools to fixed effect
model(FEM) , then Hausman is to compare random effect model (REM) to fixed effect model
(FEM). For your understanding, you can check it here friends. Just click buddy hahaha..

At this moment I wanna give you the examples and tutorials how to optimize STATA at Panel
Data Analysis. Firstly, you should download the excel.xls data here. In this research, I use 20
cross section as the ID (countries), 26 periods (from 1960-1985) and three variables viz: GDP as
the dependent variable then Population (Pop) and Saving for the independent one.

The first way, I should tell you that in STATA, we can’t use string variable so we create all
variables to be numeric. I suggest you to read my former writings about STATA before
executing this step.. Notice that this string variables will be denoted by “s” and the numeric will
be denoted by “g”. Okay, let’s input the data in excel to STATA. We have a copied excel data at
StTATA. For your ease, here I show you the first view of STATA.
Firstly, you can set the maximum memory for this analysis by writing syntax: set mem 100M

This means that we have set the memory for this analysis process up to 100 Megabyte. It’s
important for us to set this especially when we will work with a great deal data and variables. If
you don’t set it at the beginning, then you will lose your work output when you try to reset it in
the processing moment. Here is the output, friends..
In addition, you can set the maximum observation, the default in STATA is 400. In this research,
we own 520 observations. Then, you can set yout maximum observation by writing this
syntax: set matsize 5000
INPUTTING DATA

To copy the data from excel to STATA, first you must open the STATA spreadsheet with
syntax: edit

After the spreadsheet opened, you can copy the data from excel file to STATA spreadsheet. Here
is the illustration:
Then you can close the spreadsheet to rename the all the variables by writing syntax alike:
Okay friends, now we set the data to panel data set in order that, this STATA can read our data
and set them to the panel data system.. Click statistics, Longitudinal/Panel Data, Declare Dataset
to be Panel Data. Here is the illustration:

In Panel ID variable, just fill it with variable “country”. Then, please sign at Time Variable and
fill it with variable “year”. Keep the button at use format of time variable. OK.
To see the individual variability of each variable, we can use syntax: xtsum gdp pop saving

Here is the result..


Okaaaay, now let’s we go to the estimation.. First, we run common effect model (ordinary least
square regression) by using syntax: regress gdp pop saving

Here is the Common Effect Output:

In this case, I need not interpret this result because I have ever told you how to interpret this in
former writings. Okay, now we run the fixed effect model for panel data analysis by clicking
Statistics, Longitudinal/Panel Data, Linier Regression (FE, RE, PA, BE). Illustrated below:
In dependent variable just fill it with “GDP”. Meanwhile for the independent variables, input
variables “Pop” and “Saving”. Then, in Model Type, check at Fixed effect, OK. Illustrated
below:

Here is the Fixed Effect Output:


Besides showing the partial test for variable population and saving, this output can also show the
Chow Test that compare Common Effect with Fixed Effect (Common VS Fixed). The rejection
area (rejecting the null hypothesis is the Prob of cross section F. Just see the Ftest that all etc on
the bottom of the output.

We have known that the alternating hypothesis is always “fixed effect model chosen”. See that
Prob F is 0,0000 smaller than Alpha 5%, so we reject the null hypothesis and take the fixed
effect is better than pool/common. The other way to run Fixed Effect, you just only write
syntax: xtreg gdp pop saving, fe

Now, we want to get the individual effect for each countries by LSDV (Least Square Dummy
Variable). Firstly, we write the syntax: tabulate country, gen(country)

Here is the result:


Then, write this syntax: regress gdp pop saving country1-country20, noconst

Then, we get the result like this:


Okay, now let’s run the estimation for random effect model. Just the sama with fixed, we just
click GLS Random Effects at Model Type. Here is the result:

The other way to run Random Effect, you just only write syntax: xtreg gdp pop saving, re
The intercept or constant parameter of random effect estimation output shows common mean
value to intercept. The differences among individuals or countries to the intercept are reflected
from random error component. We can get the random error component per individuals by write
syntax: predict rec, u. The result can be seen in spreadsheet just by writing syntax: browse. This
is the result overview..

To get the difference value per individual through random error component to common mean
value of intercept, we need to sum constanta (_cons) and random error component per individual.
Just write this syntax: gen diffrand=_cons+rec. Here is the result diffrand overview on
spreadsheet STATA:
Okay, now let’s go to the Hausman Test to compare Random Effect with Fixed Effect (Random
VS Fixed). Just write this syntax one by one (push enter per syntax)

xtreg gdp pop saving, re (push enter)

hausman fixed (push enter)

And here is the Hausman Test Result


We can see that Prob Chi Square is 0,0888 larger than Alpha 5% so we have to accept the null
hypothesis and take the random effect model as the better model than fixed one.

The last way, we can ensure that Random Effect is the chosen model by executing Lagrange
Multiplier Test (LM Test) to compare Common Effect/Pools with Random Effect (Common VS
Random). The null hypothesis is common effect model is better than random. Here is the way to
do so.. Click Statistics, Longitudinal/Panel Data, Linier Models, LM test for Random Effects.
Then, a dialog box will approach. Just click OK.
Here is the LM Test Result:
The other way to run LM Test, you just only write syntax: xttest0

Pay attention to Prob of ChiSquare 0,0000 smaller than Alpha 5%. We reject the null hypothesis
and get Random Effect Model is the best model (chosen model) for this analysis. So, you can
interpret the result of this Random Effect Model for your analysis.

Okay friends, that’s all that I can explain you the tutorials of how to ecexute Panel Data Analysis
by using STATA. For better comprehension, you can see the result when I do this analysis by
Eviews.

Common Effect Model/Pool output


Fixed Effect Model Output

Chow Test Output (Common VS Fixed)


Random Effect Model Output
Hausman Test Output (Random VS Fixed)

In Eviews, we cannot execute the LM Test (Common VS Random) alike STATA. Again, we can
see that there’s a different result between Eviews and STATA at Common Effect Model (Pooled
Model). One thing you should know, STATA can give the same result with SPSS while
executing this Common Effect Model but it’s different with Eviews result. However, for the
coefficiens of independent variables for fixed and random effect model in STATA output
resembles with the Eviews Result.

Here is the result when I try to use SPSS to regress these three variables..
In the other hand, the difference value for individual (constanta+random error component) gives
the more detailed result in Eviews instead of STATA. Okay friends, just keep loyal with this
blog. I wanna give more and more statistical analysis in wajibstat.blogspot.com. Hope that this
post can be useful for us. Be energic, keep spirit at studying and be blessed :-)

You might also like