predict_hm: Predict function for Health module

Description Usage Arguments Value Note Examples

View source: R/predict_hm.R

Description

This function predicts the number of considered health outcomes. Each outcome is predicted with GAM models previously trained on historical data. Once trained, GAM model estimates the number of health event of the simulated day with relative 95 data frame. The data frame is composed by simulated days: n rows and 6 columns. Each row gives the fitted number, with relative 95 considered health outcomes for each simulated day. Each column represents respectively the date of the simulated day, the health outcomes, the 95 number of events, the predicted average daily number of events and the the 95 events.

Usage

1
2
3
4
5
6
7
8
9
predict_hm(
  models,
  weather_history,
  weather_today,
  ...,
  full_year = (!"o38h" %in% names(weather_today)) ||
    (all(purrr::map_lgl(models[["summer"]], is.null))),
  digits = 4L
)

Arguments

models

[lst] A list with 7 elements. Each element corresponds to previously trained model for the outcome of interest.

weather_history

[data frame] A data frame with weather historical data to use as history for each "today" predicted. At least the following column (with exactly the same column names) are needed: - date = date expressed in the format 'yyyy-mm-dd'; - temp_mean = mean temperature of corresponding day (Celsius); - press_bar_mean = mean pressure of corresponding day (hPascal); - pm10 = mean value of pm10 of corresponding day (μ g/m^3); - pm25 = mean value of pm25 of corresponding day (μ g/m^3); - no2 = mean value of no2 of corresponding day (μ g/m^3).

If provided, by a column named 038h, also information of O3 daily maximum concentration for the daily 8-hours moving-means will be used (only for summer period, i.e., from April, 1st, to September, 30th).

weather_today

[data frame] A data frame with data on weather for the simulated day(s) to be predicted. The data frame must contains at least the following column (with exactly the same column names): - date = date expressed in the format 'yyyy-mm-dd'; - temp_mean = mean temperature of corresponding day (Celsius); - press_bar_mean = mean pressure of corresponding day (hPascal); - pm10 = mean value of pm10 of corresponding day (μ g/m^3); - pm25 = mean value of pm25 of corresponding day (μ g/m^3); - no2 = mean value of no2 of corresponding day (μ g/m^3).

If provided, by a column named 038h, also information of O3 daily maximum concentration for the daily 8-hours moving-means will be used (only for summer period, i.e., from April, 1st, to September, 30th).

...

possible further arguments passed to the function

full_year

[lgl] should the models (and prediction) be made on the same full-year data or should summer or non-summer models be used? If TRUE full-year models are used. By default, full-year are used in the of missing summer- or non-summer-model or if weather_history or weather_today do not have ozone information (i.e., there are no o38h variable)

digits

integer indicating the number of decimal places (round). default is 4.

Value

a data frame with the fitted value (i.e., average predicted events) including 95 and upper) for each type of event mange by the models used for each date considered.

Note

To provide teh prediction, the models use lags up to three day in the past for every 'weather_today' predicted. That means that for each date/records in the 'weather_today', in the 'weather_history' there must be present at least information upt to three days earlier (with the corresponding dates)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(imthcm)
default_models <- train_event_models(use_ita = TRUE)
predict_hm(default_models, test_weather, test_weather[731L, ])
predict_hm(default_models, test_weather, test_weather[c(731L, 730L), ],
  full_year = TRUE
)

no_o3_test_weather <- dplyr::select(test_weather, -o38h)
predict_hm(default_models, no_o3_test_weather,
  no_o3_test_weather[731L, ]
)

UBESP-DCTV/imthcm documentation built on Dec. 2, 2019, 9:26 a.m.