[Edit:] My question concerns the use of a
categorical predictor in linear regression specifically.
Some of the assumptions for linear regression include: normality, homoscedasticity, and autocorrelation (of residuals), among others.
Normally, these all relate to the residuals of the model, but in a previous answer, it was suggested that when using a
categorical predictor, assumptions should be checked on the raw data instead, but also that all the same assumptions endure. That being said, a regression with a
categorical predictor is very similar to an ANOVA, and to my knowledge, ANOVA does not have the assumption of autocorrelation of residuals.
Which brings the question: Does the assumption of autocorrelation apply to linear regression with a categorical predictor? If yes, then how do you test it in
R on the raw data (and not from the model)?
I began my question by saying the "main" assumptions but perhaps I should have said, "the main assumptions of interest to check at the analysis stage (once data is already collected and respecting independence of observations) with a categorical variable (group) as predictor." I had read online (e.g., http://r-statistics.co/Assumptions-of-Linear-Regression.html) that there are 10 assumptions. I will name them below for the sake of completeness (though I think the list is missing independence and linearity proper):
- The regression model is linear in parameters [re: related to Linearity]
- The mean of residuals is zero
- Homoscedasticity of residuals or equal variance [re: Equal Variance]
- No autocorrelation of residuals
- The X variables and residuals are uncorrelated
- The number of observations must be greater than the number of Xs
- The variability in X values is positive
- The regression model is correctly specified
- No perfect multicollinearity
- Normality of residuals [re: Normality]
Some of these assumptions either have been already verified in my case or do not apply. For example, multicollinearity does not apply to my situation as I have a single predictor, and by definition when comparing two levels of a categorical predictor the relationship will be linear (example 1, example 2).
That being said, as the title of my question points out, my question relates exclusively to the autocorrelation of residuals assumption for the case of a
categorical predictor. The source linked before mentions "This is applicable especially for time series data", but it doesn't say that it doesn't apply to non-time-series data, so that's why I wasn't sure (also: in relation to a categorical predictor).