Congestion is of paramount concern for most large size hospitals. At the time of writing, hospitals across the world are experiencing congestion due to the coronavirus pandemic. Predicting both the number of visits to the hospital and potential pandemic considerably helps the operational management of hospitals. Empirical evidence suggests that the flu virus is more vulnerable in warm weather, hence making it more common for epidemics to proliferate in fall and winter months in the northern hemisphere. The role of weather in the spread of flu is not yet fully understood and researchers have attempted to address this question. Roussel et al. (2016) studied the impact of six climate variables (related to temperature, humidity and sunshine) on flu spread, whereas Towers et al. (2013) analysed waves of influenza and climate patterns. Davis et al. (2012) examined the hypothesis that cold and/or dry weather enhances human pneumonia and influenza mortality, whereas Firestone et al. (2012) quantified the association between the hazard of flu infection and air temperature, humidity, rainfall and wind velocity. It has been generally found that flu's transmission is mostly dependent on humidity and temperature (Lowen and Steel, 2014) , with cold and dry weather making flu more active. In this paper, we approach the problem from the point of view of hospitals facing the risk of congestion and hence the need for assessing the efficiency of the flu testing process. Specifically, we aim at understanding and quantifying the impact of weather related variables on the probability of obtaining: a high number of positive flu tested patients (epidemic), a high number of negative flu tested patients (inefficiency), and high values of positive odds (number of positive flu over negative flu tested patients).
We use three years (2016/2017, 2017/2018 and 2018/2019) of daily data from 01/07/2016 to 21/06/2019 which give us n = 1086 observations on the number of visits and positive cases for flu at the Lausanne University Hospital 1 (CHUV), one of the largest hospitals in Switzerland, with a capacity of 1000 somatic beds. q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q Recording a case of flu is per se an extreme event in the sense there are generally no flu cases registered on a "normal" day. This justifies the use of exceedances of positive cases over the threshold of 1, and then to model these 290 exceedances using extreme value theory. Although flu positive cases are registered roughly between November and May, the epidemic appears at a different time each year, with patterns that differ across the years. Similar considerations apply to the negative cases shown in Figure 2 , where the chosen threshold is 15, which gives us 230 exceedances. The choice of threshold corresponds to a certain level of inefficiency of the flu testing process (each test is expensive and costs 180 Swiss francs). It is not economically desirable to have too many negative cases. Consider, for example, the current case of SARS-CoV-2. Some countries do not have enough testing kits and those that are available tend to be used to detect/confirm positive cases. The different patterns observed across years suggest that the calendar day variable is not a good predictor for use within the framework of hospital management of flu (positive or negative) cases. This may be in part due to meteorological variation across years and perhaps also to climate change. As for the latter, we do not have enough data to test for a long term effect. Regarding the meteorological aspect, we propose to build a model for non-identically distributed discrete extremes where covariate effects can be accounted for. The discrete generalized Pareto distribution (D-GPD) provides a theoretically justified law for discrete extremes (Hitz et al., 2017) , whereas, in the same spirit of generalized additive models for location, scale and shape (Rigby and Stasinopoulos, 2005) , distributional parameters are made dependent on meteorological effects. The estimation approach needs to account for outlying observations as elaborated further in the next paragraph.
From the point of view of the management of hospital congestion due to an epidemic, a measure of interest is the odds of positive cases as shown in Figure 3 (recall that this is the ratio between the number of positive and negative cases). This value is continuous and a high number reflects a state of epidemic which in turn means that the hospital has to prepare for congestion. We define these odds to be high if they are above a threshold of 0.05, a value that is justified by a graphical technique explained in Section 2.1. The number of threshold exceedances in this case is 280. As shown in Figure 3 , some isolated extreme values appear outside the periods of flu epidemic. These points are found either at the very beginning of the flu period (a bell of alarm for hospitals since there are far more positive than negative cases) or at the end of the epidemic in early spring (corresponding to residual cases). Based on classical extreme value theory (EVT) the Generalized Pareto distribution (GPD) is the appropriate distribution to model such extremes and we build a model based on the GPD where the distributional parameters depend on meteorological factors. It is important to stress that testing patients for flu in hospital is a process that requires human intervention. As such, the recording process on certain days (e.g., 31st of December) will be different as compared to that of other days. This contaminates the underlying distribution of the data by creating outliers which have to be dealt with. To this end, we adapt the methodology introduced by Aeberhard et al. (2019) to the specific context of this paper. To the best of our knowledge no previous work has attempted to build extreme value models based on GPD and D-GPD, where the distributional parameters are allowed to be specified as functions of covariates and the presence of outlying observations is accounted for by using a theoretically founded robust estimation approach. The newly introduced models are available through the GJRM R package (Marra and Radice, 2020) which greatly simplifies the implementation of our approach, making it as simple as a canned procedure.
When we apply our proposed approach to the hospital data, we find that our three responses of interest depend on meteorological conditions. Specifically, our results suggest that the risk of congestion (extreme positive cases) increases when temperatures go down, and in periods of no sun and no rain. The risk of testing inefficiently (extreme negative cases) significantly increases in periods of no sun and no rain. The risk of outbreak (extreme odds of positive cases) increases in cold periods. We quantify these results in Section 3.
In Section 2, we describe the proposed robust regression methodology for extremes. Section 3 reports the results of the empirical analysis for the flu hospital data while Section 4 presents the findings from a simulation study. We conclude in Section 5. q q q q q q q q q qq q qq q qq q qqq q q qq qqqq q q q q q q q q q q q q q q q q q q qq q q q q q q q q qq q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qqq q q qq qq q qqq qq q q qq q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q 
Extreme value theory is the field of statistics dedicated to the study of events with low occurrence frequencies and large amplitudes. Such events are rare in relation to the bulk of a population, which makes them hard to model and difficult to predict. Section 2.1 discusses the concepts of peaks-over-threshold and Charge-at-Risk-estimation (CaRe), and describes the approach used to derive the extreme distribution used to analyze the discrete outcomes of this paper. Section 2.2 discusses the robust approach used to estimate GPD and D-GPD models whose distributional parameters are allowed to depend on covariate effects.
One of the classical theories of extremes for a common continuous random variable is based on the probabilistic limit result for exceedances of high thresholds. The so-called peaksover-threshold (POT) consists of a limiting result for the times and sizes of exceedances over some high level. Letting (Y i ) i≥1 be a sequence of independent and identically distributed (iid) random variables in [0, y F ), with common continuous distribution F , we concentrate on the sizes of exceedances over some high threshold. In other words, the focus is on the right tail of distribution F . The result by Balkema and de Haan (1974) allows for the approximation of the conditional distribution of the exceedances above a high threshold u. If there exist normalizing sequences {a n > 0} and {b n } such that for u → y F ,
for some Z following a non-degenerate probability distribution on [0, ∞), where d → denotes weak convergence, then it is possible to model the limiting distribution of the exceedances Y − u|Y > u with a Generalized Pareto distribution (GPD), that is,
where ξ ∈ IR is the shape parameter and σ > 0 the scale parameter. The case ξ = 0 is interpreted as the limit. Parameter ξ provides information about the heaviness of the tail of the underlying distribution F . More formally, condition (1) means that Y belongs to the maximum domain of attraction of an extreme value distribution with shape parameter ξ and we write Y ∈ MDA(ξ). Some examples are the Pareto distribution,
for which we take a n = κn 1/α /α, b n = κn 1/α − κ, and is in MDA(1/α) (Fréchet case). The exponential distribution, F (y) = 1 − e −λy , λ > 0, y ≥ 0, for which we take a n = 1/λ, b n = (log n)/λ, and is in MDA(0) (Gumbel-case).
Essentially all commonly encountered continuous distributions are in the maximum domain of attraction of an extreme value distribution. If the tail of F decays like a power function then F is in MDA(ξ > 0). Distributions such as Burr, log-gamma, Cauchy, Pareto and Student-t as well as various mixture models are heavy-tailed. The Gumbel class characterized by ξ = 0 contains light-tailed distributions such as the Gaussian, lognormal, exponential and gamma whose tail decay roughly exponentially. The so-called Weibull class, defined by ξ < 0, contains distributions that are bounded above (e.g., uniform and Beta distributions). In other words, for a wide class of distributions, the distribution of the excesses over a high threshold can be approximated by the GPD. This result suggests that if we choose u high enough then we can assume that result (2) holds for some parameters ξ and σ. In practice, such parameters are estimated by fitting a GPD to the excess amounts over the threshold u, relying on the standard properties of maximum likelihood estimators for ξ > −0.5.
The choice of u is important; a very low threshold would lead to high bias whereas a very high threshold to high variance. For practical purposes, a suitable threshold u is chosen using data-analytic tools such as the mean residual life plot. This is based on the fact that if excess losses over threshold u can be characterized by a GPD with parameters ξ < 1 and σ, then it is easy to show that for any higher threshold
so that the mean excess function is linear in v above u. In empirical applications, the mean residual life plot (which shows the empirical mean excess against increasing threshold values) is a useful tool to choose the threshold and also to determine the adequacy of the GPD model as an approximation of the excess distribution. For a linear mean excess function characterizing the GPD class, the best threshold candidate is any value for which the mean excess looks linear. Figure 5 shows mean residual life plots for the odds of positive cases without removing outliers (top panel) and after removing 1% of the largest values (bottom panel). The graphs support the presence of a contamination effect due to outliers, which may indeed make the choice of the threshold difficult. This is standard for mixed distributions.
Taking the point of view of the hospital's risk management, an important quantity is the quantile of Y given that Y > u because it quantifies the information about the charge load the hospital has to be ready for under different scenarios of congestion. In practice, for a fixed threshold u, given that Y > u, and a horizon of h days, the p-quantity, called Charge-at-Risk-estimation (CaRe), is the value of Y that might be exceeded one time in h days. This is defined as
where h = 1/(1 − p). As an example, during a flu period (Y > u), 97%-CaRe roughly corresponds to the value of Y that might be exceeded once in a month. In a financial context, a related value is the co-called Value-at-Risk imposed by the Basel committee and used, for instance, to measure the risk of loss on a specific portfolio of financial assets.
For a discrete random variable R, using the GPD to approximate the distribution's tail behaviour can be inappropriate. As pointed out by Hitz et al. (2017) , many common distributions such as the Poisson, geometric and negative binomial are not in any maximum domain of interest. Hitz et al. (2017) proposed two methods for modelling the tails of discrete observations from distributions with infinite support. In this paper, we briefly recall one of them. Defining the discrete maximum domain of attraction as D-MDA, we write R ∈D-MDA(ξ) with ξ ≥ 0 if there exists a continuous random variable Y such that P (R ≥ r) = P (Y ≥ r) for r = 0, 1, 2, . . .. Then, for large integers u, we have (2), tends to a discrete generalized Pareto distribution (D-GPD) defined by
for r = 0, 1, 2, . . ., whereḠ denotes the survival function of G (see Hitz et al. (2017) and references therein).
In risk management, as mentioned ealier, the quantile is a quantity of interest. In what follows, we derive such an expression for the D-GPD. Let p ∈ (0, 1) be the probability for which we seek a quantile, we then solve
As in (4) for the continuous context, the p%-CaRe for the discrete case is
where denotes the ceiling function (the smallest integer greater than or equal to).
The next section provides details on the robust estimation approach employed to fit extreme value models based on the GPD and D-GPD, where σ and ξ can be specified as functions of covariate effects.
In the context of POT models for continuous variables through GPD excess size approximations, employing techniques that allow for flexible forms of dependence on covariates are very attractive in empirical applications (Davison and Smith, 1990) . To this end, Chavez-Demoulin and Davison (2005) employed the framework of generalized additive models (Hastie and Tibshirani, 1990; Wood, 2017) to estimate flexibly the shape and scale parameters of an orthogonal reparametrization of the GPD. Yee and Stephenson (2007) proposed instead the use of vector generalized additive models. These modelling strategies are philosophically consistent with generalized additive models for location, scale and shape (Rigby and Stasinopoulos, 2005) , where, for any continuous or discrete distribution F θ , with θ being a d-dimensional parameter vector with virtually any d > 0, all distributional parameters are allowed to depend on covariate effects. This type of modelling has received a great deal of interest since its introduction and some researchers also refer to it as distributional or multi-parameter regression. The classical and perhaps most commonly known software implementation of such models is the gamlss R package (Rigby and Stasinopoulos, 2005) . Another implementation is available via the gamlss() function from the GJRM R package (Marra and Radice, 2020) which has been extended to incorporate the models developed in this paper.
For i = 1, . . . , n, where n denotes the sample size, let Y i be independently sampled from F θ i (with density or probability function f θ i ), where θ i = (θ i1 , . . . , θ id ) and x i is a vector of covariates of dimension p (which can include binary, categorical, and continuous variables, for instance). The distributional assumption of Y i is understood to be conditional on all covariates. This is achieved by assuming for each parameter θ ij , for j = 1, . . . , d, that
where the g j are one-to-one transformations or link functions (ensuring that the parameters range restrictions are met), β j0 ∈ R are overall intercepts, x ijk denotes the kth sub-vector of covariates pertaining to term j and observation i, and the K j functions f jk (·) represent generic covariate effects (which can be of any pre-specified parametric form such as linear or quadratic, or can be non-parametric). Each of these functions are approximated by a linear combination of J kj basis functions b kjl (x ikj ) and regression
. This (regression spline) approach allows for a vast variety of covariate effects. We refer the reader to Wood (2017) for all the options available and that are supported by our implementation. Note that, in our case study, linear specifications were deemed to be sufficient to model the variation in the response variables of interest.
For GPD and D-GDP, we have that θ i = (θ i1 , θ i2 ) = (ξ i , σ i ), hence d = 2. The choices of one-to-one transformations have to guarantee that the parameters lie in their admissible definition spaces. For GPD, with probability function defined as in Equation (2), we have g 1 (ξ i ) = log (ξ i + 0.5) and g 2 (σ i ) = log (σ i ) .
For D-GDP, with probability function given by Equation (5), we employ g 1 (ξ i ) = ξ i and g 2 (σ i ) = log (σ i ) .
The above choices ensure that σ i is positive for both distributions, that ξ i > −0.5 for GPD (otherwise parameter estimation is non-regular in the sense that the score statistic is not asymptotically normal as argued by Davison and Smith (1990) ), and that ξ i > 0 for D-GDP as required (Hitz et al., 2017) .
Let δ be the vector of the model's parameters to be estimated. This includes the coefficients associated with (7). Model fitting is performed by maximizing the log-likelihood
log f y i |θ . Note that, although not required for our case study, our implementation supports the presence of non-parametric components. In this case, the objective function would be augmented by a penalty term defined as 1/2δ Sδ, where S is a matrix that depends on the choice of basis functions for the nonparametric terms, and on a set of smoothing parameters that controls the trade-off between fit and smoothness.
If outlying observations occur in the data, classical model fitting will suffer from a lack of robustness, which will adversely affect parameter estimates. To deal with this, we adopt the methodology of Aeberhard et al. (2019) which essentially consists of reducing the likelihood contributions of low log-likelihood values while leaving large log-likelihood evaluations essentially unchanged. This is achieved through a function ρ c applied to the log-likelihood components, so that the objective function becomes˜
is a correction factor ensuring Fisher consistency, and ρ c is directly derived from the specified ρ c through ρ c (z) = z −∞ exp(s)ρ c (s) ds with ρ c (s) = ∂ρ c (s)/∂s. The tuning constant c > 0 in ρ c regulates the trade-off between loss of estimation efficiency (should the data exactly come from the assumed model) and the magnitude of the maximum estimation bias (should the data not come from the postulated model). For any given c, ρ c is assumed to be convex, monotonically increasing and twice continuously differentiable over R, and to have bounded first derivative ρ c within [0, 1]. The latter can be interpreted as a multiplicative robustness weight, as one would add when weighting the estimating equations in robust M -estimation. An advantage of the approach is that it leads to a natural definition of robust information criteria.
Regarding the choice of ρ c , Aeberhard et al. (2019) recommend using the log-logistic function first proposed by Eguchi and Kano (2001) : ρ c (z) = log 1+exp(z+c) 1+exp(c) , for c > 0, with corresponding ρ c (z) = exp(z) − exp(c) log 1 + exp(z + c) and first derivative ρ c (z) = exp(z + c)/ 1 + exp(z + c) . It holds that lim c→∞ ρ c (z) = z so that an increasingly large c value leads to the (non-robust) original (δ). The value of c is tuned via a simulation based procedure that controls how the robustness weights at the score level (represented by ρ c ) behave under data generated from the assumed model. The user can decide the level of down-weighting to be achieved with respect to maximum likelihood (e.g., 95%). Aeberhard et al. (2019) established the Fisher consistency ofδ as well as its asymptotic Gaussian distribution and asymptotic variance-covariance matrix which can be used to construct confidence intervals. The authors discussed a Bayesian inferential result as well. This is advantageous because such a result does not rely on asymptotic considerations, and intervals for non-linear functions of the model's parameters (e.g., CaRe) can be reliably and efficiently obtained via posterior simulation. The adopted estimation framework allows for the elegant construction of robust information criteria such as the robust AIC, that is,
where edf denotes the effective degrees of freedom which is given by the trace of a matrix that depends on components of the asymptotic variance-covariance matrix ofδ (Aeberhard et al., 2019) .
In order to estimate the model's coefficients, we have extended the efficient and stable trust region algorithm proposed by Marra and Radice (2019) to our context. One of the many advantages of such an algorithm is that it does not require the orthogonality of the distributional parameters (in this case, ξ and σ). The implementation of the trust region approach required the analytical score and Hessian of the model's log-likelihood which were derived and are reported in Supplementary Section A.
Although robust models for extremes have been developed in the literature (see, e.g., Dupuis and Field, 1998; Dupuis and Victoria-Feser, 2006; Dell'Aquila and Embrechts, 2006) , we would like to stress that, to the best of our knowledge, there are no alternative robust regression models for extreme distributions, nor respective software implementations, of the type discussed in this paper. While the construction and estimation of the proposed model rely on the infrastructure and modelling framework of GJRM, extending the software to accommodate the developments needed to address the challenges of our case study required a great deal of work. Supplementary Section B provides details on the usage of function gamlss() from the GJRM R package.
Flu is contagious and it can spread by airborne respiratory droplets, saliva or skin-to-skin contact and by touching a contaminated surface. In Switzerland, a sentinel surveillance system and a mandatory reporting system are used to register flu data. Flu monitoring in hospitalized patients has also been in a testing phase since 2018. From a health care managerial point of view, the number of negative cases among tested patients showing flu-like symptoms is as important as the number of positive cases. An extreme number of positive cases may indicate an epidemic of such a viral infection. An extreme number of negatives can instead indicate management inefficiency and hence excessive financial costs as well as congestion in the hospital units that are involved in diagnostics and pretreatment. The contagion aspect of hospitalized patients also needs to be taken into account in the bed organization of the hospital.
As shown in Figures 1, 2 and 3 , the annual calendar variable does not seem to provide important insights into managing and/or preventing congestion due to a flu epidemic. Based on the literature on flu transmission, we use meteorological variables for modelling the extremes of: positive flu cases, negative cases (visiting the hospital for a flu check) and the odds of positives. The meteorological variables are represented by L 3 X t = X t−3 , where L is the usual lag operator and X t can be each of the variables in Table 1 . For each meteorological factor, we consider the respective L 3 X t value, because, for flu, the incubation time is usually between 24 and 48 hours, and sometimes 72 hours. When discussing the models used for the analyses, extension L3 at the end of each covariate's name refers to L 3 X t values. As for the flu data, the meteorological variables were measured in Lausanne (Switzerland) from July 1, 2016 to June 21, 2019 and are available at https://gate.meteoswiss.ch/idaweb/. Figure 4 shows a correlation plot between the meteorological variables, highlighting, as expected, that humidity and radiation are highly and negatively correlated, whereas radiation and minimum temperature are positively correlated. Recall that the aim is to quantify the effect of meteorological factors on the extremes of positive, negative, and the odds of positive cases. For these responses, we specify three different models (estimated using the approach described in Section 2.2) based on the D-GPD for the two discrete responses and on the GPD for the odds of positive extremes. The models robustness tuning constants c were set to 6.1, 6.7 and 2.6, respectively, to achieve a level of down-weighting of 95%. Since the odds of positive cases is a continuous variable, we employed the mean residual life plot, based on (3), to choose the threshold defining the tail of the underlying distribution. Figure 5 shows such a plot when using all the odds data (upper panel) and without 1% of the largest values (lower panel). Looking at the upper panel, it is difficult to decide the threshold value: the mean excess curve exhibits very little linear stability and the confidence bounds become increasingly wide. In this case we choose 0.05, the value for which the mean excess tends to increase in a roughly linear manner. The lower panel, which excludes potential outliers, confirms the adequacy of the chosen threshold value. It is interesting to note that, in agreement with the analysis of Nešlehová et al. (2006) for mean excess plots in the presence of contaminated data, the results shown in Figure  5 support the presence of contamination due to outlying observations. More precisely, the different nature of the largest values makes the mean excess curve of the upper panel difficult to interpret. Forward variable selection (based on the RAIC defined in Equation (8)) was performed for the three models. We checked for linear and non-linear covariate effects; as mentioned in Section 2.2, linear specifications were found to be adequate for the modelling purposes of our dataset.
For all responses, a constant model was selected for the shape parameter ξ. This is not surprising, first, because this parameter is difficult to estimate (Hosking and Wallis, 1987) , and, second, because it concerns the tail behavior of the underlying process, a characteristic that is not likely to vary with meteorological factors. The estimated shape parameters related to the two discrete variables (positive and negative) are close to zero, meaning an underlying light tail that in fact many common discrete distributions, including geometric, Poisson and negative binomial distributions have (Hitz et al., 2017) . The estimated shape parameter for the odds of positive has a negative sign, which makes sense as one can expect this odd to be bounded above. As for the scale parameter σ, we found significant and linear effects for some meteorological variables. Below we present the results for each response variable.
In this case, the final fitted D-GPD model is based on the following equations and estimates: ξ =α 0 , withα 0 = −1.974e-06 (and standard error of 3.719e-01) and
log(σ) =β 0 +β 1 MintempL3 +β 2 RadiationL3 +β 3 PrecipitationL3.
The estimated coefficients are reported in Table 2 and their effects graphically shown in Figure S1 in Supplementary Section C. -0.009 0.004 -2.11 0.035 * Signif. codes: 0 < p-value < 1e −3 : * * * , p-value < 0.01 : * * , p-value < 0.05 : *
The resulting estimated value for ξ is very close to zero, implying a probability mass function that may belong to the discrete maximum domain of attraction with ξ = 0 (Hitz et al., 2017) . The equation for the scale parameter σ explains both the variable's variance and mean. For the latter, for GPD and therefore also for D-GPD, recall that the mean excess depends on the scale parameter as shown in Equation (3). A broad interpretation of the results is that the warmer and nicer the weather, the lower the number of extreme positive cases, variability and mean. Interestingly, radiation seems to better explain the response than humidity does, which is the factor ommonly used to explain flu spread (Lowen and Steel, 2014) . As highlighted by Figure 4 , radiation and precipitation provide complementary proxies of humidity.
The final fitted D-GPD model is based on the following equations and estimates: ξ =α 0 , withα 0 = 4.505e-05 (1.142e-01) and log(σ) =β 0 +β 1 RadiationL3 +β 2 PrecipitationL3.
The estimated coefficients are reported in Table 3 and their effects shown in Figure S2 in Supplementary Section C. -0.010 0.005 -2.01 0.045 * Signif. codes: 0 < p-value < 1e −3 : * * * , p-value < 0.01 : * * , p-value < 0.05 : * As compared to the previous model, minimum temperature does not seem to explain the variability and mean of the number of negative extremes. This may be due to the fact that cold weather activates the virus which in turn leads to more positive cases. Both the effects of radiation and precipitation are less important than those found when modelling positive cases. This may be explained by the fact that better meteorological conditions (warmer months and sun) simply decrease the number of test cases. For positive cases, favorable meteorological conditions also decrease the probability of catching the flu during the autumn/winter time. In other words, the evidence suggests that radiation and precipitation, which commonly affect the positive and negative cases, mostly influence the total number of tests that are carried out. During warmer months, summer or when the weather is good during winter time, individuals tend not to go the hospital. The analysis suggests that minimum temperature influences only the spread of flu.
The final fitted GPD model is based on the following equations and estimates: log(ξ + 0.5) =α 0 , withα 0 = −3.293(0.671) and log(σ) =β 0 +β 1 MintempL3.
The estimated coefficient for MintempL3 is reported in Table 4 and its effect displayed in Figure S3 in Supplementary Section C. -0.098 0.009 -11.17 0.000 *** Signif. codes: 0 < p-value < 1e −3 : * * * , p-value < 0.01 : * * , p-value < 0.05 : * In this case the resulting estimated value of ξ is negative, implying that the underlying distribution is bounded above, that is, the ratio cannot reach extremely large values. Unsurprisingly the extremes of the odds positive do not depend on meteorological factors other than those explaining positive and negative extreme cases. However, this was not obvious because the threshold choice for the odds positive was not given by the threshold for the positive and negative cases. In this model, only minimum temperature influences the response. All in all, among the different meteorological factors observed, humidity, wind and pressure do not exhibit an effect as compared to radiation, precipitation and minimum temperature; the latter being more responsible for the epidemiological aspect of the analysis.
From a risk management point of view, a quantity of high interest is the CaRe defined in Equation (4) for GPD, and in Equation(6) for D-GPD. These values constitute important risk measures for the hospital. Intervals are also crucial as they provide information about the estimates' uncertainty.
For the positive cases, the p%-CaRe corresponds to the regime of congestion. Figures  6, 7 and 8 show some p%-CaRe estimated curves and respective intervals obtained via posterior simulation, based on different values of the meteorological factors. For instance, the bottom panel of Figure 6 corresponds to the 0.86%-CaRe, that is the number of positive cases that can be exceeded one time over a time horizon of 7 days. This point estimate decreases from 18, for a minimum temperature of -10 degC, to 11, for 0 degC. For a horizon of 7 days, the bottom left panel of Figure 7 shows that the number of positive cases that can be exceeded once a week decreases from 16, in the case of no sun, to 3, when radiation is at its highest value. This evidence should, however, be interpreted bearing in mind the widths of the intervals which are large. qqq qq qqq qqq qq qqq qqq qqqq qqq qqqq qqq qqqq qqqq qqqqq qqqq qqqqq qqqqqq qqqqq qqqqqqq qqqqqq qqqqqqqq qqqqqqqqq qqqq Supplementary Figures S4 and S5 show the CaRe estimated values with their simulated intervals as a function of meteorological predictors, for different time horizons for negative cases. These values convey information on the risk of inefficiency in the flu testing process, revealed by a very high number of negative cases. The risk of inefficiency considerably decreases both in sunny and raining periods. The top panel of Figure S5 shows the estimated number of negative cases that can be exceeded once a month in terms of amount of precipitation. For a 30-day horizon, CaRe goes from 50, in the scenario of no rain, to 30 when it rains.
Large estimated p%-CaRe values for the odds positives, as shown in Figure S6 with their simulated intervals, correspond to the epidemic regime. Note that the intervals are thinner as compared to those obtained for the discrete responses, but the values themselves are smaller (between 0 and 1).
The hospital flu testing process depends on managerial and/or decision making instances and may lead to outlying records; our robust methodology is capable of detecting these abnormal values. Figures 9, 10 and 11 show the robustness weight w = ρ c (see Section 2.2) for each observation. These are obtained as a by product of the parameter estimation process. The size of the circles is proportional to (1 − w). These weights can be used to identify outliers: the lower the weight, the more likely the observation is to be outlying. We identify the points with the smallest weights, accompanied by their date of occurrence, from the figures. The observations with the smallest weights are not systematically those with large observed values, and, conversely, the largest observations are not systematically considered outliers. This can be seen in particular for the odds of positive cases.
Dates such as 03/01/2017 and 02/01/2018 (which are after the Christmas break) are typically regarded as special days in the flu recording process. Days in February 2019 such as 24/02/2019 and 26/02/2019 in Figure 9 relate to positive cases and correspond to school holidays. At school, children are super-spreaders. This is not the case during holidays when children are with their families. This and the fact that people are less tested during holidays contribute to a significant slow-down of the flu epidemic. q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q qqq q q q qq q qq qq q qq q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qqq qq qq qq q q q q qq q q q q q q qq q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q 
To assess the empirical properties of our proposal in finite samples, we designed a simulation study inspired by our data analysis in Section 3. We will look at the quality of the estimated parameters and CaRe obtained using the proposed approach, both under the assumed (D-GPD or GPD) model and under contamination (i.e., in the presence of observations that deviate from the assumed model).
For D-GPD responses, we generated "clean" datasets from the model
where the covariates distributions were chosen to mimic the behavior of MintempL3, RadiationL3 and PrecipitationL3 in the application. More precisely, we simulated the covariates as follows: x 1 ∼ N (2.3, 14) , x 2 ∼ Γ(1.55, 0.02) and x 3 ∼ lognormal(0.71, 3.12).
These were kept fixed throughout the simulation replicates. The parameters, inspired by our case study, were set to α = 0.01 (hence ξ = 10 −4 ), and β = (2, −0.05, −0.005, −0.01) T . Contaminated datasets were obtained by randomly setting 5% of the response values to the maximum value observed in the sample. Again, this was inspired by the empirical application.
The sample size was set to n = 250 (hence consistent with our application) and the number of replications to 500. We fitted models based on the robust and classical maximum likelihood estimators. For the robust approach, we chose c = 5.8 to achieve a downweighting of 0.95. (9). In each panel, the left boxplots refer to the clean data setting, and the right ones to the contaminated data setting. Figure 12 shows the centered estimated parameter estimates for model (9) . By looking at the left boxplots of each panel, corresponding to the clean data setting, we see that both boxplots are centered around zero suggesting unbiased estimation of the model parameters. We also see that the variability of the robust estimator's estimates are slightly larger than the variability of those obtained using its classical counterpart; this is expected because of the loss of efficiency of the robust estimator with respect to maximum likelihood. The story is different when looking at the right boxplots of each panel, corresponding to the contaminated data. All in all, the robust estimator performs much better than the classical one. For all the components of β, except β 2 , the robust estimator shows no bias. This is not the case for the classical estimator, which is influenced by the outliers, sometimes heavily, notably for β 0 and β 3 . Surprisingly, the robust estimator shows some bias for β 2 , but its magnitude is small. Also note that contamination affects the variability of the classical estimator, which is larger than that of the robust estimator for all the components of β. The estimation of α 0 under contamination seems more difficult. Both estimators show bias, even though that bias is much smaller for the robust estimator. It is worth recalling that a robust estimator guarantees that the bias under contamination does not explode, but it does not guarantee that it will vanish. Had we increased the amount of contamination or its strength, we would have expected the bias of the classical estimator to explode, but not that of the robust approach. Figure 13 : CaRe estimates for h = 7 for four values of x 1 : its minimum value (first row), its average (second row), its third quartile (third row) and its maximum (fourth row). The other covariates are fixed at their mean values. The true population value is identified by a darker bar. The first two columns correspond to the clean data setting, whereas the last two columns correspond to the contaminated data setting. Figure 13 reports the estimated CaRe for h = 7 as a function of x 1 , with x 2 and x 3 fixed at their mean values. CaRe is a discrete positive value (with relatively few different values in our simulation setting) and we depict it using barplots (histograms) for four representative values across the range of x 1 : its minimum (first row), its average (second row), its third quartile (third row) and its maximum (fourth row). In each panel, the true population value is identified by the dark bar. The comparison of the first two columns confirms that the robust and classical estimators perform equally well and their estimates either match the population value or are just off by one unit. Looking at the results under contamination and comparing the last two columns of the figure, we observed that the robust estimator performs much better than the classical one in that it identifies the true population value more often (roughly 95% of the times, except for min(x 1 ) where this is about 80%). In contrast, the classical CaRe estimator shows large variability and misses the population target quite often. The quality of the CaRe estimates is not uniform across the range of x 1 , with lower values of the covariate being more challenging.
We provide in the supplementary material similar figures for all the other combinations of horizons h and covariates; the conclusions do not change. Moreover, as expected, we observe that the performance of both estimators worsen as h increases, and that the CaRe seems to be difficult to estimate for low values of x 3 .
To sum up, our simulation study demonstrates that our distributional regression approach is effective in estimating models with D-GPD responses, and that the robust version of the estimator can successfully cope with contaminated data.
In this case, we generated data using the model log(ξ + 0.5) = α 0 and log(σ) = β 0 + β 1 x 1 ,
where x 1 ∼ N (2.3, 14) , which reproduces what we see in our application for MintempL3. We consider α = −2 (hence ξ = −0.36) and β = (−1.3, −0.1) T . Contaminated datasets were obtained by randomly setting 5% of the response values to the maximum value observed in the sample. The sample size was set to n = 250 and the number of replications to 500. Here as well, we fitted models based on the robust and classical maximum likelihood estimators, and for the robust approach, we chose c = 2.3 to achieve a downweighting of 0.95. The analysis of the boxplots of the centered parameter estimates for model (10) conveys the same conclusions as for the case of D-GPD: the robust estimator performs as well as its classical counterpart when using clean data, and outperforms the classical estimator under contamination. Furthermore, it is known that the GPD is difficult to fit and our findings suggest that our robust approach has a stabilizing property even for clean data where it corrects what seems to be a finite sample bias of the maximum likelihood estimator when estimating α 0 . It has been previously observed in the literature that robust estimators converge faster than their classical counterparts to their asymptotic distribution. Figure 15 shows functional boxplots (Sun and Genton, 2011) for the CaRe estimates as a function of x 1 . The solid red line is the median curve and the envelope represents the 50% deepest, or most central, curves, much like the interquartile range in a regular boxplot. The black dashed line is the true population CaRe. The first two rows of the panels refer to the clean data setting, whereas the last two rows to the contaminated data setting. Figure 15 : Functional boxplots of CaRe estimates as a function of x 1 for h = 30 (first column), h = 14 (second column) and h = 7 (third column). The solid red line is the median curve and the envelope represents the 50% deepest, or most central, observations. The black dashed line is the true population CaRe. The first two rows of panels are for the clean data setting, the last two rows are for the contaminated data setting.
From the two top rows, we observe that for clean data both the classical and robust estimates are aligned with the population values. When the data are contaminated (third and fourth rows of panels) the classical estimator completely misses the target by overestimating the CaRe, whereas the robust estimator continues to perform well. The wider pink envelopes also suggest that the classical estimator has larger variability than the robust one under contamination. The unsatisfactory behavior of the classical estimator worsens with an increasing h, as one would expect.
In summary, once again, we observe that our distributional regression approach works well in estimating models with GPD responses, with the robust version being rather stable under contamination.
Seasonal epidemics may lead to hospitals congestion. In this paper, we use extreme value theory to study the occurrence of large numbers of flu cases in a hospital. To this end, we developed and implemented in GJRM a robust regression-type methodology that allows for non-identically distributed discrete and continuous extremes, and that deals with outlying data. The response variables of interest (the positive and negative cases together with the odds of positives) are statistically explained by meteorological variables. Although the models selected for this case study are based on parametric covariate effects, our software implementation allows for very general non-parametric functional forms, which would most likely be required for larger datasets.
Taking the point of view of the hospital, which needs to manage admission capacities, we introduced the notion of charge-at-risk whose estimation, based on meteorological factors, can serve as a quantitative tool to alert the hospital and allow time to prepare for a possible congestion. The introduced approach could be applied to several types of seasonal virus data such as those deriving from the new virus SARS-CoV-2. 
This section provides the analytical score and Hessian components of the model's loglikelihood, for the GPD and D-GPD distributions. We also report the expectations and variances for the two distributions, and for the D-GPD we explain how variates are simulated.
If Y follows a GPD distribution with shape parameter ξ and scale parameter σ, then its cumulative distribution function is F (σ,ξ) (y) = 1 − G (σ,ξ) (y) (with G (σ,ξ) (y) given in (2)) which is defined for σ > 0 and for {y : y > 0 and 1 + ξy σ > 0}. Then the probability density function is
.
The expectation of Y is E(Y ) = σ 1−ξ and the variance is V ar(Y ) = σ 2 (1+ξ) 2 (1−2ξ) .
Having observed y = {y 1 , y 2 , · · · , y n } as independent realizations of Y the log-likelihood is
log 1 + ξy i σ .
The first and second derivatives with respect to ξ and σ are
If Y follows a D-GPD distribution with shape parameter ξ and scale parameter σ then the probability mass function of Y = r, where r ∈ N 0 = {0, 1, 2, ...} is, using Equation (5),
which is defined for σ > 0 and for {r : 1 + ξr σ > 0 and 1 + ξ(r+1) σ > 0}.
The mean and variance have to be calculated numerically. Specifically,
Having observed y = {y 1 , y 2 , . . . , y n } as independent realizations of Y , the log-likelihood is
The first and second derivatives with respect to ξ and σ are
the elements of which are
In this section, we illustrate the usage of the GJRM package (Marra and Radice, 2020) to fit the extreme value models introduced in this article. The examples below are based on artificial data sets.
n.size <-250 x1 <-rnorm(n.size) x2 <-rnorm(n.size) x3 <-rnorm(n.size) XX <-data.frame(x1 = x1, x2 = x2, x3 = x3) Xmat <-model.matrix(~x1 + x2 + x3) Figure S5 : Negative cases: estimated CaRe for h = 30, 14, 7 days (panels from top to bottom) with respect to lagged precipitation. The bars correspond to 95% intervals. The other covariates are fixed to their mean values. q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq qq qq qq qq qq qq qq qq qq qq qq qq qq qqq qqq qqq qqq qqq qqqq qqqq qqqq qqq 0.5 1.0 1.5 −10 −5 0 5 10 15
CaRe_30 days q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq qq qq qq qq qq qq qq qq qq qq qq qq qq qqq qqq qqq qqq qqq qqqq qqqq qqqq CaRe_14 days q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q q qq qq qq qq qq qq qq qq qq qq qq qq qq qq qqq qqq qqq qqq qqq qqqq qqqq qqqq qq Figure S7 : CaRe estimates for h = 7 for four values of x 2 : its minimum value (first row), its average (second row), its third quartile (third row) and its maximum (fourth row). The other covariates are fixed at their mean values. The true population value is identified by a darker bar. The first two columns correspond to the clean data setting, whereas the last two columns correspond to the contaminated data setting. Figure S8 : CaRe estimates for h = 7 for four values of x 3 : its minimum value (first row), its average (second row), its third quartile (third row) and its maximum (fourth row). The other covariates are fixed at their mean values. The true population value is identified by a darker bar. The first two columns correspond to the clean data setting, whereas the last two columns correspond to the contaminated data setting. Figure S9 : CaRe estimates for h = 14 for four values of x 1 : its minimum value (first row), its average (second row), its third quartile (third row) and its maximum (fourth row). The other covariates are fixed at their mean values. The true population value is identified by a darker bar. The first two columns correspond to the clean data setting, whereas the last two columns correspond to the contaminated data setting. Figure S10 : CaRe estimates for h = 14 for four values of x 2 : its minimum value (first row), its average (second row), its third quartile (third row) and its maximum (fourth row). The other covariates are fixed at their mean values. The true population value is identified by a darker bar. The first two columns correspond to the clean data setting, whereas the last two columns correspond to the contaminated data setting. Figure S11 : CaRe estimates for h = 14 for four values of x 3 : its minimum value (first row), its average (second row), its third quartile (third row) and its maximum (fourth row). The other covariates are fixed at their mean values. The true population value is identified by a darker bar. The first two columns correspond to the clean data setting, whereas the last two columns correspond to the contaminated data setting. Figure S12 : CaRe estimates for h = 30 for four values of x 1 : its minimum value (first row), its average (second row), its third quartile (third row) and its maximum (fourth row). The other covariates are fixed at their mean values. The true population value is identified by a darker bar. The first two columns correspond to the clean data setting, whereas the last two columns correspond to the contaminated data setting. Figure S13 : CaRe estimates for h = 30 for four values of x 2 : its minimum value (first row), its average (second row), its third quartile (third row) and its maximum (fourth row). The other covariates are fixed at their mean values. The true population value is identified by a darker bar. The first two columns correspond to the clean data setting, whereas the last two columns correspond to the contaminated data setting. Figure S14 : CaRe estimates for h = 30 for four values of x 3 : its minimum value (first row), its average (second row), its third quartile (third row) and its maximum (fourth row). The other covariates are fixed at their mean values. The true population value is identified by a darker bar. The first two columns correspond to the clean data setting, whereas the last two columns correspond to the contaminated data setting.