Functions & Formulae

Each applied formula has its own function page, with a signature, implementations, and tests.

Forecasting health service use and measuring forecast accuracy

U_t = sum_a P_(a,t) * r_(a,0); yhat_next = alpha * y_t + (1 - alpha) * yhat_t; MAE = (1 / n) * sum_t |y_t - yhat_t|

Maps past use and projected populations to forecasts of future service use, by applying age-specific use rates to a projected population or by smoothing a time series of activity, and compares forecasts with data held back from fitting to measure their accuracy. The notation follows the Demand Forecasting article and its ageing district.

  • Demographic projection of service use from age-specific base-year rates

    U_t = P_1 * r_1 + P_2 * r_2 + P_3 * r_3

    Applies the base-year use rate of each age group to that group's projected population and adds the results. The article's form sums over any number of age groups; three are written out here so that the calculator can run. Only the size and age structure of the population change; the rates stay at base-year levels unless a scenario changes them. Converting the forecast to beds is HE-FM-ALOS-002 solved for beds.

  • Simple exponential smoothing forecast for the next period

    yhat_next = alpha * y_t + (1 - alpha) * yhat_t

    Forecasts the next period as a weighted average of the latest observation and the forecast that had been made for it, or equivalently the previous forecast corrected by a share alpha of its error. Unrolled, the weights on past observations decline exponentially with age. The method suits series with no clear trend or seasonal pattern; Holt's method adds a trend and seasonal versions add a seasonal component.

  • Mean absolute error and mean absolute percentage error over three test periods

    e_1 = y_1 - f_1; e_2 = y_2 - f_2; e_3 = y_3 - f_3; MAE = (abs(e_1) + abs(e_2) + abs(e_3)) / 3; MAPE = 100 / 3 * (abs(e_1 / y_1) + abs(e_2 / y_2) + abs(e_3 / y_3))

    Summarises forecast errors, observed minus forecast, over periods held back from fitting. The MAE is in the units of the data; the MAPE expresses each error as a percentage of the observed value, so it is unit-free but undefined when an observed value is zero and extreme when values are close to zero. The general forms average over any number of test periods; three are written out here so that the calculator can run. Evaluating Stockholm's forecasts of annual growth in drug expenditure, Linnér and colleagues reported a mean absolute error of 1.9 percentage points.