RESUMEN
OBJECTIVE: To present a general framework providing high-level guidance to developers of computable algorithms for identifying patients with specific clinical conditions (phenotypes) through a variety of approaches, including but not limited to machine learning and natural language processing methods to incorporate rich electronic health record data. MATERIALS AND METHODS: Drawing on extensive prior phenotyping experiences and insights derived from 3 algorithm development projects conducted specifically for this purpose, our team with expertise in clinical medicine, statistics, informatics, pharmacoepidemiology, and healthcare data science methods conceptualized stages of development and corresponding sets of principles, strategies, and practical guidelines for improving the algorithm development process. RESULTS: We propose 5 stages of algorithm development and corresponding principles, strategies, and guidelines: (1) assessing fitness-for-purpose, (2) creating gold standard data, (3) feature engineering, (4) model development, and (5) model evaluation. DISCUSSION AND CONCLUSION: This framework is intended to provide practical guidance and serve as a basis for future elaboration and extension.
Asunto(s)
Algoritmos , Registros Electrónicos de Salud , Procesamiento de Lenguaje Natural , Fenotipo , Humanos , Aprendizaje AutomáticoRESUMEN
Lasso regression is widely used for large-scale propensity score (PS) estimation in healthcare database studies. In these settings, previous work has shown that undersmoothing (overfitting) Lasso PS models can improve confounding control, but it can also cause problems of non-overlap in covariate distributions. It remains unclear how to select the degree of undersmoothing when fitting large-scale Lasso PS models to improve confounding control while avoiding issues that can result from reduced covariate overlap. Here, we used simulations to evaluate the performance of using collaborative-controlled targeted learning to data-adaptively select the degree of undersmoothing when fitting large-scale PS models within both singly and doubly robust frameworks to reduce bias in causal estimators. Simulations showed that collaborative learning can data-adaptively select the degree of undersmoothing to reduce bias in estimated treatment effects. Results further showed that when fitting undersmoothed Lasso PS-models, the use of cross-fitting was important for avoiding non-overlap in covariate distributions and reducing bias in causal estimates.
RESUMEN
Background: Real-world data, such as administrative claims and electronic health records, are increasingly used for safety monitoring and to help guide regulatory decision-making. In these settings, it is important to document analytic decisions transparently and objectively to assess and ensure that analyses meet their intended goals. Methods: The Causal Roadmap is an established framework that can guide and document analytic decisions through each step of the analytic pipeline, which will help investigators generate high-quality real-world evidence. Results: In this paper, we illustrate the utility of the Causal Roadmap using two case studies previously led by workgroups sponsored by the Sentinel Initiative - a program for actively monitoring the safety of regulated medical products. Each case example focuses on different aspects of the analytic pipeline for drug safety monitoring. The first case study shows how the Causal Roadmap encourages transparency, reproducibility, and objective decision-making for causal analyses. The second case study highlights how this framework can guide analytic decisions beyond inference on causal parameters, improving outcome ascertainment in clinical phenotyping. Conclusion: These examples provide a structured framework for implementing the Causal Roadmap in safety surveillance and guide transparent, reproducible, and objective analysis.
RESUMEN
Increasing emphasis on the use of real-world evidence (RWE) to support clinical policy and regulatory decision-making has led to a proliferation of guidance, advice, and frameworks from regulatory agencies, academia, professional societies, and industry. A broad spectrum of studies use real-world data (RWD) to produce RWE, ranging from randomized trials with outcomes assessed using RWD to fully observational studies. Yet, many proposals for generating RWE lack sufficient detail, and many analyses of RWD suffer from implausible assumptions, other methodological flaws, or inappropriate interpretations. The Causal Roadmap is an explicit, itemized, iterative process that guides investigators to prespecify study design and analysis plans; it addresses a wide range of guidance within a single framework. By supporting the transparent evaluation of causal assumptions and facilitating objective comparisons of design and analysis choices based on prespecified criteria, the Roadmap can help investigators to evaluate the quality of evidence that a given study is likely to produce, specify a study to generate high-quality RWE, and communicate effectively with regulatory agencies and other stakeholders. This paper aims to disseminate and extend the Causal Roadmap framework for use by clinical and translational researchers; three companion papers demonstrate applications of the Causal Roadmap for specific use cases.
RESUMEN
BACKGROUND: The Targeted Learning roadmap provides a systematic guide for generating and evaluating real-world evidence (RWE). From a regulatory perspective, RWE arises from diverse sources such as randomized controlled trials that make use of real-world data, observational studies, and other study designs. This paper illustrates a principled approach to assessing the validity and interpretability of RWE. METHODS: We applied the roadmap to a published observational study of the dose-response association between ritodrine hydrochloride and pulmonary edema among women pregnant with twins in Japan. The goal was to identify barriers to causal effect estimation beyond unmeasured confounding reported by the study's authors, and to explore potential options for overcoming the barriers that robustify results. RESULTS: Following the roadmap raised issues that led us to formulate alternative causal questions that produced more reliable, interpretable RWE. The process revealed a lack of information in the available data to identify a causal dose-response curve. However, under explicit assumptions the effect of treatment with any amount of ritodrine versus none, albeit a less ambitious parameter, can be estimated from data. CONCLUSIONS: Before RWE can be used in support of clinical and regulatory decision-making, its quality and reliability must be systematically evaluated. The TL roadmap prescribes how to carry out a thorough, transparent, and realistic assessment of RWE. We recommend this approach be a routine part of any decision-making process.
Asunto(s)
Proyectos de Investigación , Femenino , Humanos , Reproducibilidad de los Resultados , Japón , Ensayos Clínicos Controlados Aleatorios como AsuntoRESUMEN
BACKGROUND: In rural China, exclusive breastfeeding (EBF) prevalence is low and hospitals often fail to attain baby-friendly feeding objectives, such as ≥ 75% of newborns exclusively breastfed from birth to discharge. Empirical evidence for the impact of increased hospital compliance with recommended feeding guidelines on continued EBF in rural China is lacking. We sought to measure and model the association of newborns' in-hospital feeding experiences with EBF practice in infancy to inform policies for EBF promotion. METHODS: Data were cross-sectional from 785 caregivers of infants < 6 months of age, collected from November to December 2019 in four underdeveloped counties/districts in Sichuan Province. In-hospital feeding practices were determined, and prevalence of current infant feeding practices was calculated from 24-h recall and categorized according to WHO/UNICEF Infant and Young Child Feeding categories as EBF, breastfed with non-milk liquids, mixed feeding, breastfed with solids, and not breastfed. Relative risk ratios were estimated using adjusted multinomial logistic regression to examine risk factors for non-EBF practices compared to EBF, including in-hospital feeding experiences. The regression model was used to investigate change in EBF prevalence under alternative in-hospital experiences. RESULTS: Only 38.1% of under-six-month-old infants were being exclusively breastfed when data were collected; 61.8% and 77.6% had been fed water and infant formula, respectively, in the hospital. Infants who were fed water or formula before discharge were estimated as 2-3 times as likely to be non-EBF than EBF up to age six months. According to our model, EBF prevalence would have increased to 53.7% (95% confidence interval (CI) 46.1, 61.2) had ≥ 75% of infants been exclusively breastfed and water-based feeds eliminated in-hospital. CONCLUSIONS: Given the importance of infants' first feeding experiences in the establishment and continuation of EBF, it is imperative that rural Chinese hospitals actively seek to limit infant formula feeds to medically indicated situations and eliminate water-based feeds.
Asunto(s)
Lactancia Materna , Periodo Posparto , Femenino , Humanos , Lactante , Recién Nacido , Hospitales , Factores de Riesgo , AguaRESUMEN
Common tasks encountered in epidemiology, including disease incidence estimation and causal inference, rely on predictive modelling. Constructing a predictive model can be thought of as learning a prediction function (a function that takes as input covariate data and outputs a predicted value). Many strategies for learning prediction functions from data (learners) are available, from parametric regressions to machine learning algorithms. It can be challenging to choose a learner, as it is impossible to know in advance which one is the most suitable for a particular dataset and prediction task. The super learner (SL) is an algorithm that alleviates concerns over selecting the one 'right' learner by providing the freedom to consider many, such as those recommended by collaborators, used in related research or specified by subject-matter experts. Also known as stacking, SL is an entirely prespecified and flexible approach for predictive modelling. To ensure the SL is well specified for learning the desired prediction function, the analyst does need to make a few important choices. In this educational article, we provide step-by-step guidelines for making these decisions, walking the reader through each of them and providing intuition along the way. In doing so, we aim to empower the analyst to tailor the SL specification to their prediction task, thereby ensuring their SL performs as well as possible. A flowchart provides a concise, easy-to-follow summary of key suggestions and heuristics, based on our accumulated experience and guided by SL optimality theory.
Asunto(s)
Algoritmos , Aprendizaje Automático , HumanosRESUMEN
We sought to determine whether machine learning and natural language processing (NLP) applied to electronic medical records could improve performance of automated health-care claims-based algorithms to identify anaphylaxis events using data on 516 patients with outpatient, emergency department, or inpatient anaphylaxis diagnosis codes during 2015-2019 in 2 integrated health-care institutions in the Northwest United States. We used one site's manually reviewed gold-standard outcomes data for model development and the other's for external validation based on cross-validated area under the receiver operating characteristic curve (AUC), positive predictive value (PPV), and sensitivity. In the development site 154 (64%) of 239 potential events met adjudication criteria for anaphylaxis compared with 180 (65%) of 277 in the validation site. Logistic regression models using only structured claims data achieved a cross-validated AUC of 0.58 (95% CI: 0.54, 0.63). Machine learning improved cross-validated AUC to 0.62 (0.58, 0.66); incorporating NLP-derived covariates further increased cross-validated AUCs to 0.70 (0.66, 0.75) in development and 0.67 (0.63, 0.71) in external validation data. A classification threshold with cross-validated PPV of 79% and cross-validated sensitivity of 66% in development data had cross-validated PPV of 78% and cross-validated sensitivity of 56% in external data. Machine learning and NLP-derived data improved identification of validated anaphylaxis events.
Asunto(s)
Anafilaxia , Procesamiento de Lenguaje Natural , Humanos , Anafilaxia/diagnóstico , Anafilaxia/epidemiología , Aprendizaje Automático , Algoritmos , Servicio de Urgencia en Hospital , Registros Electrónicos de SaludRESUMEN
OBJECTIVE: To examine the relative importance of client change language subtypes as predictors of alcohol use following motivational interviewing (MI). METHOD: Participants were 164 heavy drinkers (57.3% female, Mage = 28.5 years, 13.4% Hispanic/Latinx, 82.9% White) recruited during an emergency department visit who received MI for alcohol and human immunodeficiency virus/sexual risk in a randomized-controlled trial. MI sessions were coded with the motivational interviewing skill code (MISC) and the generalized behavioral intervention analysis system (GBIAS). Variable importance analyses used targeted maximum likelihood estimation to rank order change language subtypes defined by these systems as predictors of alcohol use over 9 months of follow-up. RESULTS: Among GBIAS change language subtypes, higher sustain talk (ST) around change planning was ranked the most important predictor of drinks per week (b = -5.57, 95% CI [-8.11, -3.02]) and heavy drinking days (b = -2.07, 95% CI [-3.17, -0.98]); this talk reflected (a) rejection of alcohol abstinence as a desired change goal, (b) rejection of specific change strategies, or (c) discussion of anticipated challenges in changing drinking. Among MISC change language subtypes, higher ST around taking steps-reflecting recent escalations in drinking described by a small minority of participants-was ranked the most important predictor of drinks per week (b = 22.71, 95% CI [20.29, 25.13]) and heavy drinking days (b = -2.45, 95% CI [1.68, 3.21]). CONCLUSIONS: Results challenge the assumption that all ST during MI is a negative prognostic indicator and highlight the importance of the context in which change language emerges. (PsycInfo Database Record (c) 2023 APA, all rights reserved).
Asunto(s)
Alcoholismo , Entrevista Motivacional , Humanos , Femenino , Adulto , Masculino , Motivación , Entrevista Motivacional/métodos , Conducta Sexual , LenguajeRESUMEN
Inverse probability weighting (IPW) and targeted maximum likelihood estimation (TMLE) are methodologies that can adjust for confounding and selection bias and are often used for causal inference. Both estimators rely on the positivity assumption that within strata of confounders there is a positive probability of receiving treatment at all levels under consideration. Practical applications of IPW require finite inverse probability (IP) weights. TMLE requires that propensity scores (PS) be bounded away from 0 and 1. Although truncation can improve variance and finite sample bias, this artificial distortion of the IP weights and PS distribution introduces asymptotic bias. As sample size grows, truncation-induced bias eventually swamps variance, rendering nominal confidence interval coverage and hypothesis tests invalid. We present a simple truncation strategy based on the sample size, n, that sets the upper bound on IP weights at $\sqrt{\textit{n}}$ ln n/5. For TMLE, the lower bound on the PS should be set to 5/($\sqrt{\textit{n}}$ ln n/5). Our strategy was designed to optimize the mean squared error of the parameter estimate. It naturally extends to data structures with missing outcomes. Simulation studies and a data analysis demonstrate our strategy's ability to minimize both bias and mean squared error in comparison with other common strategies, including the popular but flawed quantile-based heuristic.
Asunto(s)
Puntaje de Propensión , Sesgo , Causalidad , Simulación por Computador , Humanos , Funciones de VerosimilitudRESUMEN
BACKGROUND: Anaphylaxis is a life-threatening allergic reaction that is difficult to identify accurately with administrative data. We conducted a population-based validation study to assess the accuracy of ICD-10 diagnosis codes for anaphylaxis in outpatient, emergency department, and inpatient settings. METHODS: In an integrated healthcare system in Washington State, we obtained medical records from healthcare encounters with anaphylaxis diagnosis codes (potential events) from October 2015 to December 2018. To capture events missed by anaphylaxis diagnosis codes, we also obtained records on a sample of serious allergic and drug reactions. Two physicians determined whether potential events met established clinical criteria for anaphylaxis (validated events). RESULTS: Out of 239 potential events with anaphylaxis diagnosis codes, the overall positive predictive value (PPV) for validated events was 64% (95% CI = 58 to 70). The PPV decreased with increasing age. Common precipitants for anaphylaxis were food (39%), medications (35%), and insect bite or sting (12%). The sensitivity of emergency department and inpatient anaphylaxis diagnosis codes for all validated events was 58% (95% CI = 51 to 65), but sensitivity increased to 95% (95% CI = 74 to 99) when outpatient diagnosis codes were included. Using information from all validated events and sampling weights, the incidence rate for anaphylaxis was 3.6 events per 10,000 person-years (95% CI = 3.1 to 4.0). CONCLUSIONS: In this population-based setting, ICD-10 diagnosis codes for anaphylaxis from emergency department and inpatient settings had moderate PPV and sensitivity for validated events. These findings have implications for epidemiologic studies that seek to estimate risks of anaphylaxis using electronic health data.
Asunto(s)
Anafilaxia , Anafilaxia/diagnóstico , Anafilaxia/epidemiología , Registros Electrónicos de Salud , Humanos , Clasificación Internacional de Enfermedades , Valor Predictivo de las Pruebas , Washingtón/epidemiologíaRESUMEN
BACKGROUND: A substantial fraction of sexually transmitted infections (STIs) occur in patients who have previously been treated for an STI. We assessed whether routine electronic health record (EHR) data can predict which patients presenting with an incident STI are at greatest risk for additional STIs in the next 1 to 2 years. METHODS: We used structured EHR data on patients 15 years or older who acquired an incident STI diagnosis in 2008 to 2015 in eastern Massachusetts. We applied machine learning algorithms to model risk of acquiring ≥1 or ≥2 additional STIs diagnoses within 365 or 730 days after the initial diagnosis using more than 180 different EHR variables. We performed sensitivity analysis incorporating state health department surveillance data to assess whether improving the accuracy of identifying STI cases improved algorithm performance. RESULTS: We identified 8723 incident episodes of laboratory-confirmed gonorrhea, chlamydia, or syphilis. Bayesian Additive Regression Trees, the best-performing algorithm of any single method, had a cross-validated area under the receiver operating curve of 0.75. Receiver operating curves for this algorithm showed a poor balance between sensitivity and positive predictive value (PPV). A predictive probability threshold with a sensitivity of 91.5% had a corresponding PPV of 3.9%. A higher threshold with a PPV of 29.5% had a sensitivity of 11.7%. Attempting to improve the classification of patients with and without repeat STIs diagnoses by incorporating health department surveillance data had minimal impact on cross-validated area under the receiver operating curve. CONCLUSIONS: Machine algorithms using structured EHR data did not differentiate well between patients with and without repeat STIs diagnosis. Alternative strategies, able to account for sociobehavioral characteristics, could be explored.
Asunto(s)
Infecciones por Chlamydia , Gonorrea , Infecciones por VIH , Enfermedades de Transmisión Sexual , Sífilis , Teorema de Bayes , Infecciones por Chlamydia/diagnóstico , Infecciones por Chlamydia/epidemiología , Gonorrea/diagnóstico , Gonorrea/epidemiología , Humanos , Aprendizaje Automático , Massachusetts/epidemiología , Enfermedades de Transmisión Sexual/diagnóstico , Enfermedades de Transmisión Sexual/epidemiología , Sífilis/diagnóstico , Sífilis/epidemiologíaRESUMEN
We use simulated data to examine the consequences of depletion of susceptibles for hazard ratio (HR) estimators based on a propensity score (PS). First, we show that the depletion of susceptibles attenuates marginal HRs toward the null by amounts that increase with the incidence of the outcome, the variance of susceptibility, and the impact of susceptibility on the outcome. If susceptibility is binary then the Bross bias multiplier, originally intended to quantify bias in a risk ratio from a binary confounder, also quantifies the ratio of the instantaneous marginal HR to the conditional HR as susceptibles are depleted differentially. Second, we show how HR estimates that are conditioned on a PS tend to be between the true conditional and marginal HRs, closer to the conditional HR if treatment status is strongly associated with susceptibility and closer to the marginal HR if treatment status is weakly associated with susceptibility. We show that associations of susceptibility with the PS matter to the marginal HR in the treated (ATT) though not to the marginal HR in the entire cohort (ATE). Third, we show how the PS can be updated periodically to reduce depletion-of-susceptibles bias in conditional estimators. Although marginal estimators can hit their ATE or ATT targets consistently without updating the PS, we show how their targets themselves can be misleading as they are attenuated toward the null. Finally, we discuss implications for the interpretation of HRs and their relevance to underlying scientific and clinical questions. See video Abstract: http://links.lww.com/EDE/B727.
Asunto(s)
Sesgo , Puntaje de Propensión , Modelos de Riesgos Proporcionales , Estudios de Cohortes , HumanosRESUMEN
Human immunodeficiency virus (HIV) pre-exposure prophylaxis (PrEP) protects high risk patients from becoming infected with HIV. Clinicians need help to identify candidates for PrEP based on information routinely collected in electronic health records (EHRs). The greatest statistical challenge in developing a risk prediction model is that acquisition is extremely rare. METHODS: Data consisted of 180 covariates (demographic, diagnoses, treatments, prescriptions) extracted from records on 399 385 patient (150 cases) seen at Atrius Health (2007-2015), a clinical network in Massachusetts. Super learner is an ensemble machine learning algorithm that uses k-fold cross validation to evaluate and combine predictions from a collection of algorithms. We trained 42 variants of sophisticated algorithms, using different sampling schemes that more evenly balanced the ratio of cases to controls. We compared super learner's cross validated area under the receiver operating curve (cv-AUC) with that of each individual algorithm. RESULTS: The least absolute shrinkage and selection operator (lasso) using a 1:20 class ratio outperformed the super learner (cv-AUC = 0.86 vs 0.84). A traditional logistic regression model restricted to 23 clinician-selected main terms was slightly inferior (cv-AUC = 0.81). CONCLUSION: Machine learning was successful at developing a model to predict 1-year risk of acquiring HIV based on a physician-curated set of predictors extracted from EHRs.
Asunto(s)
Infecciones por VIH , Profilaxis Pre-Exposición , Registros Electrónicos de Salud , VIH , Infecciones por VIH/prevención & control , Humanos , Aprendizaje AutomáticoRESUMEN
BACKGROUND: Evidence on the risk of febrile seizures after inactivated influenza vaccine (IIV) and 13-valent pneumococcal conjugate vaccine (PCV13) is mixed. In the FDA-sponsored Sentinel Initiative, we examined risk of febrile seizures after IIV and PCV13 in children 6-23â¯months of age during the 2013-14 and 2014-15 influenza seasons. METHODS: Using claims data and a self-controlled risk interval design, we compared the febrile seizure rate in a risk interval (0-1â¯days) versus control interval (14-20â¯days). In exploratory analyses, we assessed whether the effect of IIV was modified by concomitant PCV13 administration. RESULTS: Adjusted for age, calendar time and concomitant administration of the other vaccine, the incidence rate ratio (IRR) for risk of febrile seizures following IIV was 1.12 (95% CI 0.80, 1.56) and following PCV13 was 1.80 (95% CI 1.29, 2.52). The attributable risk for febrile seizures following PCV13 ranged from 0.33 to 5.16 per 100,000 doses by week of age. The age and calendar-time adjusted IRR comparing exposed to unexposed time was numerically larger for concomitant IIV and PCV13 (IRR 2.80, 95% CI 1.63, 4.83), as compared to PCV13 without concomitant IIV (IRR 1.54, 95% CI 1.04, 2.28), and the IRR for IIV without concomitant PCV13 suggested no independent effects of IIV (IRR 0.94, 95% CI 0.63, 1.42). Taken together, this suggests a possible interaction between IIV and PCV13, though our study was not sufficiently powered to provide a precise estimate of the interaction. CONCLUSIONS: We found an elevated risk of febrile seizures after PCV13 vaccine but not after IIV. The risk of febrile seizures after PCV13 is low compared to the overall risk in this population of children, and the risk should be interpreted in the context of the importance of preventing pneumococcal infections.
Asunto(s)
Vacunas contra la Influenza/efectos adversos , Vacunas Neumococicas/efectos adversos , Convulsiones Febriles , Humanos , Lactante , Convulsiones Febriles/inducido químicamente , Convulsiones Febriles/epidemiología , Vigilancia de Guardia , Estados Unidos , Vacunas Conjugadas/efectos adversosRESUMEN
Introduction: The role of acute mood states as mediating factors in cognitive impairment in patients with mania or depression is not sufficiently clear. Similarly, the extent to which cognitive impairment is trait or state-specific remains an open question. Therefore, the aim of this study was to investigate the effect of a mood-induction on attention in patients with an affective disorder.Methods: Twenty-two depressed bipolar patients, 10 manic bipolar patients, 17 with a depressive episode (MDE), and 24 healthy controls performed the Attention-Network-Test (ANT). In a within-participants design, elated and sad moods were induced by an autobiographic recall and measured on a self-report scale. Subsequently, participants performed the ANT again.Results: The modulating effect of the elated mood induction on attention was small. Only the MDE group displayed moderate improvements in selective attention and tonic alertness. Surprisingly, after the sad mood induction, patients with MDE improved moderately on phasic and tonic alertness. Phasic alertness was also enhanced in patients with mania. Finally, after the mood induction, patients with MDE showed the largest variability in attentional performance.Conclusions: Results showed only small effects of mood induction on attention. This supports the view that attention deficits reflect trait variables.
Asunto(s)
Afecto/fisiología , Atención/fisiología , Trastorno Bipolar/psicología , Trastorno Depresivo/psicología , Desempeño Psicomotor/fisiología , Adulto , Trastorno Bipolar/fisiopatología , Trastorno Depresivo/fisiopatología , Femenino , Humanos , Masculino , Recuerdo Mental/fisiología , Persona de Mediana Edad , AutoinformeRESUMEN
BACKGROUND: HIV pre-exposure prophylaxis (PrEP) is effective but underused, in part because clinicians do not have the tools to identify PrEP candidates. We developed and validated an automated prediction algorithm that uses electronic health record (EHR) data to identify individuals at increased risk for HIV acquisition. METHODS: We used machine learning algorithms to predict incident HIV infections with 180 potential predictors of HIV risk drawn from EHR data from 2007-15 at Atrius Health, an ambulatory group practice in Massachusetts, USA. We included EHRs of all patients aged 15 years or older with at least one clinical encounter during 2007-15. We used ten-fold cross-validated area under the receiver operating characteristic curve (cv-AUC) with 95% CIs to assess the model's performance at identifying individuals with incident HIV and patients independently prescribed PrEP by clinicians. The best-performing model was validated prospectively with 2016 data from Atrius Health and externally with 2011-16 data from Fenway Health, a community health centre specialising in sexual health care in Boston (MA, USA). We calculated HIV risk scores (ie, probability of an incident HIV diagnosis) for every HIV-uninfected patient not on PrEP during 2007-15 at Atrius Health and assessed the distribution of scores for thresholds to determine possible candidates for PrEP in the three study cohorts. FINDINGS: We included 1â155â966 Atrius Health patients from 2007-15 (150 [<0·1%] patients with incident HIV) in our development cohort, 537â257 Atrius Health patients in 2016 (16 [<0·1%] with incident HIV) in our prospective validation cohort, and 33â404 Fenway Health patients from 2011-16 (423 [1·3%] with incident HIV) in our external validation cohort. The best-performing algorithm was obtained with least absolute shrinkage and selection operator (LASSO) and had a cv-AUC of 0·86 (95% CI 0·82-0·90) for identification of incident HIV infections in the development cohort, 0·91 (0·81-1·00) on prospective validation, and 0·77 (0·74-0·79) on external validation. The LASSO model successfully identified patients independently prescribed PrEP by clinicians at Atrius Health in 2016 (cv-AUC 0·93, 95% CI 0·90-0·96) or Fenway Health (0·79, 0·78-0·80). HIV risk scores increased steeply at the 98th percentile. Using this score as a threshold, we prospectively identified 9515 (1·8%) of 536â384 patients at Atrius Health in 2016 and 4385 (15·3%) of 28â702 Fenway Health patients as potential PrEP candidates. INTERPRETATION: Automated algorithms can efficiently identify patients at increased risk for HIV acquisition. Integrating these models into EHRs to alert providers about patients who might benefit from PrEP could improve prescribing and prevent new HIV infections. FUNDING: Harvard University Center for AIDS Research, Providence/Boston Center for AIDS Research, Rhode Island IDeA-CTR, the National Institute of Mental Health, and the US Centers for Disease Control and Prevention.