Degrees of freedom when comparing models applied in a secondary (test) dataset Two models in R:
mod_a = lm(height ~ age)
mod_b = lm(height ~ age + sex)

Those models have different degrees of freedom. Once they are applied in a separate set, do those degrees of freedom from the derivation carry over?
E.g., testing the models in a second, separate set of test data might look like this:
m0 <- lm(height ~ mod_a_output)
m1 <- lm(height ~ mod_b_output)

anova(m0, m1)

In this separate test set, where both models' output are now a single variable (computed with the formula derived in the training set), both will be considered to have the same degrees of freedom with this construction. Is it correct to use this (equal) set of degrees of freedom in this separate dataset, or do we need to track the degrees of freedom from the derivation set?

You can't do the type of anova() comparison that you envision on test data. That anova() requires nested models, in which the predictors of one model are a subset of those in the other. Although the two original models are nested that way, their later predicted values on test data aren't.
In your proposed evaluation of the two original models on new test data, what you have is the equivalent of two simple linear regressions, with just one predictor of the outcome in each evaluation. You could compare the forms of the 2 original models with anova() on a new data set, but not the numerical predictions from those original models.
As an anova() can't be used for that type of evaluation on test data, degrees of freedom as might be needed for an F-test aren't relevant. Each of your evaluation models would use up one degree of freedom for the intercept and one for the coefficient of its corresponding predictor, mod_(a/b)_output.
Although "degrees of freedom" might seem like a simple concept, it isn't. See this question for extensive and enlightening discussion.
