AbstractUnderstanding how multi-scale host heterogeneity affects viral community assembly can illuminate ecological drivers of infection and host-switching. Yet, such studies are hindered by imperfect viral detection. To address this issue, we used a community occupancy model – refashioned for the hierarchical nature of molecular-detection methods – to account for failed detection when examining how individual-level host traits affect herpesvirus richness in eight species of wild bats. We then used model predictions to examine the role of host sex and species identity on viral diversity at the levels of host individual, population, and community. Results demonstrate that cPCR and viral sequencing failed to perfectly detect viral presence. Nevertheless, model estimates correcting for imperfect detection show that reproductively active bats, especially reproductively active females, have significantly higher viral richness, and host sex and species identity interact to affect viral richness. Further, host sex significantly affects viral turnover across host populations, as females host more heterogeneous viral communities than do males. Results suggest models of viral ecology benefit from integration of multi-scale host factors, with implications for bat conservation and epidemiology. Furthermore, by accounting for imperfect detection in laboratory assays, we demonstrate how statistical models developed for other purposes hold promising possibilities for molecular and epidemiological applications.