[R] MA process in panels

Philipp Grueber philipp.grueber at ebs.edu
Tue Mar 20 17:53:48 CET 2012


Dear R users,

I have an unbalanced panel with an average of I=100 individuals and a total
of T=1370 time intervals, i.e. T>>I. So far, I have been using the plm
package.

I wish to estimate a FE model like:

res<-plm(x~c+v, data=pdata_frame, effect="twoways", model="within",
na.action=na.omit)

…where c varies over i and t, and v represents an exogenous impact on x
varying over time but not over i. I discover significant time effects
comparing the above model with a plm(…,effect="individual", …)-model (using
pftest). 

MY PROBLEM:
I discover high levels of serial correlation in the errors. Including lags
of x, coefficients are significant at least put to 30 lags. If I set my
dataset to weekly observations (approx. 5 days = 1 week), the coefficients
of the lags are significant at least up to the 15th lag (I didn't test a
larger number of lags). The more lags I include, the less sections can be
included in my sample (the panel is unbalanced, i.e. data is not available
for the whole period for all individuals -- in fact, full data is available
for only few individuals).  

Checking the acf() and pacf() of x, I find that for the large majority of
individuals, x is an MA() process. That's plausible because it would explain
the high levels of autocorrelation. However, I do not know a lot about MA
models for panel data.  



Most books I have found so far only touch on MA processes in panels but do
not discuss the estimation problems and implementation in further details.
Therefore, I have the following questions:

1) Are there any issues specific to panel models with an MA component? 

2) Is there an implementation for panel MA models in R?

3) If not, I have thought about the following solution. Does this approach
provide correct/ reliable results?

_________________________________________

#Unfortunately, I was unable to create an appropriate panel dataset with an
MA process in the residuals. Maybe someone has an idea where to find such
data? Nevertheless you should be able to follow my subsequent thoughts:

# I should be able to get my (time- and sectionally) demeaned series as
follows:

res1<-plm(x~c+v,data=pdata_frame, effect="twoways", model="within",
na.action=na.omit))
dem_yt<-pmodel.response(res) 
demXt<-model.matrix(res)

# Given the demeaned series, I need to set the first observation(s) in each
cross-section to NA in order to avoid inter-sectional links in the lagged
residuals (i.e. in the MA component).
#Note: Delete the first n observations per section for a MA(n) regression.
For me, an MA(1) process should be fine (I hope):

n<-1
for ( i in unique(pdata_frame$i)){
	dem_yt[na.omit(pdata_frame$i)==i][1:n]<-rep(NA,n)
	demXt$c[na.omit(pdata_frame$i)==i][1:n]<-rep(NA,n)
	demXt$v[na.omit(pdata_frame$i)==i][1:n]<-rep(NA,n)
} 

#I think I should now be able to use standard ARIMA methods such as 

res2<-arima(x=dem_yt,xreg=demXt,order=c(0,0,1))

#Alternatively, I tried to obtain res2 using maxLik() from the maxLik
package, but I am not sure about how to specify the log-likelihood function: 

tslag <- function(x, d=l)
{
  x <- as.vector(x)
  n <- length(x)
  c(rep(NA,d),x)[1:n]
}

log_Lik<-function(param) {
b1<-param[1]
b2<-param[2]
b3<-param[3]
sigma<-param[4]
ll<- -0.5*N*log(2*pi) - N*log(sigma) -
sum(0.5*(dem_yt-(b1*demXt[,1]+b2*demXt[,2]) +
b3*tslag(dem_yt-(b1*demXt[,1]+b2*demXt[,2]),d=1))^2/sigma^2)
ll
}

res2<-maxLik(logLik=log_Lik,start=c(coef(res1),1,1),method="nr")
_______________________________________


Am I on the right track? Is there an easier way to do this? Did I miss
something important?

Any help is appreciated, thanks a lot in advance!

Best, 
Philipp


______________________
Philipp Grueber
EBS Universitaet fuer Wirtschaft und Recht
Wiesbaden, Germany





-----
____________________________________
EBS Universitaet fuer Wirtschaft und Recht
FARE Department
Wiesbaden/ Germany
http://www.ebs.edu/index.php?id=finacc&L=0
--
View this message in context: http://r.789695.n4.nabble.com/MA-process-in-panels-tp4489528p4489528.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list