# If you run OLS regression on cross sectional data, should you test for autocorrelation in residuals?

I have a set of observations, independent of time. I am wondering whether I should run any autocorrelation tests? It seems to me that it makes no sense, since there's no time component in my data. However, I actually tried serial correlation LM test, and it indicates strong autocorrelation of residuals. Does it make any sense? What I'm thinking is that I can actually rearrange observations in my dataset in any possible order, and this would change the autocorrelation in residuals. So the question is - should I care at all about autocorrelation in this case? And should I use Newey-West to adjust SE for it in case test indicates so? Thanks!

• You correctly said that without a time component your residuals cannot be serially correlated. So a test for serial correlation in this case is not valid. The most common concerns in cross-section data are heteroskedasticity or spatial correlation (e.g. crime rate in city A affects crime rate in city B), but both are easily corrected for with the robust and cluster options in Stata.
– Andy
Jul 27, 2013 at 6:54
• Let's try to rephrase this without using the terms serial correlation or autocorrelation. The dependent variable of a regression model has a conditional variance matrix, ie conditional on the independent variables. We expect that the diagonal elements of the matrix, ie the conditional variances of the elements of y, will be non-zero. If the model is cross-sectional, can we infer that the off-diagonal elements, ie the covariances of pairs of elements of y, must be zero? Surely the lack of a time series interpretation doesn't eliminate this possibility, although it may make it less likely? Jul 27, 2013 at 10:33
• ... One example as Andy suggests would be covariance between spatially related elements. A possible non-spatial example is where the dependent variable is GNP in different countries (at the same time), where two countries far apart might have close trade links (eg for historical reasons) resulting in non-zero covariance. Jul 27, 2013 at 11:49
• When your data has clusters, cross-sectional dependence is possible. You may adjust the S.E. as @Andy suggested. One remark about cluster-robust S.E. is that the robust S.E. works if each cluster in data is small and there are many clusters observed. However, if you have a few large clusters, the cluster robust S.E. is not valid. Indeed, in the large cluster case, the pooled OLS could be inconsistent. You can refer Andrews (2005, Econometrica) for reference. Jul 27, 2013 at 22:23

The true distinction between data, is whether there exists, or not, a natural ordering of them that corresponds to real-world structures, and is relevant to the issue at hand.

Of course, the clearest (and indisputable) "natural ordering" is that of time, and hence the usual dichotomy "cross-sectional / time series". But as pointed out in the comments, we may have non-time series data that nevertheless possess a natural spatial ordering. In such a case all the concepts and tools developed in the context of time-series analysis apply here equally well, since you are supposed to realize that a meaningful spatial ordering exists, and not only preserve it, but also examine what it may imply for the series of the error term, among other things related to the whole model (like the existence of a trend, that would make the data non-stationarity for example).

For a (crude) example, assume that you collect data on number of cars that has stopped in various stop-in establishments along a highway, on a particular day (that's the dependent variable). Your regressors measure the various facilities/services each stop-in offers, and perhaps other things like distance from highway exits/entrances. These establishments are naturally ordered along the highway...

But does this matter? Should we maintain the ordering, and even wonder whether the error term is auto-correlated? Certainly: assume that some facilities/services on establishment No 1 are in reality non-functional during this particular day (this event would be captured by the error term). Cars intending to use these particular facilities/services will nevertheless stop-in, because they do not know about the problem. But they will find out about the problem, and so, because of the problem, they will also stop in the next establishment, No 2, where, if what they want is on offer, they will receive the services and they won't stop in establishment No 3 - but there is a possibility that establishment No 2 will appear expensive, and so they will, after all, try also establishment No 3: This means that the dependent variables of the three establishments may not be independent, which is equivalent to say that there is the possibility of correlation of the three corresponding error terms, and not "equally", but depending on their respective positions.

So the spatial ordering is to be preserved, and tests for autocorrelation must be executed -and they will be meaningful.

If on the other hand no such "natural" and meaningful ordering appears to be present for a specific data set, then the possible correlation between observations should not be designated as "autocorrelation" because it would be misleading, and the tools specifically developed for ordered data are inapplicable. But correlation may very well exist, although in such case, it is rather more difficult to detect and estimate it.

Just adding another example (much more common) in which you will probably find autocorrelation in crossectional data, and is when you have groups of observations. For example, if you have the one math scores from a standardized exam of a thousand kids, but these kids came from 100 different schools, it would be appropriate to think that observations are not independent since the school's overall math performance could be related to the students' individual performance.

In this case, if you omit the school ID term in your model you will be omitting a relevant variable, which could bias your estimates. Also, if there is a relevant difference in the distribution of math scores is observed apart from the mean (variance, skewness, and kurtosis), you should probably consider using robust errors in your models (or cluster the errors at the school level). This won't change your coefficients, but could dramatically change your model's t-test and f-test statistics since you are now accounting for possible violations of the 4th OLS assumption (constant variance).

To sum up, if you have groups in you cross-sectional data, and is plausible that these group matter, therefore it is also plausible that the observations are not independent. Thus, you should control by group (through a fixed-effect model by the group for example) and use robust errors at the group level, to have much more confidence both in your coefficients and its p-values.

• Hi Guibor, great answer, could you clarify for a newbie, why omitting a school ID would bias the estimates? Do you mean the model which uses school ID could better estimate the score? Thanks! Apr 26, 2021 at 5:25
• Sure, it's basically because when you add a dummy variable for each school ID (what is called 'fixed effect model'), you control all unobservable factors that vary across school level, which could be correlated with your other observable variables. It's a way in which you are trying to avoid the 'omitted variable bias and to maintain one of the OLS assumptions which establish that your vector of independent variables must not be correlated with the error term [Cov(e,X') = 0] Apr 26, 2021 at 5:58
• @GuiborCamargoSalamanca, I am dealing with a similar case to the example you have cited above (although I am not sure if it is exactly same as your case). May I ask that If you have groups within the data, wouldn't it be sufficient to add in some group specific characteristics as control variables? Say I am dealing with an online business data that is registered in one country that allows multiple vendors from different countries to sell one particular type of product category (vendors can sell any varieties). If I would like to determine the price of the product based on the product (contd)
– Laiy
Nov 25, 2022 at 22:40
• @GuiborCamargoSalamanca If I would like to determine the price of the product. My primary independent variables would be the product characteristics (due to varieties sold). Wouldnt it be sufficient to add vendor specific characteristics such as country of vendor, size of vendors business etc instead of dummy variable?
– Laiy
Nov 25, 2022 at 22:47
• @Laiy, I think it's important to remember why we add fixed effects to a model. Fixed effects allow us to control for variables we do not observe at a certain level but consider essential in the estimation. For example, a country-fixed effect allows us to consider unobserved differences between countries, such as tax regimes and commercial dynamics, that can affect prices (when we do not have these data at hand). The critical thing to do is that the errors must be clustered at the same level whenever we add these group effects (coefficients will not change, but st. errors will). Dec 6, 2022 at 14:52