Learn R Programming

climatehealth (version 1.0.0)

fit_air_pollution_gam: Fit GAM model

Description

Fit a generalized additive model (mgcv::gam) including pm25 and its lagged variables (pm25_lag1, ..., pm25_lagN)

Usage

fit_air_pollution_gam(
  data_with_lags,
  max_lag = 14L,
  df_seasonal = 6L,
  family = "quasipoisson"
)

Value

A list with components:

  • model: the fitted mgcv::gam object (or NULL if fit failed)

  • coef_table: data.frame with columns: lag (0 for pm25, 1..N for pm25_lag#, and "0-N" for cumulative), pm25_variable, coef, se, ci.lb, ci.ub

  • vcov_used_for_cumulative: logical; TRUE if vcov() was used to compute cumulative SE

Arguments

data_with_lags

data.frame or tibble containing the outcome, confounders and pm25 lag variables.

max_lag

integer. Maximum lag to include. Defaults to 14.

df_seasonal

integer. Degrees of freedom for seasonal spline. Default 6.

family

character or family object passed to mgcv::gam. Default "quasipoisson".