Design, replicates and sample size · Choose a method

Sex as a biological variable: how to analyse male and female animals, and when you can claim a sex difference

Analyse male and female animals together in one model with treatment and sex as factors. A result significant in one sex but not the other is not evidence of a sex difference; test the interaction. Python and R code.

By Licklider · Published · Last reviewed · How this page was made · Markdown

On this page
  1. What to do, by question
  2. The common error: comparing p-values between the sexes
  3. Worked example: significant in males, not in females, with the same effect
  4. Sample size: what including both sexes costs
  5. Before you analyse
  6. Check what an AI assistant ran
  7. Report it
  8. References

Quick answer. For a continuous outcome measured once per animal, put male and female animals in one analysis with treatment and sex as factors (a two-way ANOVA or linear model), and report the treatment effect from that model with its 95% confidence interval. Do not run separate tests in each sex and compare their p-values: “significant in males, not in females” is not evidence of a sex difference. To claim the treatment works differently in the two sexes, test the treatment × sex interaction and report its estimate with its 95% CI. If the sexes vary about equally, sharing your planned number of animals across the two sexes costs little power for the treatment effect, but a study of that size can rarely show a sex difference in the effect; say so rather than reading a non-significant interaction as “no difference”. Show the data for each sex.

Terms used below. Factor: a variable with categories, here treatment (vehicle or drug) and sex. Two-way ANOVA: a model with two factors that estimates each one’s effect and their interaction. Main effect: the treatment effect averaged over sexes. Interaction (treatment × sex): whether the treatment effect differs between the sexes. Factorial design: every combination of the factors is studied, here four groups (female vehicle, female drug, male vehicle, male drug). Baseline sex difference: males and females differ without treatment, for example in body weight or grip strength. Pooling: analysing all animals together while ignoring sex. Sex-disaggregated data: results shown separately for each sex. Power: the chance of detecting an effect that is really there. 95% confidence interval (CI): the range of effects compatible with the data. Residual variance: the scatter of animals around their group mean, which the model uses for every comparison. F and df: the ANOVA test statistic and its degrees of freedom, which reflect the amount of independent data. Balanced design: the same number of animals in every group. Sums of squares, Types I, II or III: ways of splitting the variation between terms; they agree in a balanced design and can differ with unequal group sizes. Fixed factor: a factor whose levels are the ones you want to compare (sex, treatment). Random effect: a term for units sampled from a larger set, such as cages or litters, that adds their shared variation to the model. False positive: a “significant” result when there is no real effect. Conservative test: one that gives fewer false positives than it claims. Confounded: mixed up with another factor, such as cage or day, so that their effects are entangled. Post hoc tests: comparisons chosen after the main analysis, often between every pair of groups.

What to do, by question

Your question Analysis Report
Does the treatment work? (both sexes included) Two-way ANOVA or linear model, outcome ~ treatment * sex Treatment effect averaged over sexes with 95% CI; the interaction as a secondary result; data for each sex
Does the treatment work differently in males and females? The treatment × sex interaction in the same model, planned in advance, with a sample size calculated for it The difference between the sexes in the treatment effect, with its 95% CI; if the interaction is clearly present, the effect in each sex becomes the main result, because an average over the sexes describes neither
What is the effect in each sex? Effects for each sex from the same model (they use the pooled residual variance) Each sex’s effect with its CI, described as estimates, not as separate significance tests
Is there a baseline difference between the sexes? The main effect of sex in the same model Usually not the question; keeping sex in the model removes this variation from the treatment comparison
Counts or repeated measures The same factors in the matching model: a count model (count data) or a mixed model with sex as a fixed factor (repeated measures) As above
Many outcomes Name in advance the outcome that carries the sex-difference question; report every interaction estimate with its CI, or adjust (which correction to use) Other interactions labelled exploratory

The policy background is short. NIH “expects that sex as a biological variable will be factored into research designs, analyses, and reporting in vertebrate animal and human studies”, and asks for a strong justification when an application proposes to study only one sex (NIH notice NOT-OD-15-102). ARRIVE 2.0 is a reporting guideline: item 8a asks you to report the animals’ “species, strain and substrain, sex, age or developmental stage” (Percie du Sert et al. 2020). The SAGER guidelines ask that “data should be reported disaggregated by sex” (Heidari et al. 2016).

The common error: comparing p-values between the sexes

Gelman and Stern put the problem in one line: “changes in statistical significance are often not themselves statistically significant” (Gelman & Stern 2006). In neuroscience papers that compared two effects, Nieuwenhuis and colleagues “found that 78 used the correct procedure and 79 used the incorrect procedure” (Nieuwenhuis et al. 2011). For sex differences specifically, Garcia-Sifuentes and Maney found that authors “explicitly tested for interactions between sex and other factors in only 27 of the 92 articles (29%)”, and of 53 articles concluding that an effect was specific to one sex, a significant interaction was shown in “only 16 (30%)” (Garcia-Sifuentes & Maney 2021).

Worked example: significant in males, not in females, with the same effect

Constructed data: grip strength (g) in 20 mice, 5 per sex in each treatment group. The data were generated with males 20 g stronger at baseline and a drug effect of 12 g in both sexes (standard deviation [SD] 12 g); in these 20 mice the vehicle groups differ by 11.9 g, and the observed effects are 17.8 g in males and 13.2 g in females. The random seed was chosen so that the separate tests disagree, which is common at this size (see the simulation below). Stored code and data: grip.csv, make_data.py, analysis.py, analysis.R and the analysis output; analysis.py and analysis.R print the same output.

Analysis Result
Separate Student’s t-tests in each sex (the error) Males: +17.76 g, p = 0.0056. Females: +13.16 g, p = 0.16
Pooled t-test ignoring sex p = 0.014 (the baseline sex difference adds noise)
Two-way ANOVA: sex F(1, 16) = 8.62, p = 0.0097 (the baseline difference; usually not the question)
Two-way ANOVA: treatment F(1, 16) = 10.18, p = 0.0057; effect averaged over sexes 15.46 g (95% CI 5.19 to 25.73)
Two-way ANOVA: treatment × sex F(1, 16) = 0.23, p = 0.64; males minus females 4.60 g (95% CI −15.94 to 25.14)
Effect in each sex, from the model Females 13.16 g (95% CI −1.36 to 27.68); males 17.76 g (95% CI 3.24 to 32.28)
Group SDs 6.1 to 14.9 g (ratio 2.4); with 5 mice per group this is chance variation around the true SD of 12 g, so the pooled model is kept

Read as separate tests, the results make the drug seem to work only in males. Read correctly, the model shows that the drug increases grip strength, and these data cannot tell whether the effect differs between the sexes: the interval for the difference runs from about 16 g smaller in males to 25 g larger, so “no sex difference” is not a conclusion either. In 10,000 simulated experiments of this design with the same 12 g effect in both sexes, 40.5% gave a significant result in exactly one sex, while the interaction test gave a false positive in 4.5% (simulation.py, the simulation output).

# Condensed: the full script, which also prints the separate tests and the effect in each sex, is analysis.py
import pandas as pd
import statsmodels.formula.api as smf
from statsmodels.stats.anova import anova_lm

d = pd.read_csv("grip.csv")                          # columns: mouse, sex, treatment, grip_g; one row per mouse
# C(..., Treatment(...)) treats a column as categories and fixes the reference level (vehicle, female)
fit = smf.ols("grip_g ~ C(treatment, Treatment('vehicle')) * C(sex, Treatment('female'))", d).fit()
print(anova_lm(fit, typ=2))                          # Type II; with equal group sizes all types agree
term = "C(treatment, Treatment('vehicle'))[T.drug]:C(sex, Treatment('female'))[T.male]"
print(fit.params[term], fit.conf_int().loc[term].values)   # male - female difference in the effect: 4.60 (-15.94 to 25.14)
# averaged effect and each sex's effect: see analysis.py (15.46; females 13.16; males 17.76)
d <- read.csv("grip.csv")
d$sex <- factor(d$sex, levels = c("female", "male")); d$treatment <- factor(d$treatment, levels = c("vehicle", "drug"))
fit <- lm(grip_g ~ treatment * sex, data = d)
car::Anova(fit, type = 2)                            # Type II; with equal group sizes all types agree
library(emmeans)
# "revpairwise" and reverse = TRUE give the later level minus the earlier one (drug - vehicle, male - female)
confint(contrast(emmeans(fit, ~ treatment), "revpairwise"))           # effect averaged over sexes: 15.5 (5.19 to 25.7)
confint(pairs(emmeans(fit, ~ treatment | sex), reverse = TRUE))       # each sex: females 13.2, males 17.8
confint(contrast(emmeans(fit, ~ treatment * sex), interaction = c("revpairwise", "revpairwise")))   # male - female difference in the effect

With unequal numbers per group, R’s anova() and statsmodels’ default anova_lm() are sequential (Type I), so the order of terms matters; use Type II (car::Anova(fit, type = 2) in R, anova_lm(fit, typ=2) in Python) and say which type you used (unequal group sizes).

Sample size: what including both sexes costs

Phillips and colleagues simulated this choice and concluded that “for most biologically expected situations (where treatment effects are similar across the sexes or there is a baseline sex difference), there is no need to increase the N needed in the studies, rather the intended N can be shared across the 2 sexes for a treatment”, provided the data are analysed with a factorial method such as two-way ANOVA (Phillips et al. 2023). Our simulation agrees for the treatment effect: with 20 mice and a 12 g effect, power was 55.6% for 5 per sex in each treatment group analysed with two-way ANOVA and 55.9% for 10 males per group. Pooling the sexes in a t-test instead dropped power to 31.6%, because the baseline sex difference was left in the noise (the pooled test was also conservative, with 1.0% false positives instead of 5%). Their conclusion assumes similar spread in both sexes: Drobniak and colleagues argued that realistic differences in variability between the sexes require larger samples (Drobniak et al. 2024), and Phillips and colleagues replied that when one sex is clearly more variable, the analysis plan and power calculation should be adapted (Phillips et al. 2024). If your pilot data show one sex varying much more, plan for more animals.

The interaction is a different matter. In a balanced design, to reach the same power as for the average treatment effect, a sex difference in the effect has to be twice the size of that effect: when the drug added 24 g in males and nothing in females, the interaction test detected it in 55.8% of experiments. If a sex difference in the effect is your question, plan the sample size for the interaction in advance: the interaction’s standard error is twice that of the averaged effect, so with an SD of 12 g, detecting the 24 g difference with 80% power needs 9 mice per sex per treatment (36 in total; interaction_power.py, output). For the general approach, see how many biological replicates.

Before you analyse

  1. Decide the question in advance. Treatment effect in both sexes (the usual case), or a sex difference in the effect (a larger study). Write it in your plan.
  2. Balance and randomise within sex. Allocate treatments within each sex so that every treatment has males and females, and house and process the sexes so that sex is not confounded with cage, day or batch (randomisation and blinding).
  3. Keep sex as a fixed factor. With two sexes, sex is a fixed factor in the model, not a random effect; cage or litter, if needed, goes in as a random effect (nested data and mixed models).
  4. Check spread in each group. Print the standard deviation of each of the four groups (d.groupby(["sex", "treatment"]).grip_g.std() in Python, tapply(d$grip_g, list(d$sex, d$treatment), sd) in R). As a rule of thumb, if the largest is clearly more than twice the smallest and the pattern is consistent (not just one small group), analyse on the log scale or use a model that allows unequal variances, such as nlme::gls(grip_g ~ treatment * sex, weights = varIdent(form = ~ 1 | sex), data = d) in R or robust standard errors (.fit(cov_type="HC3")) in Python, and say so. With 5 animals per group, a ratio of 2 to 3 often arises by chance, as in the worked example.
  5. Report a non-significant interaction as uncertain. Give its estimate and CI; with the usual sample sizes it rarely shows that the sexes respond the same way.
  6. If the interaction is clearly present (and the interaction was a planned question), report the effect in each sex as the main result, not the average over sexes.

Check what an AI assistant ran

  1. Separate t-tests or ANOVAs in each sex, followed by “the effect is sex-specific”. Ask for one model with treatment * sex and the interaction estimate.
  2. Sex dropped from the model (all animals pooled). Put sex back as a factor.
  3. Post hoc tests between every pair of the four groups reported instead of the planned effects. Report the treatment effect, and each sex’s effect from the model if needed.
  4. “No interaction, so no sex difference.” Ask for the interaction’s CI.

Report it

Methods:

Male and female mice were included in equal numbers (n = [5] per sex per treatment) and allocated to treatment at random within sex. Grip strength was analysed with a linear model including treatment, sex and their interaction (two-way ANOVA). The primary result was the treatment effect averaged over sexes; the treatment × sex interaction was a secondary analysis, for which the study was not powered. (Software: R [4.3.3] or Python [3.13] with statsmodels [0.15.0]; replace with your own.)

Results, when the interaction was not the main question:

The drug increased grip strength by [15.5] g (95% CI [5.2] to [25.7]; F(1, [16]) = [10.18], p = [0.0057]). The estimated effect was [17.8] g in males and [13.2] g in females; the difference between the sexes, [4.6] g (95% CI [−15.9] to [25.1]; interaction p = [0.64]), was estimated imprecisely. Data for each sex are shown in Figure [X].

Results, when a planned interaction is clearly present:

The treatment effect differed between the sexes (interaction: [difference] g, 95% CI [lower] to [upper]; p = [p]). In males the drug increased grip strength by [X] g (95% CI [ ] to [ ]); in females by [Y] g (95% CI [ ] to [ ]).

Replace the bracketed values with your own.

References

  • NIH (2015). Consideration of sex as a biological variable in NIH-funded research. Notice NOT-OD-15-102. grants.nih.gov (checked 11 November 2026)
  • Percie du Sert N, Hurst V, Ahluwalia A, et al. (2020). The ARRIVE guidelines 2.0: updated guidelines for reporting animal research. PLOS Biology 18:e3000410. doi:10.1371/journal.pbio.3000410
  • Heidari S, Babor TF, De Castro P, Tort S, Curno M (2016). Sex and Gender Equity in Research: rationale for the SAGER guidelines and recommended use. Research Integrity and Peer Review 1:2. doi:10.1186/s41073-016-0007-6
  • Gelman A, Stern H (2006). The difference between “significant” and “not significant” is not itself statistically significant. The American Statistician 60:328–331. doi:10.1198/000313006X152649
  • Nieuwenhuis S, Forstmann BU, Wagenmakers EJ (2011). Erroneous analyses of interactions in neuroscience: a problem of significance. Nature Neuroscience 14:1105–1107. doi:10.1038/nn.2886
  • Garcia-Sifuentes Y, Maney DL (2021). Reporting and misreporting of sex differences in the biological sciences. eLife 10:e70817. doi:10.7554/eLife.70817
  • Drobniak SM, Lagisz M, Yang Y, Nakagawa S (2024). Realism and robustness require increased sample size when studying both sexes. PLOS Biology 22:e3002456. doi:10.1371/journal.pbio.3002456
  • Phillips B, Haschler TN, Karp NA (2024). A response to “Realism and robustness require increased sample size when studying both sexes”. PLOS Biology 22:e3002578. doi:10.1371/journal.pbio.3002578
  • Phillips B, Haschler TN, Karp NA (2023). Statistical simulations show that scientists need not increase overall sample size by default when including both sexes in in vivo studies. PLOS Biology 21:e3002129. doi:10.1371/journal.pbio.3002129

How this page was made

  • Written and published by Licklider. Recommendations cite NIH policy, the ARRIVE 2.0 and SAGER guidelines and peer-reviewed methods papers listed under References; cited passages were checked against the source text.
  • The worked example uses constructed data. Its numbers were produced by stored code (Python 3.13 with SciPy 1.18.1 and statsmodels 0.15.0; R 4.3.3 with car 3.1-2, and emmeans 1.10.0 for the page snippet), and the two analysis scripts print identical output; the simulation and the interaction power calculation were run in Python.
  • Separate review passes checked the statistics, the citations and readability before publication.