Movatterモバイル変換


[0]ホーム

URL:


GHRmodel

LicenseCRAN statusCRAN downloads totalCRAN downloads month

Overview

TheGHRmodel package supports modeling healthoutcomes using Bayesian hierarchical spatio-temporal models with complexcovariate effects (e.g., linear, non-linear, interactions, distributedlag linear and non-linear models) in theR-INLA framework. It is designedto help users identify key drivers and predictors of disease risk byenabling streamlined model exploration, comparison, and visualization ofcomplex covariate effects.

The image below shows the structure of theGHRmodelpackage, outlining its functions (in blue), GHRmodel-specific outputobjects (in purple), generic output objects (in grey), and generalfunctionality. Generic output objects can be provided directly by theuser or can be generated usingGHRmodel helperfunctions.

TheGHRmodel package is designed to work in tandemwith other packages of the GHRtools suite:GHRexplore,which facilitates data exploration and visualization, andGHRpredict, which computes out-of-sample probabilisticpredictions of models developed inGHRmodel and enablespredictive performance evaluation.

More information about the toolkit, with tutorials and publishedexamples can be found at thiswebsite.


Installation

The latest version of theGHRmodel package is hostedonCRAN and can by installedusing the following commands:

# Install from CRANinstall.packages("GHRmodel")# Get the development version from Gitlablibrary(devtools)devtools::install_git('https://earth.bsc.es/gitlab/ghr/ghrmodel.git')

GHRmodel depends on theINLApackage, which is not available on CRAN. Instead, it must be installedfrom its own repository as follows:

install.packages("INLA",repos=c(getOption("repos"),INLA="https://inla.r-inla-download.org/R/stable"),dep=TRUE)

In case you run into any issues, please check the installationinstructions on theR-INLA website.

Usage

To fit a model with R-INLA, formulas need to follow its requiredsyntax and structural conventions. INLA-compatible model formulas can bedeveloped using either:

In this example the user provides a list of INLA-compatible modelformulas. These are passed to theas_GHRformulas() functionto be converted into a standardizedGHRformulas object.This ensures consistent output structure and random effect specificationacross models that can be interpreted by the functionfit_models() for model fitting.

library("GHRmodel")# Convert list of user-defined INLA formulas into a GHRformulas objectformulas_user_ghr<-as_GHRformulas(c(# Model 1: random effects only, where monthly random effect is replicated by meso region and the spatial random effect is replicated by year"dengue_cases ~ 1 +     f(month_id, model = 'rw1', replicate = spat_meso_id, cyclic = TRUE, constr = TRUE, hyper = prior_t) +     f(year_id, model = 'iid', constr = TRUE, hyper = prior_t) +     f(spat_id, model = 'bym2', graph = g, constr = TRUE, hyper = prior_sp, replicate = year_id2)",# Model 2: random effects and a varying effect for pdsi lag 1 by climate zone"dengue_cases ~ 1 + f(main_climate_f, pdsi.l1, model = 'iid') +     f(month_id, model = 'rw1', replicate = spat_meso_id, cyclic = TRUE, constr = TRUE, hyper = prior_t) +     f(year_id, model = 'iid', constr = TRUE, hyper = prior_t) +     f(spat_id, model = 'bym2', graph = g, constr = TRUE, hyper = prior_sp, replicate = year_id2)",# Model 3: random effects and a 3-way interaction between different pdsi and tmin lags"dengue_cases ~ 1 + pdsi.l1 + tmin.l3 + pdsi.l6 + pdsi.l1:tmin.l3:pdsi.l6 +     f(month_id, model = 'rw1', replicate = spat_meso_id, cyclic = TRUE, constr = TRUE, hyper = prior_t) +     f(year_id, model = 'iid', constr = TRUE, hyper = prior_t) +     f(spat_id, model = 'bym2', graph = g, constr = TRUE, hyper = prior_sp, replicate = year_id2)"))

Thefit_models() function allows users to fit a set ofINLA-compatible model formulas defined by aGHRformulasobject to a provided data set. It automates model fitting, extraction ofoutputs, and computation of a wide range of goodness-of-fit (GoF)metrics. The output is aGHRmodels object.

# User-defined INLA-compatible formulas can be passed into fit_models() as a GHRformulas objectmodel_user<-fit_models(formulas = formulas_user_ghr,data = data,family ="nbinomial",# Negative binomial likelihoodname ="mod",# Label prefix for each modeloffset ="population",# Offset variable to account for population sizecontrol_compute =list(config =FALSE,# Do not posterior predictive distributionvcov =FALSE# Do not return variance-covariance matrix  ),pb =TRUE,# Display progress barnthreads =8# Use 8 threads for parallel computation)

For model evaluation,GHRmodel provides a range offunctions for model diagnostics, interpretation and evaluation.Functions with the prefixplot_* return graphicalggplot2 orcowplot objects, allowing users toeasily customize visual outputs.

# Plot any linear coefficients found in the fitted model results.plot_coef_lin(model = model_user,# Provide fitted model GHRmodels objectexp =TRUE,# Exponentiate coefficients to relative risk scaletitle ="Relative Risk (RR)"# Plot title)

Developers

GiovenaleMoirano, PhDORCID
Barcelona Supercomputing Center
Global Health Resilience

Carles Milà,PhDORCID
Barcelona Supercomputing Center
Global Health Resilience

Anna B.Kawiecki, PhDORCID
Barcelona Supercomputing Center
Global Health Resilience

Rachel Lowe,PhDORCID
Barcelona Supercomputing Center
Global Health Resilience (Group leader)


[8]ページ先頭

©2009-2025 Movatter.jp