Main R code for data analysis from An evolutionary model to predict the frequency of antibiotic resistance under seasonal antibiotic use, and an application to <i>Streptococcus pneumoniae</i> BlanquartFrançois LehtinenSonja FraserChristophe 2017 The frequency of resistance to antibiotics in <i>Streptococcus pneumoniae</i> has been stable over the last decades. For example, penicillin non-susceptibility in Europe has fluctuated between 12% and 16% without any major time trend. In spite of long-term stability, resistance fluctuates over short time-scales, presumably in part due to seasonal fluctuations in antibiotic prescriptions. Here, we develop a model that describes the evolution of antibiotic resistance under selection by multiple antibiotics prescribed at seasonally changing rates. This model was inspired by, and fitted to, published data on monthly antibiotics prescriptions and frequency of resistance, in two communities in Israel, over 5 years. Seasonal fluctuations in antibiotic usage translate into small fluctuations of the frequency of resistance around the average value. We describe these dynamics using a perturbation approach that encapsulates all ecological and evolutionary forces into a generic model, whose parameters quantify a force stabilizing the frequency of resistance around the equilibrium, and the sensitivity of the population to antibiotic selection. Fitting the model to the data revealed a strong stabilizing force, typically two to five times stronger than direct selection due to antibiotics. The strong stabilizing force explains that resistance fluctuates <i>in phase</i> with usage, as antibiotic selection alone would result in resistance fluctuating behind usage with a lag of three months when antibiotic use is seasonal. While most antibiotics selected for increased resistance, intriguingly, cephalosporins selected for decreased resistance to penicillins and macrolides, an effect consistent in the two communities. One extra monthly prescription of cephalosporins per 1000 children decreased the frequency of penicillin-resistant strains by 1.7%. This model emerges under minimal assumptions, quantifies the forces acting on resistance and explains up to 43% of the temporal variation in resistance.