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

2005-02-11 Thread David Hugh-Jones
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,

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

2005-02-11 Thread Doran, Harold
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

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

2005-02-11 Thread David Hugh-Jones
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

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

2005-02-10 Thread Doran, Harold
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

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

2005-02-10 Thread David Hugh-Jones
That's very helpful - I was on the point of giving up and going with Stata! I will look into that in more detail. I assume that afterwards it would be ok to apply the Beck and Katz procedure to get panel corrected standard errors. Cheers David On Thu, 10 Feb 2005 12:36:32 -0500, Doran, Harold

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

2005-02-10 Thread David Hugh-Jones
Assuming I have years in YEAR and state ids in ID, I guess the correlation ought to be corAR1(form = ~ YEAR | ID) ? Thanks a lot, David On Thu, 10 Feb 2005 12:36:32 -0500, Doran, Harold [EMAIL PROTECTED] wrote: In the nlme package you can find the gls() function to account for

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

2005-02-10 Thread Prof Brian Ripley
Are the years equally spaced and in time order? If so, it probably doesn't matter, and if not you may want corCAR1 not corAR1. On Thu, 10 Feb 2005, David Hugh-Jones wrote: Assuming I have years in YEAR and state ids in ID, I guess the correlation ought to be corAR1(form = ~ YEAR | ID) ? Thanks a