The mathematical / statistical linear model, $$y_{ij} = \mu + \rho_i + \tau_j + \epsilon_{ij},$$ where $\mu$ is the population mean, $\rho_i$ is the main effect of subject, $\tau_j$ is the main effect of treatment, $\epsilon_{ij}$ is the independent error ([link](http://www.docstoc.com/docs/25226940/Repeated-Measures-and-Related-Designs), p. 2), describes a single-factor repeated measures design. It is said that for the data collected in such a design we have to operate with the residuals calculated accordingly to the `formula A`: $$\hat\epsilon_{ij} = Y_{ij} - \bar Y_{i.} - \bar Y_{.j} + \bar Y.$$ The [`formula B`](http://en.wikipedia.org/wiki/Errors_and_residuals_in_statistics), on wiki is $\hat\epsilon_i = Y_i - \bar Y$. My question is: what formula is used to correctly calculate residuals in the model describing a single-factor repeated measures design ? Thank you.