Choosing a statistical method to measure differences in age groups while accounting for sex

I am looking at one kind of measurement in 4 groups Young males, young females, senior males, senior females. Whereas I am mainly concerned at looking at the differences between young and old, I don't want sex as a confounding factor which is why I added in the additional sex groups and basically doubled my sample size (no previous studies to say if it is different with age in the species I am researching). I am pretty new to statistics and am not sure how to analyse this as I was originally going to do a student's unpaired T-Test but now I have added the additional two groups to separate the sexes.

Additionally, some of the patients I am using may have underlying health issues that impact the measurement I am taking. I know this in advance (so for example I might know that 2 of the 12 senior females may have a health problem that changes the measurement), but unfortunately I cannot choose a different group of patients. Is there a way to account for these in advance? Or to note which ones may have values indicative of health problems and treat them as outliers later.

So without changing the outline of the project, if I am mainly comparing differences in this measurement between two age groups, while also taking into account sex, what statistical test should I use?

Thank you

• This is an RBD. where the sexis your block. so an anova would suffice Mar 29, 2023 at 2:35
• By analyzing age groups and not continuous age, the result will be highly inefficient and possibly misleading. See discourse.datamethods.org/t/categorizing-continuous-variables. There is great heterogeneity within an age "group". Mar 29, 2023 at 17:03
• @FrankHarrell I was originally looking between the two, but there is a large age gap I am missing as for this initial study I am only looking at two age groups (1-3 and 10+ in animals where lifespan is only max 15 years). The question I am trying to answer is just if there is a difference between the two age groups and if there is my next study would be using animals with continuous age to see where that change may occur. Our hypothesis is that said change happens before the age of ten so there should be significant differences between the two vastly different groups- would you still be wary? Mar 30, 2023 at 21:38
• You can have age gaps and still get a much better analysis by using exact age. Mar 31, 2023 at 17:56
• @FrankHarrell Okay thank you! If all I need to do is change how I analyse the data from these two age groups I will look into analysing them as continuous data rather than groups- would that change the method I analyse it or could I still do a linear regression but specify exact ages instead of young adult or senior? Apr 2, 2023 at 23:26