Fit a generalized additive model (mgcv::gam) including pm25 and its lagged variables (pm25_lag1, ..., pm25_lagN)
fit_air_pollution_gam(
data_with_lags,
max_lag = 14L,
df_seasonal = 6L,
family = "quasipoisson"
)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
data.frame or tibble containing the outcome, confounders and pm25 lag variables.
integer. Maximum lag to include. Defaults to 14.
integer. Degrees of freedom for seasonal spline. Default 6.
character or family object passed to mgcv::gam. Default "quasipoisson".