Very important notice: Please update the Stata xthp module (xthp.ado). This version works correctly with `if'.
[NEW] Download xthp.R (right-click and save the link as xthp.R). This R module can handle weakly exogenous regressors.
source("xthp.R") dat <- read.csv("stata-data.csv") ivec <- dat$id tvec <- dat$year n <- length(unique(ivec)) ## The following lines are important y <- to.regular.panel(dat$y, ivec,tvec) x1 <- to.regular.panel(dat$x1,ivec,tvec) x2 <- to.regular.panel(dat$x2,ivec,tvec) w1 <- to.regular.panel(dat$w1,ivec,tvec) ## y: dependent, (x1,x2): strictly exogenous, ## w1: weakly exogenous xthp(y,n=n) # simple univariate dynamic panel hp <- xthp(y,x=cbind(x1,x2),w=w1,n=n) print(hp$coefficients)The first line of the $coefficients is for the AR(1) coefficient. The rests are for the strictly exogenous regressors (X1, X2) and the weakly exogenous regressors (W1).
Download xthp.ado (right-click and save the link as xthp.ado). Download the paper here.
use oildata tsset country year xthp oil xthp oil if year>1981 xthp oil lny lnp if year>1990
The Han and Phillips's (2006) estimator for the panel AR(1) model
yit=ai+uit, uit=r uit-1+eit,
where eit is iid across i and t is the OLS estimator (excluding the constant term) of the transformed dependent variable 2dyit+dyit-1 on dyit-1, where the d notation stands for the first difference operator. This estimator is consistent for all AR coefficient in (-1,1], and is asymptotically normal as NT increases. The standard error should be calculated in a customized way. It is remarkable that
When exogenous variables are present as in
yit=ai+b xit + uit,
so
yit-b xit=ai + uit, yit-r yit-1 = ai* + b(xit-r xit-1) + eit,
where ai*=ai(1-r), the r parameter and the b parameter can be determined simultaneously or one-by-one repeatedly using the above two equations. The current ado file estimates b using LSDV on the second equation based on the assumption that xit are strictly exogenous.