# Load example GHRmodels object from the package
model_dlnm_file <- system.file("examples", "model_dlnm.rds", package = "GHRmodel")
model_dlnm <- readRDS(model_dlnm_file)
# Load example cross-basis matrix from the package: 2-dimensional cross-basis matrix of the
# non-linear effect of dengue risk across tmin values and lags:
cb_tmin_file <- system.file("examples","cb_tmin.rds", package = "GHRmodel")
cb_tmin <- readRDS(cb_tmin_file) # loads cross-basis matrix into the environment
# Generate predictions
pred_result <- crosspred_inla(
models = model_dlnm,
basis = cb_tmin,
mod_id = "mod3",
at = seq(17, 24, by = 1), # e.g., temperature sequence
lag = 2,
cen = 20,
ci.level = 0.95
)
# Plot DLNM predictions
plot_coef_crosspred(
crosspred = pred_result, # Crosspred object with model predictions
type = "slices", # Plot temperature-specific slices of exposure-response curves
exp = TRUE, # Exponentiate the coefficients (to relative risk scale)
var = c(22:24), # Display results for temperature 22°C to 24°C
line_color = "red", # Red color for the lines representing effect estimates
line_size = 0.8, # Line thickness set to 0.8 for better visibility
ribbon_color = "red", # Red shading for credible interval ribbons
ribbon_alpha = 0.3, # Set ribbon transparency to 30%
title = "Effect of minimum temperatures 22°C to 23°C on dengue relative risk by lag",
xlab = "Lag", # Label for the x-axis (exposure variable)
ylab = "Relative Risk (RR)" # Label for the y-axis (effect estimate scale)
)
Run the code above in your browser using DataLab