a b s t r a c tMilk losses associated with mastitis can be attributed to either effects of pathogens per se (i.e., direct losses) or effects of the immune response triggered by intramammary infection (indirect losses). The distinction is important in terms of mastitis prevention and treatment. Regardless, the number of pathogens is often unknown (particularly in field studies), making it difficult to estimate direct losses, whereas indirect losses can be approximated by measuring the association between increased somatic cell count (SCC) and milk production. An alternative is to perform a mediation analysis in which changes in milk yield are allocated into their direct and indirect components. We applied this method on data for clinical mastitis, milk and SCC test-day recordings, results of bacteriological cultures (Escherichia coli, Staphylococcus aureus, Streptococcus uberis, coagulase-negative staphylococci, Streptococcus dysgalactiae, and streptococci other than Strep. dysgalactiae and Strep. uberis), and cow characteristics. Following a diagnosis of clinical mastitis, the cow was treated and changes (increase or decrease) in milk production before and after a diagnosis were interpreted counterfactually. On a daily basis, indirect changes, mediated by SCC increase, were significantly different from zero for all bacterial species, with a milk yield decrease (ranging among species from 4 to 33 g and mediated by an increase of 1000 SCC/mL/day) before and a daily milk increase (ranging among species from 2 to 12 g and mediated by a decrease of 1000 SCC/mL/day) after detection. Direct changes, not mediated by SCC, were only different from zero for coagulase-negative staphylococci before diagnosis (72 g per day). We concluded that mixed structural equation models were useful to estimate direct and indirect effects of the presence of clinical mastitis on milk yield.