Correction to: Nature Medicine https://doi.org/10.1038/s41591-021-01666-2, published online 13 January 2022.

In the version of this article initially published, a Statistical Analysis subsection was not present in the Methods and has now been included. Further, the Data availability statement has been amended to clarify that patient-level data may be available to approved researchers after securing relevant permissions from Public Health Scotland via the Public Benefit and Privacy Panel.

The changes have been made to the online version of the article.