# Degrees of freedom with duplicate data points

The degrees of freedom of the residual in an OLS model is $n - p - 1$, where $n$ is the number of samples, and $p$ is the number of independent variables. I.e., the data matrix $X$ is $n\times p$.

If I have replicated points, e.g. two rows of $X$ that were both extracted from the same sample (and that would vary only because of noise), would they both contribute to the residual degrees of freedom as one df each? To me it seems that they would not each carry a "full" constraint on the model, and thus not each contribute a full degree of freedom.

Do you know how to interpret the degrees of freedom in this case?

Update: I found this: Degrees of freedom for a weighted average but I fail to interpret the answer. Should the df for the mean be $1$ or $n-1$? Perhaps the most sensible solution is to compute the df as $df=\mathrm{tr}(X(X^T X)X^T)$ directly, and not bother with the df for the repeated samples.

If I assume that the df for the other measures are all $1$, then the df for the repeated measures would be $n_r - (n - \mathrm{tr}(X(X^T X)X^T))$, where $n_r$ is the number of repeated samples. But I suppose this value could be negative...