GHRtools
  • Home
  • data4health
    • Overview
  • clim4health
    • Overview
  • GHRexplore
    • Overview
    • Reference
    • Changelog

    • Vignettes
    • Getting started
  • GHRmodel
    • Overview
    • Reference
    • Changelog

    • Vignettes
    • Getting started
    • Covariate structures
    • DLNMs in GHRmodel
  • GHRpredict
    • Overview
  • About GHR

On this page

  • Add Covariates to All Combinations
    • Description
    • Arguments
    • Returns
    • Examples

Add Covariates to All Combinations

Description

This function appends one or more covariate names to all elements (i.e., covariate sets) in a list of character vectors. This is useful when a covariate (like a confounder or control variable) needs to be included in every model. It also works with a single character vector input. The resulting list can be input into the covariates argument in write_inla_formulas.

cov_add(covariates, name, add = FALSE)

Arguments

  • covariates: A character vector or a list of character vectors, where each vector represents a set of covariates (e.g., from cov_multi).
  • name: A character vector of covariate names to be added to each set.
  • add: Boolean that indicates if the original combinations in the covariates argument must be kept. Defaults to FALSE.

Returns

A list of character vectors, with each vector containing the original covariates plus the additional ones specified in the name argument.

Examples

# Multiple combinations
cov_sets <- list(
  c("tmin", "pdsi"),
  c("tmin.l1", "pdsi"),
  c("tmin.l2", "pdsi")
)
cov_add(cov_sets, name = "urban")

Copyright 2025, GHR