Controlling for age in $t$-test I have submitted a paper where I have performed a $t$-test between 2 groups A and B (coded as a dummy variable) to compare the mean of an Inattention scale derived from CFA analysis of the ADHD self-reported scale.
We observed a significant difference between the 2 groups (one way $t$-test $p <0.001$). The reviewer asks that we control the effect of age in our study.
Could you tell me how to control for age?
I'm using the following software to conduct the data analysis python, jasp, or jamovi.

You can do this using a linear regression model.
The model would have the following structure:
$$
y_i = \beta_0 + \beta_1\cdot\text{Group}_{i} + \beta_2\cdot\text{Age}_i + \epsilon_i
$$
Here, $\text{Group}$ is the dummy variable for the group and $\beta_1$ estimates the mean difference between the groups adjusted/controlled for potential age-differences between the groups. A model containing categorical and continuous predictors is sometimes called an analysis of covariance (ANCOVA). The model above assumes a linear relationship between age and the outcome. If you suspect that age is nonlinearly related to the outcome, I'd recommend including age using restricted splines (aka natural splines) with anything between 3 to 5 knots, depending on your sample size. This allows for a very flexible adjustment for age.
