Reputation: 3324
I have spent much time looking for a special package that could run the Pesaran(2007) unit root test (which assumes cross-sectional dependence unlike most others) and I have found none. So, I decided to do it manually; however, I don't know where I'm going wrong, because my results are very different from Microsoft Excel's results (in which it is done very easily).
My data frame is made up of 22 countries with 506 observations of daily price indices. Following is the model to run using the Pesaran(2007) unit root test:
(i) With an intercept only
where $\overline{Y}$ is the cross-section average of the observations across countries at each time $t$ and $b$ is the coefficient of interest to us because it will allow us to compute the ADF test statistic and then determine whether the process is stationary or not.
I constructed each of these variables in the following way:
(Delta)Y(t)
dif.yt = diff(yt)
## yt is the object containing all the observations for a specific country
## (e.g. Australia)
Y(t-1)
yt.lag.1 = lag(yt, -1)
Y(bar)(t-1)
ybar.lag.1 = lag(c(rowMeans(x)), -1)
## x is the object containing my entire data frame
(Delta)Y(bar)(t-1)
dif.ybar.lag.1 = diff(ybar.lag.1)
(Delta)Y(bar)(t-2)
dif.ybar.lag.2 = diff(lag(c(rowMeans(x)), -2))
(Delta)Y(t-1)
dif.yt.lag.1 = diff(yt.lag.1)
(Delta)Y(t-2)
dif.yt.lag.2 = diff(lag(yt, -2)
After constructing each variable individually, I then run the linear regression
reg = lm(dif.yt ~ yt.lag.1[-1] + ybar.lag.1[-1] + dif.ybar.lag.1 +
dif.ybar.lag.2 + dif.yt.lag.1 + dif.yt.lag.2)
summary(reg)
It is obvious that the explanatory variables in my regression equation differ in length, so I'd like to know whether there is a way in R to make all the variables of equal length (perhaps with a function).
Also, I'd like to know whether the procedure I used was correct and if there are more optimal ways.
Upvotes: 1
Views: 1448
Reputation: 4826
library(dynlm)
#object class is a zoo or ts
reg = dynlm(d(yt) ~ (L(yt, 1) + L(ybar,1) + d(L(ybar,1) + ....
data = ~yourdata, start = .... other args)
summary(reg)
More details about the package: http://cran.r-project.org/web/packages/dynlm/dynlm.pdf
Upvotes: 1