[R] correcting for autocorrelation in models with panel data?

David Hugh-Jones davidhughjones at gmail.com
Fri Feb 11 16:15:06 CET 2005


Specifically the Beck and Katz article points out that "Feasible GLS",
which involves a special method for correcting standard errors for
panel data, doesn't work when time period is less than number of
individuals. They suggest using OLS, then correcting the standard
errors. But their method does not correct for autocorrelation over
time - only for heteroskedasticity and correlation between different
units at time t.

Cheers
David


On Fri, 11 Feb 2005 06:12:30 -0500, Doran, Harold <HDoran at air.org> wrote:
> No, by definition the off-diagonal elements in the covariance matrix for an OLS are 0. Thus, OLS is a special case of a GLS. You can see this if you write out the formulae for an OLS solution and GLS solution.
> 
> The typical solution for the standard errors in an OLS are (X'X)^{-1}*s^2. This is the same as (X'V^{-1}X)^{-1} when V= s^2*I, I being the identity matrix, which is also the gls solution.  But in the gls solution the off diagonal elements of V are covariances, not 0. In the case of autocorrelation (AR1) the off-diagonal elements decay exponentially over time.
> 
> I'm not familiar with Beck and Katz or why they would recommend that OLS be used when the number of time units is smaller than the number of individuals in the data. But to me, this seems rather silly, isn't this often the case?
> 
> HTH
> Harold
> 
>         -----Original Message-----
>         From: David Hugh-Jones [mailto:davidhughjones at gmail.com]
>         Sent: Fri 2/11/2005 5:23 AM
>         To: Doran, Harold
>         Cc: r-help at lists.r-project.org
>         Subject: Re: [R] correcting for autocorrelation in models with panel data?
> 
>         Another question - is there a way to use autocorrelation with OLS,
>         rather than GLS?
>         I am really blindly following Beck and Katz (1995) here, and they
>         recommend OLS rather than "Feasible Generalized Least Squares" for
>         panel data where the number of individuals is larger than the number
>         of time units, which is my case.
> 
>         Cheers
>         David
> 
>         > On Thu, 10 Feb 2005 12:36:32 -0500, Doran, Harold <HDoran at air.org> wrote:
>         > > In the nlme package you can find the gls() function to account for
>         > > autocorrelation over time using corAR1. Syntax might look something like
>         > > this:
>         > >
>         > > fm1 <- gls(response ~ IV, long, correlation=corAR1(form=~1|ID),
>         > > method='ML')
>         > >
>         > > You can also use weights() for heteroscedasticity.
>         > >
>         > > -Harold
>         > >
>         > > -----Original Message-----
>         > > From: r-help-bounces at stat.math.ethz.ch
>         > > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of David Hugh-Jones
>         > > Sent: Thursday, February 10, 2005 12:15 PM
>         > > To: r-help at stat.math.ethz.ch
>         > > Subject: [R] correcting for autocorrelation in models with panel data?
>         > >
>         > > Hi
>         > >
>         > > I have some panel data for the 50 US states over about 25 years, and I
>         > > would like to test a simple model via OLS, using this data. I know how
>         > > to run OLS in R, and I think I can see how to  create Panel Corrected
>         > > Standard Errors using
>         > >
>         > > http://jackman.stanford.edu/classes/350C/pcse.r
>         > >
>         > > What I can't figure out is how to correct for autocorrelation over time.
>         > > I have found a lot of R stuff on time series models but they all seem
>         > > focused on predicting a single variable from its previous values.
>         > > Can anyone explain to me how to detect and get round autocorrelation?
>         > > Is there a package for panel data that I have missed?
>         > >
>         > > I appreciate that this is probably just as much about my ignorance of
>         > > econometrics as about R itself!
>         > >
>         > > Cheers
>         > > David
>         > >
>         > > ______________________________________________
>         > > R-help at stat.math.ethz.ch mailing list
>         > > https://stat.ethz.ch/mailman/listinfo/r-help
>         > > PLEASE do read the posting guide!
>         > > http://www.R-project.org/posting-guide.html
>         > >
>         > >
>         >
> 
> 
>




More information about the R-help mailing list