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.

- Copy the file to your working directory.
- Run as the following example:
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).

- Estimates with only strictly exogenous regressors seem alright. But I haven't tested the validity of the program for models with weakly exogenous regressors.
- Strictly exogenous regressors are handled by LSDV.
**Weakly exogenous**regressors are handled by FOD (forward orthogonal deviation) transformation. Instruments are BOD (backward orghotnal deviation) transformed regressors. (Search Google for FOD and BOD.) Note that the**Stata**module**cannot**handle weakly exogenous regressors.

Download xthp.ado (right-click and save the link as xthp.ado). Download the paper here.

- Start Stata and determine the personal ado directory. This can be
done by running
`sysdir`in the Stata session and reading the output line starting with`PERSONAL`. - Copy the saved xthp.ado into this directory. (If the directory does not exist, create it.)
- Restart Stata, or run
`discard`.

- Open a stata dataset.
- Run
`tsset`to set the cross-sectional index and the time-series index (only once). - Run
`xthp`with proper arguments.- No exogenous variable: "
`xthp y`" - With exogenous variables: "
`xthp y x1 x2 x3`"

- No exogenous variable: "
- Note: When exogenous variables are included, the LSDV estimation is performed for them.

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

y_{it}=a_{i}+u_{it},
u_{it}=r
u_{it-1}+e_{it},

where e_{it} is iid across *i*
and *t* is the OLS estimator (excluding the constant term) of the
transformed dependent variable 2dy_{it}+dy_{it-1} on dy_{it-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

- the
*r*estimate is consistent for all*r*value including unity; and - the asymptotics holds as
*NT*increases regardless of the*N/T*ratio.

When exogenous variables are present as in

y_{it}=a_{i}+b x_{it} +
u_{it},

so

y_{it}-b x_{it}=a_{i} +
u_{it}, y_{it}-r y_{it-1} =
a_{i}^{*} + b(x_{it}-r x_{it-1}) +
e_{it},

where *a _{i}^{*}=a_{i}(1-r)*,
the