For studies examining risk factors of sexually transmitted infections (STIs), confounding can stem from characteristics of partners of study subjects, and persist after adjustment for the subjects’ individual-level characteristics. Two conditions that can result in confounding by the subjects’ partners are: (C1) partner choice is assortative by the risk factor examined and, (C2) sexual activity is associated with the risk factor. The objective of this paper is to illustrate the potential impact of the assortativity bias in studies examining STI risk factors, using smoking and human papillomavirus (HPV) as an example. We developed an HPV transmission-dynamic mathematical model in which we nested a cross-sectional study assessing the smoking–HPV association. In our base case, we assumed (1) no effect of smoking on HPV, and (2) conditions C1–C2 hold for smoking (based on empirical data). The assortativity bias caused an overestimation of the odds ratio (OR) in the simulated study after perfect adjustment for the subjects’ individual-level characteristics (adjusted OR 1·51 instead of 1·00). The bias was amplified by a lower basic reproductive number (R0), greater mixing assortativity and stronger association of smoking with sexual activity. Adjustment for characteristics of partners is needed to mitigate assortativity bias.