Saturday, 14 May 2016

Panel Gmm using STATA




following pic is showing feature of GMM




























* Rule of thumb for avoiding over-identification of instruments is that the number of instruments be less than or equal to the number of groups in the regressions. (Barajas et al., 2013).

GMM is the method of choice for finance and asset pricing research these days.

GMM should be applied with more than 5 Time Periods (SIR MUHAMMAD ANEES)

Caselli et al. (1996) and Bond et al. (2001) show that the Generalized Methods of Moments (GMM) dynamic panel estimation is capable to correct for unobserved country heterogeneity, omitted variable bias, measurement error, and endogeneity problems frequently arise in growth estimation.

Problems with GMM
  1. The main problem of GMM, it doesn't consider cross sectional dependency and structural break. Moreover, 
  2. GMM isn't a good choice for long panel time series data.
The difference GMM
The difference GMM approach deals with this inherent endogeneity by transforming the data to remove the fixed effects. The standard approach applies the first difference (FD) transformation, which as
discussed earlier removes the fixed effect at the cost of introducing a correlation between yi;t􀀀1 and it , both of which have a term dated (t 􀀀 1). This is preferable to the application of the within transformation, as that transformation makes every observation in the transformed data endogenous to every other for a given individual. 
Note:
Note that in xtabond2 syntax, every right-hand variable generally
appears twice in the command, as instruments must be explicitly 
specified when they are instrumenting themselves.
The one disadvantage of the first difference transformation is that it magnifies gaps in unbalanced panels. If some value of yit is missing, then both yit and yi;t􀀀1 will be missing in the transformed data. This motivates an alternative transformation: the forward orthogonal deviations (FOD) transformation, proposed by Arellano and Bover (J. Econometrics, 1995).
System GMM
·         System GMM is developed by Arellano and Bover, 1995, and Blundell and Bond, 1998, and the method is considered more superior than difference GMM. Bond et al., 2001, argue this method is able to correct unobserved country heterogeneity, omitted variable bias, measurement error, and potential endogeniety that frequently affect growth estimation.
hHis technique combines in a system the relevant regressions expressed in first-differences and in levels.
Note: Instruments for differenced equations are obtained from values (levels) of explanatory variables lagged at least twice,  Instruments for levels equations are lagged differences of the variable.
WHAT IS AR 1 AND AR2 AND Sargan/Hansen
 As suggested by Arellano and Bond, 1991; Arellano and Bover, 1995; and Blundell and Bond, 1998, two specification tests are used. Firstly, Sargan/Hansen test of over-identifying restrictions which tests for overall validity of the instruments and the null hypothesis is that all instruments as a group are exogenous. the null hypothesis is that all instruments as a group are exogenous. Therefore higher p-value is better (insignificant). The second test examines the null hypothesis that error term of the differenced equation is not serially correlated particularly at the second order (AR2). One should not reject the null hypothesis of both tests.
WHY GMM?
Arellano–Bond (Arellano and Bond 1991) and Arellano–Bover/Blundell–Bond (Arellano and Bover 1995; Blundell and Bond 1998) dynamic panel estimators are increasingly popular Both are general estimators designed for situations with
 1) “small T, large N” panels, meaning few time periods and many individuals;
2)  a linear functional relationship;
3) one left-hand-side variable that is dynamic, depending on its own past realizations;
4)  independent variables that are not strictly exogenous, meaning they
are correlated with past and possibly current realizations of the error;
 5)  fixed individual effects;
 6. Heteroskedasticity and auto-correlation within individuals but not across them. Arellano–Bond estimation starts by transforming all Regressor, usually by differencing.
Diagnostics about GMM
GMM diongnostic.s
1. Consistency of the GMM estimator depends on the validity of the instruments.

2. As suggested by Arellano and Bond (1991), Arellano and Bover(1995), and Blundell and Bond (1998), two specification tests are used: Sargan/Hansen test and serial correlation test (AR(1) & AR(2)).

3. Sargan/Hansen test of over-identifying restrictions which tests for overall validity of the instruments

4. the null hypothesis is that all instruments as a group are exogenous. Therefore higher p-value is better (insignificant

5. Serial correlation test examines the null hypothesis that error term of the differenced equation is not serially correlated at the first order (AR1) and second order (AR2). So again we need higher p-value here.

6. By construction, the differenced error term is probably serially correlated at AR(1) even if the original error is not. Differenced error term at AR (1) process is and and both have uit-1

7. AR(2) test is most important since it will detect autocorrelation in levels. AR(2) process is and

8. While most studies that employ GMM dynamic estimation report the test for first order serial correlation, some do not.(Mahyudin Ahmad Studied Development economics at University of Leicester& Cambridge)
Dynamic Panel data model
Lets do it practically  COMMANDS FOR PANEL GMM
Ø 1.Difference GMM
Ø 2.System GMM
Ok let’s start and playing with commands
Now I’m going to run panel Gmm (Differenced Gmm)
First of all I have my variables
Dependent variables = Iit is gross fixed capital formation as percentage of GDP (INV)
Independent variables=
FDI (fdi),
Loans (loans),
portfolio (equity and bonds) (portfolio)
 control variables.
lagged real GDP growth (growth) – as accelerator effect
growth forecast error (uncert) – as measure of uncertainty
change in log terms of trade (tot) – to proxy for price of imported capital goods
deviation of M2 from 3-year trend (dev_m2) – to proxy for liquidity available to                     finance investment
 Endogenous variables
Inv
 Fdi
 Loans
 Portfolio
Step one I am going to run gmm /differenced gmm
1.      First install following command
Write sscinstall xtabond2
2.      Then declare your data panel
3.      Then set time.
4.      This is command of difference Gmm
xtabond2 inv l.inv fdi loans portfolio l.growth uncert tot dev_m2, gmm (inv fdi loans portfolio, lag (2 2)) iv(fin_integr trans_index flows_eeca l.growth uncert tot dev_m2) nolevel small
xtabond2= is command for Gmm
inv    =dependent variable
l.inv  = used dependent lag as explanatory variable (actually Gmm is panel dynamic model so in dynamic models we used dependent lags as independent)
Independent variables=
FDI (fdi),
Loans (loans),
portfolio (equity and bonds) (portfolio)
 control variables.(if u also have control variables u should use)
lagged real GDP growth (growth) – as accelerator effect
growth forecast error (uncert) – as measure of uncertainty
change in log terms of trade (tot) – to proxy for price of imported capital goods
deviation of M2 from 3-year trend (dev_m2) – to proxy for liquidity available to                     finance investment
 Endogenous variables
Inv
 Fdi
 Loans
 Portfolio
gmm (inv fdi loans portfolio, lag (2 2))= here I m saying to stata use inv fdi loan etc as endogenous variables while use all these variables as instrumental
With lag (2 2) I have instructed Stata to use only the second lag of the endogenous variables as instruments. Due to the small number of countries in my sample a large number of instruments causes the Sargan test (explained below) to be weak. The rule of thumb is to keep the number of instruments less than or equal to the number of groups. Stata warns you about that at the top of the output table. The second lag is required, because it is not correlated with the current error term, while the first lag is. Generally, one can experiment with a second or deeper lags to find a good instrument, but using deeper lags reduces sample size. If the number of countries is large enough, one may use all available lags (second and deeper lags) as instruments.
iv(fin_integr trans_index flows_eeca l.growth uncert tot dev_m2)
The second list of explanatory variables, iv ( ) (or ivstyle ( )), lists all strictly exogenous variables (l.growth, uncert, tot, dev_m2) as well as the additional instrumental variables (fin_integr, trans_index, flows_eeca), which are not part of equation (1) and, therefore, are not listed before the comma in the Stata command. What this option essentially does for the included exogenous variables is tell Stata to use the variables themselves as their own instruments. Note: Growth is lagged in this case due to economic theory and not because it is required by the regression.
nolevel small= nolevel (or noleveleq) tells Stata to apply the difference GMM estimator. By default xtabond2 will apply the system GMM, if you don’t specify nolevel. (System GMM is discussed next.)
small tells Stata to use the small-sample adjustment and report t- instead of z-statistics and the Wald chi-squared test instead of the F test.
SYSTEM GMM


xtabond2 inv l.inv fdi loans portfolio l.growth uncert tot dev_m2, gmm (inv fdi loans portfolio, lag (2 2)) iv(fin_integr trans_index flows_eeca l.growth uncert tot dev_m2) small
JUST removie nolevel

Detail about panel gmm commands Here
good luck just pray for me...

1 comments:

Anonymous said...

bro, this is brilliant, thank you!

Search