Forecasting tool for hospital demand during heat periods

This tool has been developed by researchers at ISPM, University of Bern, in the context of the NCCS project about impacts of climate change on health in Switzerland.

This forecasting tool allows to:
(i) quantify the association between visits to emergency department and daily temperature, based on historical data provided;
(ii) generate short-term forecasts of the expected number of patient visits on new data, given temperature and number of visits observed in the past week and temperature forecasts for the next days.

We showcase an application of the tool to data from the emergency department at Bern University Hospital, and mean temperature data for the city of Bern.

You can upload your own data to test the tool for your case study. Check the user guide for instructions on how to use this tool.

The tool has been implemented as an R shiny app by Laura Di Domenico.
If you use this tool, please refer to the following publication:
Di Domenico L, Wohlfender MS, Hautz WE, Vicedo-Cabrera AM, Althaus CL,
A forecasting tool of hospital demand during heat periods: a case study in Bern, Switzerland
The R code is available on GitHub in this repository


Section 1: DATA

In this section, you can choose the data source and the time period of interest for the analysis.

You can also define the training and test set for the model.

Upload your own data in CSV format, following the template on the right.

Include at least three columns, named 'date' (YYYY-MM-DD), 'hosp_counts' (number of daily visits to the hospital), and a column with temperature of interest (e.g., 'mean_temp' with the average daily temperature).


Section 2: MODEL

In this section, we estimate the association between temperature and hospital visits.

The 'Beginner' mode allows you to run the regression model using a set of predefined predictors. The 'Expert' mode allows you to change predictors and obtain additional details on the model fit.

Download Plot

The association with temperature is non-linear and modelled with natural cubic splines. The dotted vertical lines represent the position of the knots for the splines. The red line represents the estimated change in the number of hospital visits for a given temperature with respect to a temperature of minimum risk. The gray shaded area represents the confidence interval.


In the following tabs, you can find additional details on the model fit, predictions and evaluation metrics.

In this panel, we show histograms of the observed temperature data, for the training set and the test set. Temperature ranges were data in the training set are scarce will lead to higher uncertainty in the estimate of the exposure response function.

In this panel, we show the time series of daily observed temperature per year, for the time period of interest. Temperature values above a given threshold (default 25 °C) are shown in red. You can change the default threshold value in the input field.

The table shows an overview of the user inputs for the data and the regression model. You can save this settings along with the model results.

This panel displays the output of the model summary( ) function in R.


                

In the plot above, we used the regression coefficients estimated for the temperature indicator to build the exposure-response function.

In the panels below, we show the regression coefficients for the other predictors in the model, in particular the autoregressive terms (left) and the effect of day of the week and holiday (right).

In this panel, we show evaluation metrics for the model fit on the training set and 1-step ahead predictions on the test set. The evaluation metrics are computed using the root mean square error (RMSE), mean absolute error (MAE) and Akaike Information Criterion (AIC). We show results for the reference model (with temperature as predictor), for a model without temperature, and for two naive models of last observatoon carried forrward (LOCF).

Train set
Test set

This panel shows the fit of the model on the training set. Green represents the fitted values, while black indicate the data. Dots indicate daily values; lines indicate a weekly rolling mean as a guide for the eye.

In left panel, we show examples of model forecasts at three time points in the test set. Dots represent the raw data. The black line indicate 1-step ahead prediction and it is shown as a reference. The blue line indicate forecats for the next 7 days (continuous line) or 21 days (dashed line). Shaded area indicate prediction intervals (50% and 90% PI). Prediction interval for step h assumes a point prediction on step h-1, without propagating uncertainty from one day to the next. A method for propagating uncertainty in the prediction interval is implemented in Section 3.

In the right panel, we show forecast errors (computed as root mean squared error (RMSE)) for different forecast horizons.

In the plot on the left, we show forecast errors (computed as root mean squared error (RMSE)) for different forecast horizons (first, second or third week in the future), for the reference model and for a model neglecting temperature as predictor. We consider here all possible forecasting windows in the test set, each one with a given strating date.

On the right, we consider a subset of forecasting windows, corresponding to the ones where the average temperature in the 7-day period of the forecasting window is above a given threshold value.

In this panel we show forecast errors on the test set, after cross validation across years. For each year in the data, we train the model on all years except one year, and test the model on the remaining data. Then, we compute forecast errors on the test set, analogously to what is done in the 'Forecast errors' tab.


Section 3: FORECASTS

In this section, we generate forecasts of future hospital visits based on the model estimated above.

The default mode 'Test set' will generate retrospective forecasts on the test set. To generate forecasts in real time, choose the 'New data (upload)' option and upload a csv file with temperature and hospital data in the latest week and expected temperature for the upcoming days.