Learn R Programming

climatehealth (version 1.0.0)

set_cross_basis: Create a cross-basis matrix set for DLNM analysis

Description

Generates cross-basis matrices for lagged climate variables in a dataset, for use in Distributed Lag Nonlinear Models (DLNM).

Usage

set_cross_basis(data, max_lag = 2, nk = 2)

Value

A list of cross-basis matrices including the basis matrix for maximum temperature, minimun temperature, cumulative rainfall, and relative humidity.

Arguments

data

A dataset returned from combine_health_climate_data(), including lagged variables like tmax_lag1, tmin_lag1, etc.

max_lag

Character. Number corresponding to the maximum lag to be considered for the delay effect. It should be between 2 an 4. Defaults to 2.

nk

Numeric. Number of internal knots for the natural spline of each predictor, controlling its flexibility: nk = 0 produces a linear effect with one basis column, nk = 1 generates a simple spline with two columns, nk = 2 yields a more flexible spline with three columns, and higher values of nk further increase flexibility but may also raise collinearity among spline terms. Defaults to 1