Friday, August 23, 2019

STATA Commands for Panel Data


Command 1:
  For Descriptive Statistics, just put the following command and then press enter. 
       summarize
       Or
       summarize y x1 x2 x3…xn
For detail statistics
      summarize, detail
       or
      summarize y x1 x2 x3…xn, detail


Command 2:
   For Correlation Matrix, just put the following command and then press enter.
      corr
      Or
      corr  y x1 x2 x3 …. xn


Command 3:
For Pooled OLS, just put the following command and then press enter.
reg         
Or   
reg y x1 x2 x3…. xn
regress
Or  
regress y x1 x2 x3 …. xn

Command 4:
For Robust Regression, just put the following command and then press enter.
reg y x1 x2 x3…. xn, robust 
Or  
regress y x1 x2 x3 …. xn, robust


Command 5:
   For Durbin Watson test and variance inflation factor (VIF) and Ramsey Reset test for omitted variables, just set the time and run OLS regression and then put the following commands, respectively.
   gen =_n
   tsset time                         (Time Series data)
  reg y x1 x2 x3…. xn
  dwstat
  vif
  ovtest  

Command 6:

   For Hausman test, just set the ID and time for panel data and run GLS regression by the following commands, respectively.
   xtset id time, yearly
   xtreg y x1 x2 x3….xn, re
   estimate store re
   xtreg y x1 x2 x3….xn, fe
   estimate store fe
   hausman fe re

Command 7:
   For Chow test (F-Limer Test or Redundant Fixed Effect), just set the ID and time for panel data and run GLS regression by the following commands, respectively.
    xtreg y x1 x2 x3….xn, re
    test x1 x2 x3 
Command 8:
   For Breusch and Pagan Lagrangian multiplier test for random effects, just set the ID and time for panel data and run GLS regression with random effects and then press the command of LM test, respectively.
xtreg y x1 x2 x3….xn, re
xttest0
Command 9:

   For Wooldridge Test of Autocorrelation in Panel data, run OLS regression and then press the following commands of Wooldridge Test, , respectively.
        reg y x1 x2 x3….xn
        ssc install xtserial
        ssc findit xtserial
        net sj 3-2 st0039
        net install st0039 
        xtserial y1 x1 x2 x3….xn           

Command 10:
   For Cross-sectional time-series FGLS regression, press the following commands, respectively.     
        xtgls y x1 x2 x3….xn
Note:
Coefficients:  generalized least squares
Panels:      Homoskedastic
Correlation:   No autocorrelation
Command 11:
   For Mixed-effects ML regression
 xtmixed y x1 x2 x3 ….xn

Command 12:
   For Jerque Berra test of normality, press the following commands, respectively.
       ssc install jb
    jb y
       jb x1
       jb x2
       jb x3

       jb resid 

No comments:

Post a Comment